From 2364f3197e97196a43f14cd8649147c42834ea9b Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Wed, 18 Nov 2026 23:56:20 +0000 Subject: [PATCH 001/195] Check for, for-in and for-of statements, with [~In] heads, against the tokens (7.3) for ( init ; test ; update ), for-in and for-of with a declaration or an identifier as head (ForDeclaration, VariableDeclarationList, a let/const LexicalDeclaration). The head is checked in cx_in(cx, false): binary operators (except in), assignment, unary, member access, bindings and identifiers no longer need [+In]; the driver no longer refuses every node with in_ false or deflt true, only the kinds whose checks need [+In]. Verus: 273 verified; mutate: 6 killed. Verified share 765 to 791 of 1568. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 1031 ++++++++++++++++++- crates/clazel-js-syntax/tests/derivation.rs | 16 +- 2 files changed, 1029 insertions(+), 18 deletions(-) diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index 063f408f..26d3374b 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -11,7 +11,7 @@ //! spread, `this`/`null`/`true`/`false`; and the statements expression, empty, //! `var`/`let`/`const` (no destructuring), block, `if`, `while`, `do`-`while`, //! `throw`, `break`/`continue`, labelled, `try`/`catch`/`finally`, `switch` and -//! `debugger`, `return`; function declarations and expressions, generators, +//! `debugger`, `return`; `for` (all heads); function declarations and expressions, generators, //! `async` functions, arrow functions (simple parameters, defaults and `...rest` //! of a name), `yield` and `await`. Each node is checked in the context its //! parent's production gives it (`Done::cxs`, [`Cx5`]); the assignment is @@ -852,8 +852,7 @@ proof fn lemma_binary_done( 0 <= m < a.nodes.len(), 0 <= l < m, 0 <= r < m, - cx_in(cx, true) == cx, - cx.in_, + a.nodes[m].op == Op::In ==> cx.in_, a.nodes[m].children =~= seq![l, r], is_bin_kind(a.nodes[m].kind), bin_op_ok(a.nodes[m].kind, a.nodes[m].op), @@ -929,8 +928,6 @@ fn check_binary( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, - g.cx.in_, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), @@ -955,7 +952,13 @@ fn check_binary( }, }; let (own, lmin, rmin, opok) = bin_info(nd.kind, nd.op); - if !opok || nd.children.len() != 2 { + let cxm = match done.cxs.get(m) { + Some(c) => c, + None => { + return None; + }, + }; + if !opok || nd.children.len() != 2 || (matches!(nd.op, Op::In) && !cxm.i) { return None; } let l = match nd.children.as_slice().get(ZERO) { @@ -1082,6 +1085,9 @@ fn check_binary( assert(is_op_tok(g.ts, mi as int, op)) by { lemma_op_chars(op); } + assert(cxm == &done.cxs@[m as int]); + assert(g.cx.in_ == cxm.i); + assert(a.nodes[m as int].op == nd.op); lemma_binary_done(a, g.ts, g.cx, m as int, l as int, r as int, lo_l as int, mi as int, lo_r as int, j as int); } Some((lo_l, j, own)) @@ -1627,7 +1633,6 @@ fn check_list( ) -> (r: Option) requires ls.m < nodes.len(), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, ls.m as int), cx_ok(arena_of(nodes@), done.cxs@, ls.m as int, g.cx), @@ -1783,7 +1788,6 @@ fn check_list( e <= toks.len(), pos <= e, ast_wf(a), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), cx_ok(a, done.cxs@, m as int, g.cx), @@ -2923,7 +2927,7 @@ fn check_binding( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, + nodes@[m as int].kind == NodeKind::BindingElement ==> cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), @@ -3137,7 +3141,7 @@ proof fn lemma_decl_stmt_done( ) requires toks_wf(ts), - cx_in(cx, true) == cx, + a.nodes[m].kind == NodeKind::VariableStatement ==> cx_in(cx, true) == cx, 0 <= m < a.nodes.len(), 0 <= x < tn(ts), a.nodes[m].children.len() > 0, @@ -3209,7 +3213,7 @@ fn check_decl_stmt( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, + nodes@[m as int].kind == NodeKind::VariableStatement ==> cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), @@ -5921,20 +5925,47 @@ pub fn check_derivation( return Derivation::Failed; }, }; - // The statements and expressions covered so far are checked with `[+In]`. - if !cxm.i || cxm.d { - return Derivation::Unsupported; - } + // Most statements and expressions are checked with `[+In]` and no `[Default]`. + let plain = cxm.i && !cxm.d; proof { lemma_env_toks_wf(src@, nodes@, toks@, gaps@, ts); } let ghost cx = cx_of(cxm); proof { - assert(cx_in(cx, true) == cx); + if plain { + assert(cx_in(cx, true) == cx); + } assert(cxm == done.cxs@[m as int]); } let is_arrow = matches!(nd.kind, NodeKind::ArrowFunction | NodeKind::AsyncArrowFunction); - let res = if is_arrow { + let is_for = matches!( + nd.kind, + NodeKind::ForStatement | NodeKind::ForInStatement | NodeKind::ForOfStatement + ); + let res = if is_for { + if !plain { + return Derivation::Unsupported; + } + let cxi = cx5_noin(&cxm); + if matches!(nd.kind, NodeKind::ForStatement) { + if !kids_cx4(nodes, done.cxs.as_slice(), m, &cxi, &cxm, &cxm, &cxm) { + return Derivation::Unsupported; + } + proof { + assert(nd == &nodes@[m as int]); + } + check_for(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + } else { + if !kids_cx3(nodes, done.cxs.as_slice(), m, &cxi, &cxm, &cxm) { + return Derivation::Unsupported; + } + let sh = InOfShape { m, of: matches!(nd.kind, NodeKind::ForOfStatement) }; + proof { + assert(nd == &nodes@[m as int]); + } + check_for_in_of(src, nodes, toks, gaps, &done, &sh, Ghost(GCx { ts, cx })) + } + } else if is_arrow { let is_async = matches!(nd.kind, NodeKind::AsyncArrowFunction); if nd.children.len() != 2 { return Derivation::Unsupported; @@ -5979,7 +6010,26 @@ pub fn check_derivation( if !kids_cx(nodes, done.cxs.as_slice(), m, &cxm) { return Derivation::Unsupported; } + // The kinds whose checks do not need `[+In]`. + let any_ctx = matches!( + nd.kind, + NodeKind::NumericLiteral | NodeKind::StringLiteral | NodeKind::RegularExpressionLiteral + | NodeKind::IdentifierName | NodeKind::AdditiveExpression | NodeKind::MultiplicativeExpression + | NodeKind::ExponentiationExpression | NodeKind::ShiftExpression | NodeKind::EqualityExpression + | NodeKind::BitwiseANDExpression | NodeKind::BitwiseXORExpression | NodeKind::BitwiseORExpression + | NodeKind::LogicalANDExpression | NodeKind::LogicalORExpression | NodeKind::CoalesceExpression + | NodeKind::RelationalExpression | NodeKind::IdentifierReference | NodeKind::BindingIdentifier + | NodeKind::LabelIdentifier | NodeKind::ThisExpression | NodeKind::NullLiteral + | NodeKind::BooleanLiteral | NodeKind::UnaryExpression | NodeKind::AssignmentExpression + | NodeKind::MemberExpression | NodeKind::VariableDeclaration | NodeKind::LexicalBinding + | NodeKind::VariableDeclarationList | NodeKind::ForDeclaration | NodeKind::LexicalDeclaration + ); + if !plain && !any_ctx { + return Derivation::Unsupported; + } match nd.kind { + NodeKind::VariableDeclarationList => check_var_list(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ForDeclaration => check_for_decl(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::NumericLiteral | NodeKind::StringLiteral | NodeKind::RegularExpressionLiteral | NodeKind::IdentifierName => { proof { lemma_env_literal_facts(src@, nodes@, toks@, gaps@, ts); @@ -6300,6 +6350,25 @@ fn child_cx(kind: NodeKind, k: usize, p: &Cx5, ident: bool, braced: bool) -> (r: let (c0, c1) = arrow_cx5(p, matches!(kind, NodeKind::AsyncArrowFunction), ident, braced); return if k == 0 { c0 } else { c1 }; } + if matches!( + kind, + NodeKind::ForStatement | NodeKind::ForInStatement | NodeKind::ForOfStatement + ) { + return if k == 0 { cx5_noin(p) } else { *p }; + } + // These productions pass their own context to their children. + if matches!( + kind, + NodeKind::AdditiveExpression | NodeKind::MultiplicativeExpression | NodeKind::ExponentiationExpression + | NodeKind::ShiftExpression | NodeKind::EqualityExpression | NodeKind::BitwiseANDExpression + | NodeKind::BitwiseXORExpression | NodeKind::BitwiseORExpression | NodeKind::LogicalANDExpression + | NodeKind::LogicalORExpression | NodeKind::CoalesceExpression | NodeKind::RelationalExpression + | NodeKind::UnaryExpression | NodeKind::AssignmentExpression | NodeKind::MemberExpression + | NodeKind::VariableDeclaration | NodeKind::LexicalBinding | NodeKind::VariableDeclarationList + | NodeKind::LexicalDeclaration | NodeKind::ForDeclaration + ) { + return *p; + } Cx5 { y: p.y, a: p.a, i: true, r: p.r, d: false } } @@ -10600,4 +10669,932 @@ fn check_rest_param( Some((x, j, -100)) } +// --------------------------------------------------------------------- +// The `for` statements (§14.7.4, §14.7.5): their heads are `[~In]`. +// --------------------------------------------------------------------- + +/// The context of a `for` head: `[~In]`, `[Default]` cleared (`cx_in(cx, false)`). +fn cx5_noin(p: &Cx5) -> (r: Cx5) + ensures + cx_of(r) == cx_in(cx_of(*p), false), +{ + Cx5 { y: p.y, a: p.a, i: false, r: p.r, d: false } +} + +/// The four children of node `m` are checked in `c0`..`c3`. +pub open spec fn cx_kids4(a: AstV, cxs: Seq, m: int, c0: Ctx, c1: Ctx, c2: Ctx, c3: Ctx) -> bool { + 0 <= m < a.nodes.len() && a.nodes[m].children.len() == 4 && (forall|k: int| + 0 <= k < 4 ==> 0 <= #[trigger] a.nodes[m].children[k] < cxs.len()) && cx_of( + cxs[a.nodes[m].children[0]], + ) == c0 && cx_of(cxs[a.nodes[m].children[1]]) == c1 && cx_of(cxs[a.nodes[m].children[2]]) + == c2 && cx_of(cxs[a.nodes[m].children[3]]) == c3 +} + +/// The four children of node `m` are checked in `c0`..`c3`. +fn kids_cx4(nodes: &[Node], cxs: &[Cx5], m: usize, c0: &Cx5, c1: &Cx5, c2: &Cx5, c3: &Cx5) -> (r: bool) + requires + m < nodes.len(), + cxs.len() == nodes.len(), + ast_wf(arena_of(nodes@)), + ensures + r ==> cx_kids4(arena_of(nodes@), cxs@, m as int, cx_of(*c0), cx_of(*c1), cx_of(*c2), cx_of(*c3)), +{ + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return false; + }, + }; + if nd.children.len() != 4 { + return false; + } + let a0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return false; + }, + }; + let a1 = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return false; + }, + }; + let a2 = match kid_of(nodes, m, 2) { + Some(c) => c, + None => { + return false; + }, + }; + let a3 = match kid_of(nodes, m, 3) { + Some(c) => c, + None => { + return false; + }, + }; + let (k0, k1, k2, k3) = match (cxs.get(a0), cxs.get(a1), cxs.get(a2), cxs.get(a3)) { + (Some(x), Some(y), Some(z), Some(w)) => (x, y, z, w), + _ => { + return false; + }, + }; + let ok = cx_eq(k0, c0) && cx_eq(k1, c1) && cx_eq(k2, c2) && cx_eq(k3, c3); + proof { + let a = arena_of(nodes@); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + if ok { + assert forall|k: int| 0 <= k < 4 implies 0 <= #[trigger] a.nodes[m as int].children[k] < cxs.len() by { + lemma_child_before(a, m as int, k); + } + } + } + ok +} + +/// Token `x` is not the keyword `w` (it may not exist). +fn not_word_at( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + x: usize, + w: &[u32], + Ghost(gw): Ghost, +) -> (r: bool) + requires + env_ok(src@, nodes@, toks@, gaps@, gw.g.ts), + cps(gw.w) =~= w@, + ensures + r ==> !is_kw(gw.g.ts, x as int, gw.w), +{ + let _ = (nodes.len(), gaps.len()); + let ghost g = gw.g; + proof { + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let t = match toks.get(x) { + Some(t) => t, + None => { + return true; + }, + }; + proof { + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, x as int); + assert(t == &toks@[x as int]); + } + let r = !(matches!(t.kind, TokKind::IdentifierName) && !t.escaped && text_is(src, t, w)); + proof { + if r { + assert(g.ts.toks[x as int].text =~= src@.subrange(t.start as int, t.end as int)); + } + } + r +} + +/// §14.3.2 `var VariableDeclarationList`, as the head of a `for`. +#[verifier::spinoff_prover] +proof fn lemma_vdl_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + a.nodes[m].kind == NodeKind::VariableDeclarationList, + a.nodes[m].children.len() > 0, + is_kw(ts, x, "var"@), + dsep(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e, false), + forall|k: int| + 0 <= k < a.nodes[m].children.len() ==> list_item_ok(a, #[trigger] a.nodes[m].children[k], 2), + x + 1 <= e <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[e - 1].end, + ensures + node_done(a, ts, m, cx, x, e), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, e)); + assert forall|k: int| 0 <= k < a.nodes[m].children.len() implies kd( + a, + #[trigger] a.nodes[m].children[k], + ) == NodeKind::VariableDeclaration by { + assert(list_item_ok(a, a.nodes[m].children[k], 2)); + } + assert(d_stmt(a, ts, m, cx, x, e)); + lemma_ed_of(a, ts, m, x, e); +} + +/// §14.3.2 `var VariableDeclarationList`. +#[verifier::spinoff_prover] +fn check_var_list( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_decl_words(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::VariableDeclarationList) || nd.children.is_empty() { + return None; + } + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if !word_at(src, nodes, toks, gaps, x, &[0x76, 0x61, 0x72], Ghost(GW { g, w: "var"@ })) { + return None; + } + let ls = ListSpec { m, start: x.saturating_add(1), mode: 2, trail: false }; + let e = match check_list(src, nodes, toks, gaps, done, &ls, Ghost(g)) { + Some(e) => e, + None => { + return None; + }, + }; + if !end_ok(src, nodes, toks, gaps, nd.end, e, Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + assert(a.nodes[m as int].children.len() > 0); + lemma_vdl_done(a, g.ts, g.cx, m as int, x as int, e as int); + } + Some((x, e, -100)) +} + +/// §14.7.5 `ForDeclaration : var|let|const ForBinding`. +#[verifier::spinoff_prover] +proof fn lemma_for_decl_done(a: AstV, ts: Stream, cx: Ctx, m: int, c: int, x: int, j: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c < m, + a.nodes[m].kind == NodeKind::ForDeclaration, + a.nodes[m].children =~= seq![c], + if a.nodes[m].op == Op::Var { + is_kw(ts, x, "var"@) + } else if a.nodes[m].op == Op::Let { + is_kw(ts, x, "let"@) + } else { + a.nodes[m].op == Op::Const && is_kw(ts, x, "const"@) + }, + kd(a, c) == NodeKind::BindingIdentifier, + node_done(a, ts, c, cx, x + 1, j), + x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c); + assert(dc(a, ts, m, c, cx, x + 1, j)); + assert(d_stmt(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §14.7.5 `ForDeclaration`. +#[verifier::spinoff_prover] +fn check_for_decl( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_decl_words(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ForDeclaration) || nd.children.len() != 1 { + return None; + } + let c = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let kw_ok = match nd.op { + Op::Var => word_at(src, nodes, toks, gaps, x, &[0x76, 0x61, 0x72], Ghost(GW { g, w: "var"@ })), + Op::Let => word_at(src, nodes, toks, gaps, x, &[0x6C, 0x65, 0x74], Ghost(GW { g, w: "let"@ })), + Op::Const => word_at(src, nodes, toks, gaps, x, &[0x63, 0x6F, 0x6E, 0x73, 0x74], Ghost(GW { g, w: "const"@ })), + _ => false, + }; + let (lo_c, j, _) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + if !kw_ok || !matches!(kind_at(nodes, c), NodeKind::BindingIdentifier) + || lo_c != x.saturating_add(1) || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) + || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(a.nodes[m as int].children =~= seq![c as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].op == nd.op); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 0); + lemma_for_decl_done(a, g.ts, g.cx, m as int, c as int, x as int, j as int); + } + Some((x, j, -100)) +} + +/// §14.7.4 `for ( init ; test ; update ) Statement`. +#[verifier::spinoff_prover] +#[verifier::rlimit(300)] +proof fn lemma_for_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + k0: int, + k1: int, + k2: int, + k3: int, + x: int, + m0: int, + q: int, + r: int, + j: int, +) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= k0 < m, + 0 <= k1 < m, + 0 <= k2 < m, + 0 <= k3 < m, + a.nodes[m].kind == NodeKind::ForStatement, + a.nodes[m].children =~= seq![k0, k1, k2, k3], + is_kw(ts, x, "for"@), + is_p(ts, x + 1, "("@), + is_statement_kind(kd(a, k3)), + d(a, ts, k0, cx_in(cx, false), x + 2, m0), + ed(a, ts, k0, x + 2) == m0, + if kd(a, k0) == NodeKind::LexicalDeclaration { + is_p(ts, m0 - 1, ";"@) + } else { + is_p(ts, m0, ";"@) && (kd(a, k0) == NodeKind::Absent || kd(a, k0) + == NodeKind::VariableDeclarationList || (lvl(a, k0) >= -1 && !(is_kw( + ts, + x + 2, + "let"@, + ) && is_p(ts, x + 3, "["@)))) + }, + opt_expr(a, k1), + d(a, ts, k1, cx, for_init_next(a, ts, k0, x + 2), q), + ed(a, ts, k1, for_init_next(a, ts, k0, x + 2)) == q, + is_p(ts, q, ";"@), + opt_expr(a, k2), + d(a, ts, k2, cx, q + 1, r), + ed(a, ts, k2, q + 1) == r, + is_p(ts, r, ")"@), + d(a, ts, k3, cx, r + 1, j), + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == k0); + assert(a.nodes[m].children[1] == k1); + assert(a.nodes[m].children[2] == k2); + assert(a.nodes[m].children[3] == k3); + assert(for_init_ok(a, ts, m, k0, cx, x + 2)); + assert(dc(a, ts, m, k1, cx, for_init_next(a, ts, k0, x + 2), q)); + assert(dc(a, ts, m, k2, cx, q + 1, r)); + assert(dc(a, ts, m, k3, cx, r + 1, j)); + assert(d_stmt(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §14.7.4 `for ( init ; test ; update ) Statement`. +#[verifier::spinoff_prover] +fn check_for( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + 0 <= m < done.cxs@.len(), + cx_of(done.cxs@[m as int]) == g.cx, + cx_kids4( + arena_of(nodes@), + done.cxs@, + m as int, + cx_in(g.cx, false), + g.cx, + g.cx, + g.cx, + ), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words5(); + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ForStatement) || nd.children.len() != 4 { + return None; + } + let k0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let k1 = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let k2 = match kid_of(nodes, m, 2) { + Some(c) => c, + None => { + return None; + }, + }; + let k3 = match kid_of(nodes, m, 3) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if !word_at(src, nodes, toks, gaps, x, &[0x66, 0x6F, 0x72], Ghost(GW { g, w: "for"@ })) + || !punct_at(src, nodes, toks, gaps, x.saturating_add(1), 0x28, Ghost(GW { g, w: "("@ })) { + return None; + } + let s = x.saturating_add(2); + let ghost cxi = cx_in(g.cx, false); + // The initializer. + let ki = kind_at(nodes, k0); + let lexical = matches!(ki, NodeKind::LexicalDeclaration); + let (m0, lv0): (usize, i32) = if matches!(ki, NodeKind::Absent) { + if !check_absent(src, nodes, toks, gaps, k0, s, Ghost(GCx { ts: g.ts, cx: cxi })) { + return None; + } + (s, -100) + } else { + let (lo0, h0, lv0) = match done_at(done, k0) { + Some(r) => r, + None => { + return None; + }, + }; + if lo0 != s { + return None; + } + (h0, lv0) + }; + let p0: usize = if lexical { m0 } else { m0.saturating_add(1) }; + if lexical { + if m0 < 1 || !punct_at(src, nodes, toks, gaps, m0.saturating_sub(1), 0x3B, Ghost(GW { g, w: ";"@ })) { + return None; + } + } else { + let init_ok = matches!(ki, NodeKind::Absent | NodeKind::VariableDeclarationList) + || (lv0 >= -1 && not_word_at(src, nodes, toks, gaps, s, &[0x6C, 0x65, 0x74], Ghost(GW { g, w: "let"@ }))); + if !init_ok || !punct_at(src, nodes, toks, gaps, m0, 0x3B, Ghost(GW { g, w: ";"@ })) { + return None; + } + } + // The test. + let kt = kind_at(nodes, k1); + let q: usize = if matches!(kt, NodeKind::Absent) { + if !check_absent(src, nodes, toks, gaps, k1, p0, Ghost(g)) { + return None; + } + p0 + } else { + let (lo1, h1, lv1) = match done_at(done, k1) { + Some(r) => r, + None => { + return None; + }, + }; + if lo1 != p0 || lv1 < -1 { + return None; + } + h1 + }; + if !punct_at(src, nodes, toks, gaps, q, 0x3B, Ghost(GW { g, w: ";"@ })) { + return None; + } + // The update. + let q1 = q.saturating_add(1); + let ku = kind_at(nodes, k2); + let rr: usize = if matches!(ku, NodeKind::Absent) { + if !check_absent(src, nodes, toks, gaps, k2, q1, Ghost(g)) { + return None; + } + q1 + } else { + let (lo2, h2, lv2) = match done_at(done, k2) { + Some(r) => r, + None => { + return None; + }, + }; + if lo2 != q1 || lv2 < -1 { + return None; + } + h2 + }; + if !punct_at(src, nodes, toks, gaps, rr, 0x29, Ghost(GW { g, w: ")"@ })) { + return None; + } + let (lo3, j, _) = match done_at(done, k3) { + Some(r) => r, + None => { + return None; + }, + }; + if !stmt_kind_exec(kind_at(nodes, k3)) || lo3 != rr.saturating_add(1) + || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(s as int == x as int + 2); + assert(q1 as int == q as int + 1); + assert(rr.saturating_add(1) as int == rr as int + 1); + assert(a.nodes[m as int].children =~= seq![k0 as int, k1 as int, k2 as int, k3 as int]) by { + assert(a.nodes[m as int].children.len() == 4); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k0 as int); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k2 as int); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k3 as int); + assert(kd(a, k0 as int) == ki); + assert(kd(a, k1 as int) == kt); + assert(kd(a, k2 as int) == ku); + assert(kd(a, k3 as int) == nodes@[k3 as int].kind); + assert(is_statement_kind(kd(a, k3 as int))); + assert(cx_of(done.cxs@[k0 as int]) == cxi); + assert(cx_of(done.cxs@[k1 as int]) == g.cx); + assert(cx_of(done.cxs@[k2 as int]) == g.cx); + assert(cx_of(done.cxs@[k3 as int]) == g.cx); + if !matches!(ki, NodeKind::Absent) { + assert(lvl(a, k0 as int) == lv0 as int); + assert(kd(a, k0 as int) != NodeKind::Absent); + } + if !matches!(kt, NodeKind::Absent) { + assert(kd(a, k1 as int) != NodeKind::Absent); + } + if !matches!(ku, NodeKind::Absent) { + assert(kd(a, k2 as int) != NodeKind::Absent); + } + assert(opt_expr(a, k1 as int)); + assert(opt_expr(a, k2 as int)); + assert(for_init_next(a, g.ts, k0 as int, x as int + 2) == p0 as int); + assert(m0 >= 1 || !lexical); + lemma_for_done(a, g.ts, g.cx, m as int, k0 as int, k1 as int, k2 as int, k3 as int, x as int, m0 as int, q as int, rr as int, j as int); + } + Some((x, j, -100)) +} + +/// §14.7.5 `for ( ForDeclaration|LeftHandSideExpression in|of ... ) Statement`. +#[verifier::spinoff_prover] +#[verifier::rlimit(60)] +proof fn lemma_for_in_of_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + h: int, + e: int, + b: int, + of: bool, + x: int, + mh: int, + q: int, + j: int, +) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= h < m, + 0 <= e < m, + 0 <= b < m, + a.nodes[m].kind == (if of { + NodeKind::ForOfStatement + } else { + NodeKind::ForInStatement + }), + a.nodes[m].children =~= seq![h, e, b], + !a.nodes[m].flag, + is_kw(ts, x, "for"@), + is_p(ts, x + 1, "("@), + for_head_ok(a, ts, h, x + 2, of, false), + of ==> first_kid_kind(a, h) != NodeKind::VariableDeclaration, + if of { + is_assign_expr(a, e) + } else { + lvl(a, e) >= -1 + }, + is_statement_kind(kd(a, b)), + d(a, ts, h, cx_in(cx, false), x + 2, mh), + ed(a, ts, h, x + 2) == mh, + is_kw(ts, mh, if of { + "of"@ + } else { + "in"@ + }), + d(a, ts, e, cx, mh + 1, q), + ed(a, ts, e, mh + 1) == q, + is_p(ts, q, ")"@), + d(a, ts, b, cx, q + 1, j), + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == h); + assert(a.nodes[m].children[1] == e); + assert(a.nodes[m].children[2] == b); + assert(dc(a, ts, m, h, cx_in(cx, false), x + 2, mh)); + assert(dc(a, ts, m, e, cx, mh + 1, q)); + assert(dc(a, ts, m, b, cx, q + 1, j)); + assert(d_stmt(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// What `check_for_in_of` reads: the node, and whether it is `for`-`of`. +pub struct InOfShape { + /// The node. + pub m: usize, + /// `for`-`of` (else `for`-`in`). + pub of: bool, +} + +/// §14.7.5 `for ( head in|of expression ) Statement`, with a declaration or an +/// identifier as head. +#[verifier::spinoff_prover] +fn check_for_in_of( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + sh: &InOfShape, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + sh.m < nodes.len(), + cx_in(g.cx, true) == g.cx, + nodes@[sh.m as int].kind == (if sh.of { + NodeKind::ForOfStatement + } else { + NodeKind::ForInStatement + }), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, sh.m as int), + 0 <= sh.m < done.cxs@.len(), + cx_of(done.cxs@[sh.m as int]) == g.cx, + cx_kids3(arena_of(nodes@), done.cxs@, sh.m as int, cx_in(g.cx, false), g.cx, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + sh.m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), sh.m as int), + None => true, + }, +{ + let m = sh.m; + proof { + lemma_words5(); + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if nd.children.len() != 3 || nd.flag { + return None; + } + let h = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let e = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let b = match kid_of(nodes, m, 2) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if !word_at(src, nodes, toks, gaps, x, &[0x66, 0x6F, 0x72], Ghost(GW { g, w: "for"@ })) + || !punct_at(src, nodes, toks, gaps, x.saturating_add(1), 0x28, Ghost(GW { g, w: "("@ })) { + return None; + } + let s = x.saturating_add(2); + let kh = kind_at(nodes, h); + let decl = matches!(kh, NodeKind::ForDeclaration); + // A head that is not a declaration is an identifier reference, not `let` (`async` for `of`). + let head_ok = decl || (matches!(kh, NodeKind::IdentifierReference) + && not_word_at(src, nodes, toks, gaps, s, &[0x6C, 0x65, 0x74], Ghost(GW { g, w: "let"@ })) + && (!sh.of || not_word_at(src, nodes, toks, gaps, s, &[0x61, 0x73, 0x79, 0x6E, 0x63], Ghost(GW { g, w: "async"@ })))); + let head_first_ok = if decl { + match kid_of(nodes, h, 0) { + Some(c) => !matches!(kind_at(nodes, c), NodeKind::VariableDeclaration), + None => false, + } + } else { + match nodes.get(h) { + Some(hn) => hn.children.is_empty(), + None => false, + } + }; + let (lo_h, mh, _) = match done_at(done, h) { + Some(r) => r, + None => { + return None; + }, + }; + let (lo_e, q, lv_e) = match done_at(done, e) { + Some(r) => r, + None => { + return None; + }, + }; + let (lo_b, j, _) = match done_at(done, b) { + Some(r) => r, + None => { + return None; + }, + }; + let kw_ok = if sh.of { + word_at(src, nodes, toks, gaps, mh, &[0x6F, 0x66], Ghost(GW { g, w: "of"@ })) + } else { + word_at(src, nodes, toks, gaps, mh, &[0x69, 0x6E], Ghost(GW { g, w: "in"@ })) + }; + let e_ok = if sh.of { lv_e >= 0 } else { lv_e >= -1 }; + if !head_ok || !head_first_ok || lo_h != s || !kw_ok || !e_ok || lo_e != mh.saturating_add(1) + || !punct_at(src, nodes, toks, gaps, q, 0x29, Ghost(GW { g, w: ")"@ })) + || !stmt_kind_exec(kind_at(nodes, b)) || lo_b != q.saturating_add(1) + || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(s as int == x as int + 2); + assert(mh.saturating_add(1) as int == mh as int + 1); + assert(q.saturating_add(1) as int == q as int + 1); + assert(a.nodes[m as int].children =~= seq![h as int, e as int, b as int]) by { + assert(a.nodes[m as int].children.len() == 3); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].flag == nd.flag); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, h as int); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, e as int); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, b as int); + assert(kd(a, h as int) == kh); + assert(kd(a, b as int) == nodes@[b as int].kind); + assert(is_statement_kind(kd(a, b as int))); + assert(cx_of(done.cxs@[h as int]) == cx_in(g.cx, false)); + assert(cx_of(done.cxs@[e as int]) == g.cx); + assert(cx_of(done.cxs@[b as int]) == g.cx); + assert(lvl(a, e as int) == lv_e as int); + if sh.of { + assert(is_assign_expr(a, e as int)); + } + // The head. + if !decl { + assert(kd(a, h as int) == NodeKind::IdentifierReference); + assert(lvl(a, h as int) == 17); + assert(is_destructuring_target(a, h as int)); + } + assert(a.nodes[h as int] == nodes@[h as int]@); + assert(for_head_ok(a, g.ts, h as int, x as int + 2, sh.of, false)) by { + if !decl { + assert(!is_kw(g.ts, s as int, "let"@)); + } + } + assert(sh.of ==> first_kid_kind(a, h as int) != NodeKind::VariableDeclaration) by { + if sh.of { + if decl { + let hc = a.nodes[h as int].children[0]; + assert(kid(kids(a, h as int), 0) == hc); + } else { + assert(a.nodes[h as int].children.len() == 0); + assert(kid(kids(a, h as int), 0) == -1int); + } + } + } + lemma_for_in_of_done(a, g.ts, g.cx, m as int, h as int, e as int, b as int, sh.of, x as int, mh as int, q as int, j as int); + } + Some((x, j, -100)) +} + +/// The words `for`, `of` and `in`, as code points. +proof fn lemma_words5() + ensures + cps("for"@) =~= seq![0x66u32, 0x6F, 0x72], + cps("of"@) =~= seq![0x6Fu32, 0x66], + cps("in"@) =~= seq![0x69u32, 0x6E], + cps("let"@) =~= seq![0x6Cu32, 0x65, 0x74], + cps("async"@) =~= seq![0x61u32, 0x73, 0x79, 0x6E, 0x63], +{ + reveal_strlit("for"); + reveal_strlit("of"); + reveal_strlit("in"); + reveal_strlit("let"); + reveal_strlit("async"); + assert("for"@ =~= seq!['f', 'o', 'r']); + assert("of"@ =~= seq!['o', 'f']); + assert("in"@ =~= seq!['i', 'n']); + assert("let"@ =~= seq!['l', 'e', 't']); + assert("async"@ =~= seq!['a', 's', 'y', 'n', 'c']); +} + } // verus! diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index 60b9e7be..a1f6d28a 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -82,6 +82,20 @@ var c;", "(async a => await a);", "(async (a) => 1);", "function f() { function g() { return 1 } return g }", + "for (;;) ;", + "for (;;) { break; }", + "for (a = 0; a < 10; a = a + 1) b;", + "for (var i = 0, n = 5; i < n; i = i + 1) { c }", + "for (let i = 0; i < n; i = i + 1) c;", + "for (const i = 0;;) c;", + "for (var i = 0 + 1 * 2;;) ;", + "for (x of y) z;", + + "for (let x in o) z;", + "for (x in o) ;", + "for (const a of b.c) { d }", + "for (var i in a, b) ;", + "for (a in b) for (c of d) e;", "while (a) b;", "while (a) { b; c }", "do a; while (b)", @@ -118,7 +132,7 @@ var c;", #[test] fn other_programs_are_unsupported_not_failed() { - for s in ["for (;;) ;", "var [a] = 1;", "[1];", "({});"] { + for s in ["for (a, b;;) ;", "var [a] = 1;", "[1];", "({});"] { assert!( derivation(s, SourceGoal::Script) == Some(Derivation::Unsupported), "{s}" From 672f5d680b71e1eadc9e7d9d0812263f65a088cc Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Thu, 19 Nov 2026 03:27:40 +0000 Subject: [PATCH 002/195] Check array and object literals against the tokens (7.3) ArrayLiteral (darray: elements, holes, spread, trailing comma), ObjectLiteral and its PropertyDefinitions (shorthand, key: value, spread), ComputedPropertyName, Elision. Methods, getters/setters and name = init (CoverInitializedName) are not covered yet. Verus: 287 verified. Verified share 791 to 829 of 1568; harness files 7 to 10 of 41. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 890 +++++++++++++++++++- crates/clazel-js-syntax/tests/derivation.rs | 18 +- 2 files changed, 901 insertions(+), 7 deletions(-) diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index 26d3374b..e69a1ee6 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -1582,6 +1582,8 @@ pub open spec fn item_ok_val(l: int, k: NodeKind, mode: int) -> bool { k == NodeKind::VariableDeclaration } else if mode == 3 { k == NodeKind::LexicalBinding + } else if mode == 5 { + k == NodeKind::PropertyDefinition } else { k == NodeKind::BindingElement || k == NodeKind::FunctionRestParameter } @@ -1600,6 +1602,8 @@ fn item_ok_exec(l: i32, k: NodeKind, mode: u8) -> (r: bool) matches!(k, NodeKind::VariableDeclaration) } else if mode == 3 { matches!(k, NodeKind::LexicalBinding) + } else if mode == 5 { + matches!(k, NodeKind::PropertyDefinition) } else { matches!(k, NodeKind::BindingElement | NodeKind::FunctionRestParameter) } @@ -5009,6 +5013,7 @@ proof fn lemma_env_gap(src: Seq, nodes: Seq, toks: Seq, gaps: S } /// Extending the processed nodes by one. +#[verifier::rlimit(100)] proof fn lemma_inv_push( a: AstV, ts: Stream, @@ -5039,23 +5044,28 @@ proof fn lemma_inv_push( assert(lo2.len() == m + 1); assert(hi2.len() == m + 1); assert(lv2.len() == m + 1); - assert forall|j: int| 0 <= j < m + 1 implies (#[trigger] lv2[j]) as int == lvl(a, j) - && (kd(a, j) != NodeKind::Absent ==> node_done( + assert forall|j: int| 0 <= j < m + 1 implies (#[trigger] lv2[j]) as int == lvl(a, j) by { + if j < m { + assert(lv2[j] == lv[j]); + } else { + assert(lv2[j] == l); + } + } + assert forall|j: int| 0 <= j < m + 1 implies (kd(a, j) != NodeKind::Absent ==> node_done( a, ts, j, cx_of(cxs[j]), - lo2[j] as int, + #[trigger] lo2[j] as int, hi2[j] as int, )) by { if j < m { + assert(lv[j] as int == lvl(a, j)); assert(lo2[j] == lo[j]); assert(hi2[j] == hi[j]); - assert(lv2[j] == lv[j]); } else { assert(lo2[j] == l0); assert(hi2[j] == h0); - assert(lv2[j] == l); } } } @@ -5063,6 +5073,7 @@ proof fn lemma_inv_push( /// Extending the processed nodes by an `Absent` node, which has no token range of /// its own: its parent places it. +#[verifier::rlimit(100)] proof fn lemma_inv_push_absent( a: AstV, ts: Stream, @@ -6207,6 +6218,11 @@ pub fn check_derivation( NodeKind::DefaultClause => check_default(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ReturnStatement => check_return(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::FormalParameters => check_params(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ArrayLiteral => check_array(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ObjectLiteral => check_object(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::PropertyDefinition => check_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ComputedPropertyName => check_computed(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::Elision => check_elision(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::FunctionRestParameter => check_rest_param(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::YieldExpression => check_yield(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::AwaitExpression => check_await(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), @@ -11597,4 +11613,868 @@ proof fn lemma_words5() assert("async"@ =~= seq!['a', 's', 'y', 'n', 'c']); } +// --------------------------------------------------------------------- +// Array and object literals (§13.2.4, §13.2.5): elements, holes, spread, +// properties (shorthand, `key: value`, spread), computed names. +// --------------------------------------------------------------------- + +/// What an array literal accepts as an element. +pub open spec fn array_item_ok(a: AstV, c: int) -> bool { + lvl(a, c) >= 0 || kd(a, c) == NodeKind::SpreadElement || kd(a, c) == NodeKind::Elision +} + +/// `array_item_ok`, executable. +fn array_item_exec(l: i32, k: NodeKind) -> (r: bool) + ensures + r ==> (l as int >= 0 || k == NodeKind::SpreadElement || k == NodeKind::Elision), +{ + l >= 0 || matches!(k, NodeKind::SpreadElement | NodeKind::Elision) +} + +/// §13.2.4 `Elision : ,` (a hole): a `,`. +#[verifier::spinoff_prover] +proof fn lemma_elision_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= x < tn(ts), + a.nodes[m].kind == NodeKind::Elision, + a.nodes[m].children.len() == 0, + is_p(ts, x, ","@), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[x].end, + ensures + node_done(a, ts, m, cx, x, x + 1), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, x + 1)); + assert(d_pat(a, ts, m, cx, x, x + 1)); + lemma_ed_of(a, ts, m, x, x + 1); +} + +/// §13.2.4 an `Elision`. +#[verifier::spinoff_prover] +fn check_elision( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_comma_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::Elision) || !nd.children.is_empty() { + return None; + } + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if !punct_at(src, nodes, toks, gaps, x, 0x2C, Ghost(GW { g, w: ","@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, x.saturating_add(1), Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].children.len() == 0); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_elision_done(a, g.ts, g.cx, m as int, x as int); + } + Some((x, x.saturating_add(1), -100)) +} + +/// The elements of an array literal: `spec::darray` of the children, ending at `e`. +fn check_array_items( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + ls: &ListSpec, + Ghost(g): Ghost, +) -> (r: Option) + requires + ls.m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, ls.m as int), + cx_ok(arena_of(nodes@), done.cxs@, ls.m as int, g.cx), + ensures + match r { + Some(e) => ls.start <= e && e <= toks.len() && darray( + arena_of(nodes@), + g.ts, + ls.m as int, + arena_of(nodes@).nodes[ls.m as int].children, + 0, + g.cx, + ls.start as int, + e as int, + ) && forall|k: int| + 0 <= k < arena_of(nodes@).nodes[ls.m as int].children.len() ==> array_item_ok( + arena_of(nodes@), + #[trigger] arena_of(nodes@).nodes[ls.m as int].children[k], + ), + None => true, + }, +{ + let _ = gaps.len(); + let m = ls.m; + let start = ls.start; + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let len = nd.children.len(); + let ghost a = arena_of(nodes@); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + if len == 0 { + if start > toks.len() { + return None; + } + proof { + assert(darray(a, g.ts, m as int, a.nodes[m as int].children, 0, g.cx, start as int, start as int)); + } + return Some(start); + } + let last = len.saturating_sub(1); + let c = match nd.children.as_slice().get(last) { + Some(x) => *x as usize, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int].children[last as int] == c as int); + lemma_child_before(a, m as int, last as int); + } + if c >= m { + return None; + } + let (lo_c, hc, lvl_c) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + let kc_kind = kind_at(nodes, c); + if !array_item_exec(lvl_c, kc_kind) { + return None; + } + let is_hole = matches!(kc_kind, NodeKind::Elision); + let mut comma_after = false; + if let Some(t) = toks.get(hc) { + proof { + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, hc as int); + assert(t == &toks@[hc as int]); + } + if !is_hole && matches!(t.kind, TokKind::Punctuator) && text_is1(src, t, 0x2C) { + comma_after = true; + } + } + let e: usize = if comma_after { hc.saturating_add(1) } else { hc }; + proof { + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, last as int); + assert(hc <= toks.len()); + assert(kd(a, c as int) == nodes@[c as int].kind); + assert(kd(a, c as int) == kc_kind); + if comma_after { + lemma_comma_text(); + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, hc as int); + assert(hc < toks.len()); + assert(e as int == hc as int + 1); + assert(g.ts.toks[hc as int].kind == TokKind::Punctuator); + assert(g.ts.toks[hc as int].text =~= seq![0x2Cu32]); + assert(is_p(g.ts, hc as int, ","@)); + assert(!is_rest_kind(kd(a, c as int))); + } else { + assert(e == hc); + } + assert(e <= toks.len()); + assert(ed(a, g.ts, c as int, lo_c as int) == hc as int); + let ks = a.nodes[m as int].children; + assert(dc(a, g.ts, m as int, c as int, g.cx, lo_c as int, hc as int)); + reveal_with_fuel(darray, 2); + assert(darray(a, g.ts, m as int, ks, last as int, g.cx, lo_c as int, e as int)); + } + let mut k = last; + let mut pos = lo_c; + while k > 0 + invariant + m < nodes.len(), + nodes@.len() == nodes.len(), + nd == &nodes@[m as int], + a == arena_of(nodes@), + len == nd.children.len(), + len == a.nodes[m as int].children.len(), + k < len, + e <= toks.len(), + pos <= e, + ast_wf(a), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(a, done.cxs@, m as int, g.cx), + darray(a, g.ts, m as int, a.nodes[m as int].children, k as int, g.cx, pos as int, e as int), + forall|q: int| + k <= q < len ==> array_item_ok(a, #[trigger] a.nodes[m as int].children[q]), + decreases k, + { + let c2 = match nd.children.as_slice().get(k.saturating_sub(1)) { + Some(x) => *x as usize, + None => { + return None; + }, + }; + proof { + assert(k >= 1); + assert(k.saturating_sub(1) as int == k as int - 1); + assert(a.nodes[m as int].children[k as int - 1] == c2 as int); + lemma_child_before(a, m as int, k as int - 1); + } + if c2 >= m { + return None; + } + let (lo2, hi2, lvl2) = match done_at(done, c2) { + Some(r) => r, + None => { + return None; + }, + }; + let kind2 = kind_at(nodes, c2); + if !array_item_exec(lvl2, kind2) { + return None; + } + if matches!(kind2, NodeKind::Elision) { + if hi2 != pos { + return None; + } + } else { + let sep = match toks.get(hi2) { + Some(t) => t, + None => { + return None; + }, + }; + proof { + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, hi2 as int); + assert(sep == &toks@[hi2 as int]); + } + if !matches!(sep.kind, TokKind::Punctuator) || !text_is1(src, sep, 0x2C) + || hi2.saturating_add(1) != pos { + return None; + } + } + proof { + lemma_comma_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c2 as int, g.cx, k as int - 1); + assert(kd(a, c2 as int) == kind2); + assert(hi2 <= toks.len()); + assert(ed(a, g.ts, c2 as int, lo2 as int) == hi2 as int); + let ks = a.nodes[m as int].children; + assert(dc(a, g.ts, m as int, c2 as int, g.cx, lo2 as int, hi2 as int)); + if !matches!(kind2, NodeKind::Elision) { + assert(hi2 < toks.len()); + assert(hi2 + 1 == pos); + assert(g.ts.toks[hi2 as int].kind == TokKind::Punctuator); + assert(g.ts.toks[hi2 as int].text =~= seq![0x2Cu32]); + assert(is_p(g.ts, hi2 as int, ","@)); + } + reveal_with_fuel(darray, 2); + assert(darray(a, g.ts, m as int, ks, k as int - 1, g.cx, lo2 as int, e as int)); + } + pos = lo2; + k = k.saturating_sub(1); + } + if pos != start { + return None; + } + proof { + assert(forall|q: int| + 0 <= q < len ==> array_item_ok(a, #[trigger] a.nodes[m as int].children[q])); + } + Some(e) +} + +/// §13.2.4 `ArrayLiteral : [ elements ]`. +#[verifier::spinoff_prover] +proof fn lemma_array_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= x, + x + 1 <= e < tn(ts), + a.nodes[m].kind == NodeKind::ArrayLiteral, + darray(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e), + forall|k: int| + 0 <= k < a.nodes[m].children.len() ==> array_item_ok(a, #[trigger] a.nodes[m].children[k]), + is_p(ts, x, "["@), + is_p(ts, e, "]"@), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[e].end, + ensures + node_done(a, ts, m, cx, x, e + 1), + lvl(a, m) == 17, +{ + assert(span_ok(a, ts, m, x, e + 1)); + assert(d_expr_lhs(a, ts, m, cx, x, e + 1)); + lemma_ed_of(a, ts, m, x, e + 1); +} + +/// §13.2.4 `ArrayLiteral`. +#[verifier::spinoff_prover] +fn check_array( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_brackets(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ArrayLiteral) { + return None; + } + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if !punct_at(src, nodes, toks, gaps, x, 0x5B, Ghost(GW { g, w: "["@ })) { + return None; + } + let als = ListSpec { m, start: x.saturating_add(1), mode: 0, trail: true }; + let e = match check_array_items(src, nodes, toks, gaps, done, &als, Ghost(g)) { + Some(e) => e, + None => { + return None; + }, + }; + if !punct_at(src, nodes, toks, gaps, e, 0x5D, Ghost(GW { g, w: "]"@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, e.saturating_add(1), Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(e.saturating_add(1) as int == e as int + 1); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_array_done(a, g.ts, g.cx, m as int, x as int, e as int); + } + Some((x, e.saturating_add(1), 17)) +} + +/// The brackets `[` and `]`, as code points. +proof fn lemma_brackets() + ensures + cps("["@) =~= seq![0x5Bu32], + cps("]"@) =~= seq![0x5Du32], +{ + reveal_strlit("["); + reveal_strlit("]"); + assert("["@ =~= seq!['[']); + assert("]"@ =~= seq![']']); +} + +/// §13.2.5 `ObjectLiteral : { PropertyDefinitionList ,? }`. +#[verifier::spinoff_prover] +proof fn lemma_object_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= x, + x + 1 <= e < tn(ts), + a.nodes[m].kind == NodeKind::ObjectLiteral, + dsep(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e, true), + forall|k: int| + 0 <= k < a.nodes[m].children.len() ==> list_item_ok(a, #[trigger] a.nodes[m].children[k], 5), + is_p(ts, x, "{"@), + is_p(ts, e, "}"@), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[e].end, + ensures + node_done(a, ts, m, cx, x, e + 1), + lvl(a, m) == 17, +{ + assert forall|k: int| 0 <= k < a.nodes[m].children.len() implies kd( + a, + #[trigger] a.nodes[m].children[k], + ) == NodeKind::PropertyDefinition || kd(a, a.nodes[m].children[k]) + == NodeKind::CoverInitializedName || kd(a, a.nodes[m].children[k]) + == NodeKind::MethodDefinition by { + assert(list_item_ok(a, a.nodes[m].children[k], 5)); + } + assert(span_ok(a, ts, m, x, e + 1)); + assert(d_expr_lhs(a, ts, m, cx, x, e + 1)); + lemma_ed_of(a, ts, m, x, e + 1); +} + +/// §13.2.5 `ObjectLiteral`. +#[verifier::spinoff_prover] +fn check_object( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_brace_text(); + lemma_words2(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ObjectLiteral) { + return None; + } + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if !punct_at(src, nodes, toks, gaps, x, 0x7B, Ghost(GW { g, w: "{"@ })) { + return None; + } + let ls = ListSpec { m, start: x.saturating_add(1), mode: 5, trail: true }; + let e = match check_list(src, nodes, toks, gaps, done, &ls, Ghost(g)) { + Some(e) => e, + None => { + return None; + }, + }; + if !punct_at(src, nodes, toks, gaps, e, 0x7D, Ghost(GW { g, w: "}"@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, e.saturating_add(1), Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(e.saturating_add(1) as int == e as int + 1); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_object_done(a, g.ts, g.cx, m as int, x as int, e as int); + } + Some((x, e.saturating_add(1), 17)) +} + +/// §13.2.5 `PropertyDefinition`: `name`, `key : value`, `... value`. +#[verifier::spinoff_prover] +#[verifier::rlimit(100)] +proof fn lemma_property_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + k0: int, + k1: int, + x: int, + mk: int, + j: int, +) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= k0 < m, + 0 <= k1 < m, + a.nodes[m].kind == NodeKind::PropertyDefinition, + if a.nodes[m].op == Op::Shorthand { + a.nodes[m].children =~= seq![k0] && kd(a, k0) == NodeKind::IdentifierReference + && node_done(a, ts, k0, cx, x, x + 1) && j == x + 1 + } else if a.nodes[m].op == Op::KeyValue { + a.nodes[m].children =~= seq![k0, k1] && is_prop_name_kind(kd(a, k0)) && is_assign_expr( + a, + k1, + ) && node_done(a, ts, k0, cx, x, mk) && is_p(ts, mk, ":"@) && node_done( + a, + ts, + k1, + cx, + mk + 1, + j, + ) + } else { + a.nodes[m].op == Op::Spread && a.nodes[m].children =~= seq![k0] && is_p(ts, x, "..."@) + && is_assign_expr(a, k0) && node_done(a, ts, k0, cx, x + 1, j) + }, + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == k0); + if a.nodes[m].op == Op::KeyValue { + assert(a.nodes[m].children[1] == k1); + assert(dc(a, ts, m, k0, cx, x, mk)); + assert(dc(a, ts, m, k1, cx_in(cx, true), mk + 1, j)); + } else if a.nodes[m].op == Op::Shorthand { + assert(dc(a, ts, m, k0, cx, x, x + 1)); + } else { + assert(dc(a, ts, m, k0, cx_in(cx, true), x + 1, j)); + } + assert(d_expr_lhs(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.2.5 `PropertyDefinition` (without methods and `name = init`). +#[verifier::spinoff_prover] +fn check_property( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::PropertyDefinition) { + return None; + } + let k0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let (lo0, h0, lv0) = match done_at(done, k0) { + Some(r) => r, + None => { + return None; + }, + }; + let kk0 = kind_at(nodes, k0); + let (j, k1, mk): (usize, usize, usize) = match nd.op { + Op::Shorthand => { + if nd.children.len() != 1 || !matches!(kk0, NodeKind::IdentifierReference) || lo0 != x { + return None; + } + (h0, k0, 0) + }, + Op::KeyValue => { + if nd.children.len() != 2 { + return None; + } + let v = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo1, h1, lv1) = match done_at(done, v) { + Some(r) => r, + None => { + return None; + }, + }; + if !matches!( + kk0, + NodeKind::IdentifierName | NodeKind::StringLiteral | NodeKind::NumericLiteral + | NodeKind::ComputedPropertyName + ) || lo0 != x || lv1 < 0 || !punct_at(src, nodes, toks, gaps, h0, 0x3A, Ghost(GW { g, w: ":"@ })) + || lo1 != h0.saturating_add(1) { + return None; + } + (h1, v, h0) + }, + Op::Spread => { + if nd.children.len() != 1 || lv0 < 0 || lo0 != x.saturating_add(1) + || !ellipsis_at(src, nodes, toks, gaps, x, Ghost(g)) { + return None; + } + (h0, k0, 0) + }, + _ => { + return None; + }, + }; + let _ = (k1, mk); + if !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].op == nd.op); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + assert(a.nodes[m as int].children.len() == nd.children.len()); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k0 as int, g.cx, 0); + assert(kd(a, k0 as int) == kk0); + if nd.op == Op::KeyValue { + assert(mk.saturating_add(0) == mk); + assert(h0.saturating_add(1) as int == h0 as int + 1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int, g.cx, 1); + assert(a.nodes[m as int].children =~= seq![k0 as int, k1 as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + } else { + assert(a.nodes[m as int].children =~= seq![k0 as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + } + lemma_property_done(a, g.ts, g.cx, m as int, k0 as int, k1 as int, x as int, mk as int, j as int); + } + Some((x, j, -100)) +} + +/// §13.2.5 `ComputedPropertyName : [ AssignmentExpression ]`. +#[verifier::spinoff_prover] +proof fn lemma_computed_done(a: AstV, ts: Stream, cx: Ctx, m: int, c: int, x: int, mc: int) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= c < m, + a.nodes[m].kind == NodeKind::ComputedPropertyName, + a.nodes[m].children =~= seq![c], + is_p(ts, x, "["@), + is_assign_expr(a, c), + node_done(a, ts, c, cx, x + 1, mc), + is_p(ts, mc, "]"@), + 0 <= x, + mc < tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[mc].end, + ensures + node_done(a, ts, m, cx, x, mc + 1), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, mc + 1)); + assert(a.nodes[m].children[0] == c); + assert(dc(a, ts, m, c, cx_in(cx, true), x + 1, mc)); + assert(d_expr_lhs(a, ts, m, cx, x, mc + 1)); + lemma_ed_of(a, ts, m, x, mc + 1); +} + +/// §13.2.5 `ComputedPropertyName`. +#[verifier::spinoff_prover] +fn check_computed( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_brackets(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ComputedPropertyName) || nd.children.len() != 1 { + return None; + } + let c = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let (lo_c, mc, lv_c) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + if !punct_at(src, nodes, toks, gaps, x, 0x5B, Ghost(GW { g, w: "["@ })) || lv_c < 0 + || lo_c != x.saturating_add(1) || !punct_at(src, nodes, toks, gaps, mc, 0x5D, Ghost(GW { g, w: "]"@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, mc.saturating_add(1), Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(mc.saturating_add(1) as int == mc as int + 1); + assert(a.nodes[m as int].children =~= seq![c as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 0); + assert(lvl(a, c as int) >= 0); + lemma_computed_done(a, g.ts, g.cx, m as int, c as int, x as int, mc as int); + } + Some((x, mc.saturating_add(1), -100)) +} + } // verus! diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index a1f6d28a..9f19f99d 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -82,6 +82,20 @@ var c;", "(async a => await a);", "(async (a) => 1);", "function f() { function g() { return 1 } return g }", + "[];", + "[1, 2, 3];", + "[1, 2,];", + "[,];", + "[, , 1, , 2, ,];", + "[...a, b, ...c];", + "[[1], [2, [3]]];", + "({});", + "({a});", + "({a: 1, b: 2,});", + "({'a': 1, 2: 3, [k]: 4, ...r});", + "({a, b: [1], c: {d: e}});", + "var o = {x: 1}, p = [o];", + "for (var k of [1, 2]) ;", "for (;;) ;", "for (;;) { break; }", "for (a = 0; a < 10; a = a + 1) b;", @@ -132,7 +146,7 @@ var c;", #[test] fn other_programs_are_unsupported_not_failed() { - for s in ["for (a, b;;) ;", "var [a] = 1;", "[1];", "({});"] { + for s in ["for (a, b;;) ;", "var [a] = 1;", "new a;", "a++;"] { assert!( derivation(s, SourceGoal::Script) == Some(Derivation::Unsupported), "{s}" @@ -154,7 +168,7 @@ fn errors_are_still_errors() { fn what_the_check_costs() { let body = "(1 + 2 * 3) < 4 - 5 / 6 % 7;\n".repeat(60_000); let covered = cps(&body); - let stopped = cps(&format!("[];\n{body}")); + let stopped = cps(&format!("new a;\n{body}")); let time = |src: &[u32]| { let t = Instant::now(); let r = parse_checked(src, SourceGoal::Script); From 7470074eafd4c71d2d99d5453d9c2bf4f3f377a8 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Thu, 19 Nov 2026 03:39:05 +0000 Subject: [PATCH 003/195] Check binding patterns against the tokens (7.3) ArrayBindingPattern and ObjectBindingPattern (darray, dsep), BindingProperty, BindingRestElement, BindingRestProperty; pattern targets for var/let/const bindings (an initializer is required), BindingElement, function ...rest and catch parameters. Assignment patterns are not covered yet. Verus: 294 verified. The verified share of Test262 is unchanged (829 of 1568): the files that use patterns also use other uncovered productions. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 585 +++++++++++++++++++- crates/clazel-js-syntax/tests/derivation.rs | 10 +- 2 files changed, 575 insertions(+), 20 deletions(-) diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index e69a1ee6..9eff835c 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -1584,6 +1584,8 @@ pub open spec fn item_ok_val(l: int, k: NodeKind, mode: int) -> bool { k == NodeKind::LexicalBinding } else if mode == 5 { k == NodeKind::PropertyDefinition + } else if mode == 7 { + k == NodeKind::BindingProperty || k == NodeKind::BindingRestProperty } else { k == NodeKind::BindingElement || k == NodeKind::FunctionRestParameter } @@ -1604,6 +1606,8 @@ fn item_ok_exec(l: i32, k: NodeKind, mode: u8) -> (r: bool) matches!(k, NodeKind::LexicalBinding) } else if mode == 5 { matches!(k, NodeKind::PropertyDefinition) + } else if mode == 7 { + matches!(k, NodeKind::BindingProperty | NodeKind::BindingRestProperty) } else { matches!(k, NodeKind::BindingElement | NodeKind::FunctionRestParameter) } @@ -1729,7 +1733,8 @@ fn check_list( } // The end: after a trailing `,` if one is allowed and there. let mut comma_after = false; - let tok_after = if ls.trail && !matches!(kc_kind, NodeKind::FunctionRestParameter) { + let tok_after = if ls.trail + && !matches!(kc_kind, NodeKind::FunctionRestParameter | NodeKind::BindingRestProperty) { toks.get(hc) } else { None @@ -2866,7 +2871,7 @@ proof fn lemma_binding_done( a.nodes[m].kind == NodeKind::VariableDeclaration || a.nodes[m].kind == NodeKind::LexicalBinding || (a.nodes[m].kind == NodeKind::BindingElement && cx_in(cx, true) == cx), a.nodes[m].children =~= seq![t, init], - kd(a, t) == NodeKind::BindingIdentifier, + is_binding_target_kind(kd(a, t)), node_done(a, ts, t, cx, lo_t, mt), a.nodes[m].start == ts.toks[lo_t].start, a.nodes[m].end == ts.toks[j - 1].end, @@ -2883,7 +2888,7 @@ proof fn lemma_binding_done( j, ) } else { - kd(a, init) == NodeKind::Absent && j == mt && d(a, ts, init, cx, mt, mt) && ed( + kd(a, init) == NodeKind::Absent && (a.nodes[m].kind == NodeKind::BindingElement || !is_binding_pattern_kind(kd(a, t))) && j == mt && d(a, ts, init, cx, mt, mt) && ed( a, ts, init, @@ -2906,6 +2911,7 @@ proof fn lemma_binding_done( assert(is_assign_expr(a, init)); assert(dc(a, ts, m, init, cx, lo_i, j)); assert(d_init(a, ts, m, init, cx, mt, j, false)); + assert(d_init(a, ts, m, init, cx, mt, j, true)); } else { assert(dc(a, ts, m, init, cx, mt, mt)); assert(d_init(a, ts, m, init, cx, mt, j, false)); @@ -2993,7 +2999,10 @@ fn check_binding( }, }; let target_ok = match nodes.get(t) { - Some(x) => matches!(x.kind, NodeKind::BindingIdentifier), + Some(x) => matches!( + x.kind, + NodeKind::BindingIdentifier | NodeKind::ObjectBindingPattern | NodeKind::ArrayBindingPattern + ), None => false, }; if !target_ok { @@ -3010,7 +3019,12 @@ fn check_binding( }, }; if init_absent { - if !check_absent(src, nodes, toks, gaps, init, mt, Ghost(g)) { + let pat = !matches!(nd.kind, NodeKind::BindingElement) + && match nodes.get(t) { + Some(x) => !matches!(x.kind, NodeKind::BindingIdentifier), + None => true, + }; + if pat || !check_absent(src, nodes, toks, gaps, init, mt, Ghost(g)) { return None; } let prev = match toks.get(mt.saturating_sub(1)) { @@ -6218,6 +6232,15 @@ pub fn check_derivation( NodeKind::DefaultClause => check_default(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ReturnStatement => check_return(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::FormalParameters => check_params(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ArrayBindingPattern | NodeKind::ObjectBindingPattern => { + let sh = PatShape { m, array: matches!(nd.kind, NodeKind::ArrayBindingPattern) }; + proof { + assert(nd == &nodes@[m as int]); + } + check_pattern(src, nodes, toks, gaps, &done, &sh, Ghost(GCx { ts, cx })) + }, + NodeKind::BindingProperty => check_binding_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::BindingRestElement | NodeKind::BindingRestProperty => check_binding_rest(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ArrayLiteral => check_array(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ObjectLiteral => check_object(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::PropertyDefinition => check_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), @@ -8027,7 +8050,7 @@ proof fn lemma_catch_done( is_kw(ts, x, "catch"@), kd(a, blk) == NodeKind::BlockStatement, if has_param { - kd(a, p) == NodeKind::BindingIdentifier && is_p(ts, x + 1, "("@) && node_done( + is_binding_target_kind(kd(a, p)) && is_p(ts, x + 1, "("@) && node_done( a, ts, p, @@ -8141,7 +8164,7 @@ fn check_catch( } let x1 = x.saturating_add(1); let kp = kind_at(nodes, p); - let has_param = matches!(kp, NodeKind::BindingIdentifier); + let has_param = matches!(kp, NodeKind::BindingIdentifier | NodeKind::ObjectBindingPattern | NodeKind::ArrayBindingPattern); let mp: usize = if has_param { let (lo_p, hi_p, _) = match done_at(done, p) { Some(r) => r, @@ -10549,7 +10572,7 @@ proof fn lemma_rest_param_done(a: AstV, ts: Stream, cx: Ctx, m: int, c: int, x: a.nodes[m].kind == NodeKind::FunctionRestParameter, a.nodes[m].children =~= seq![c], is_p(ts, x, "..."@), - kd(a, c) == NodeKind::BindingIdentifier, + is_binding_target_kind(kd(a, c)), node_done(a, ts, c, cx, x + 1, j), x < j <= tn(ts), a.nodes[m].start == ts.toks[x].start, @@ -10663,7 +10686,7 @@ fn check_rest_param( }, }; if !ellipsis_at(src, nodes, toks, gaps, x, Ghost(g)) - || !matches!(kind_at(nodes, c), NodeKind::BindingIdentifier) + || !matches!(kind_at(nodes, c), NodeKind::BindingIdentifier | NodeKind::ObjectBindingPattern | NodeKind::ArrayBindingPattern) || lo_c != x.saturating_add(1) || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { return None; @@ -11623,12 +11646,31 @@ pub open spec fn array_item_ok(a: AstV, c: int) -> bool { lvl(a, c) >= 0 || kd(a, c) == NodeKind::SpreadElement || kd(a, c) == NodeKind::Elision } -/// `array_item_ok`, executable. -fn array_item_exec(l: i32, k: NodeKind) -> (r: bool) +/// What an array literal (mode 0) or an array binding pattern (mode 6) accepts as an element. +pub open spec fn array_item_mode_ok(a: AstV, c: int, mode: int) -> bool { + if mode == 6 { + kd(a, c) == NodeKind::BindingElement || kd(a, c) == NodeKind::Elision || kd(a, c) + == NodeKind::BindingRestElement + } else { + array_item_ok(a, c) + } +} + +/// `array_item_mode_ok`, executable. +fn array_item_exec(l: i32, k: NodeKind, mode: u8) -> (r: bool) ensures - r ==> (l as int >= 0 || k == NodeKind::SpreadElement || k == NodeKind::Elision), + r ==> (if mode == 6 { + k == NodeKind::BindingElement || k == NodeKind::Elision || k + == NodeKind::BindingRestElement + } else { + l as int >= 0 || k == NodeKind::SpreadElement || k == NodeKind::Elision + }), { - l >= 0 || matches!(k, NodeKind::SpreadElement | NodeKind::Elision) + if mode == 6 { + matches!(k, NodeKind::BindingElement | NodeKind::Elision | NodeKind::BindingRestElement) + } else { + l >= 0 || matches!(k, NodeKind::SpreadElement | NodeKind::Elision) + } } /// §13.2.4 `Elision : ,` (a hole): a `,`. @@ -11743,9 +11785,10 @@ fn check_array_items( ls.start as int, e as int, ) && forall|k: int| - 0 <= k < arena_of(nodes@).nodes[ls.m as int].children.len() ==> array_item_ok( + 0 <= k < arena_of(nodes@).nodes[ls.m as int].children.len() ==> array_item_mode_ok( arena_of(nodes@), #[trigger] arena_of(nodes@).nodes[ls.m as int].children[k], + ls.mode as int, ), None => true, }, @@ -11797,7 +11840,7 @@ fn check_array_items( }, }; let kc_kind = kind_at(nodes, c); - if !array_item_exec(lvl_c, kc_kind) { + if !array_item_exec(lvl_c, kc_kind, ls.mode) { return None; } let is_hole = matches!(kc_kind, NodeKind::Elision); @@ -11807,7 +11850,8 @@ fn check_array_items( lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, hc as int); assert(t == &toks@[hc as int]); } - if !is_hole && matches!(t.kind, TokKind::Punctuator) && text_is1(src, t, 0x2C) { + if !is_hole && !matches!(kc_kind, NodeKind::BindingRestElement) + && matches!(t.kind, TokKind::Punctuator) && text_is1(src, t, 0x2C) { comma_after = true; } } @@ -11855,7 +11899,7 @@ fn check_array_items( cx_ok(a, done.cxs@, m as int, g.cx), darray(a, g.ts, m as int, a.nodes[m as int].children, k as int, g.cx, pos as int, e as int), forall|q: int| - k <= q < len ==> array_item_ok(a, #[trigger] a.nodes[m as int].children[q]), + k <= q < len ==> array_item_mode_ok(a, #[trigger] a.nodes[m as int].children[q], ls.mode as int), decreases k, { let c2 = match nd.children.as_slice().get(k.saturating_sub(1)) { @@ -11880,7 +11924,7 @@ fn check_array_items( }, }; let kind2 = kind_at(nodes, c2); - if !array_item_exec(lvl2, kind2) { + if !array_item_exec(lvl2, kind2, ls.mode) { return None; } if matches!(kind2, NodeKind::Elision) { @@ -11930,7 +11974,7 @@ fn check_array_items( } proof { assert(forall|q: int| - 0 <= q < len ==> array_item_ok(a, #[trigger] a.nodes[m as int].children[q])); + 0 <= q < len ==> array_item_mode_ok(a, #[trigger] a.nodes[m as int].children[q], ls.mode as int)); } Some(e) } @@ -12033,6 +12077,8 @@ fn check_array( assert(a.nodes[m as int].kind == nd.kind); assert(a.nodes[m as int].start == nd.start as int); assert(a.nodes[m as int].end == nd.end as int); + assert(forall|k: int| + 0 <= k < a.nodes[m as int].children.len() ==> array_item_ok(a, #[trigger] a.nodes[m as int].children[k])); lemma_array_done(a, g.ts, g.cx, m as int, x as int, e as int); } Some((x, e.saturating_add(1), 17)) @@ -12477,4 +12523,505 @@ fn check_computed( Some((x, mc.saturating_add(1), -100)) } +// --------------------------------------------------------------------- +// Binding patterns (§14.3.3): array and object patterns, their elements and +// properties, and `...rest` of a name or a pattern. +// --------------------------------------------------------------------- + +/// §14.3.3 `BindingRestElement : ... target`, `BindingRestProperty : ... BindingIdentifier`. +#[verifier::spinoff_prover] +proof fn lemma_binding_rest_done(a: AstV, ts: Stream, cx: Ctx, m: int, c: int, x: int, j: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c < m, + a.nodes[m].kind == NodeKind::BindingRestElement || a.nodes[m].kind + == NodeKind::BindingRestProperty, + a.nodes[m].children =~= seq![c], + is_p(ts, x, "..."@), + a.nodes[m].kind == NodeKind::BindingRestElement ==> is_binding_target_kind(kd(a, c)), + a.nodes[m].kind == NodeKind::BindingRestProperty ==> kd(a, c) == NodeKind::BindingIdentifier, + node_done(a, ts, c, cx, x + 1, j), + x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c); + assert(dc(a, ts, m, c, cx, x + 1, j)); + assert(d_pat(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §14.3.3 `BindingRestElement`, `BindingRestProperty`. +#[verifier::spinoff_prover] +fn check_binding_rest( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::BindingRestElement | NodeKind::BindingRestProperty) + || nd.children.len() != 1 { + return None; + } + let c = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let (lo_c, j, _) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + let kc = kind_at(nodes, c); + let kind_ok = match nd.kind { + NodeKind::BindingRestElement => matches!( + kc, + NodeKind::BindingIdentifier | NodeKind::ObjectBindingPattern | NodeKind::ArrayBindingPattern + ), + _ => matches!(kc, NodeKind::BindingIdentifier), + }; + if !ellipsis_at(src, nodes, toks, gaps, x, Ghost(g)) || !kind_ok || lo_c != x.saturating_add(1) + || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(a.nodes[m as int].children =~= seq![c as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 0); + assert(kd(a, c as int) == kc); + lemma_binding_rest_done(a, g.ts, g.cx, m as int, c as int, x as int, j as int); + } + Some((x, j, -100)) +} + +/// §14.3.3 `BindingProperty : SingleNameBinding | PropertyName : BindingElement`. +#[verifier::spinoff_prover] +proof fn lemma_binding_property_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + k0: int, + k1: int, + x: int, + mk: int, + j: int, +) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= k0 < m, + 0 <= k1 < m, + a.nodes[m].kind == NodeKind::BindingProperty, + if a.nodes[m].op == Op::Shorthand { + a.nodes[m].children =~= seq![k0] && kd(a, k0) == NodeKind::BindingElement + && first_kid_kind(a, k0) == NodeKind::BindingIdentifier && node_done( + a, + ts, + k0, + cx, + x, + j, + ) + } else { + a.nodes[m].op == Op::KeyValue && a.nodes[m].children =~= seq![k0, k1] + && is_prop_name_kind(kd(a, k0)) && kd(a, k1) == NodeKind::BindingElement && node_done( + a, + ts, + k0, + cx, + x, + mk, + ) && is_p(ts, mk, ":"@) && node_done(a, ts, k1, cx, mk + 1, j) + }, + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == k0); + if a.nodes[m].op == Op::KeyValue { + assert(a.nodes[m].children[1] == k1); + assert(dc(a, ts, m, k0, cx, x, mk)); + assert(dc(a, ts, m, k1, cx, mk + 1, j)); + } else { + assert(dc(a, ts, m, k0, cx, x, j)); + } + assert(d_pat(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §14.3.3 `BindingProperty`. +#[verifier::spinoff_prover] +fn check_binding_property( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::BindingProperty) { + return None; + } + let k0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let (lo0, h0, _) = match done_at(done, k0) { + Some(r) => r, + None => { + return None; + }, + }; + let kk0 = kind_at(nodes, k0); + let (j, k1, mk): (usize, usize, usize) = match nd.op { + Op::Shorthand => { + // The element's target is a name. + let first = match kid_of(nodes, k0, 0) { + Some(c) => matches!(kind_at(nodes, c), NodeKind::BindingIdentifier), + None => false, + }; + if nd.children.len() != 1 || !matches!(kk0, NodeKind::BindingElement) || !first + || lo0 != x { + return None; + } + (h0, k0, 0) + }, + Op::KeyValue => { + if nd.children.len() != 2 { + return None; + } + let v = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo1, h1, _) = match done_at(done, v) { + Some(r) => r, + None => { + return None; + }, + }; + if !matches!( + kk0, + NodeKind::IdentifierName | NodeKind::StringLiteral | NodeKind::NumericLiteral + | NodeKind::ComputedPropertyName + ) || !matches!(kind_at(nodes, v), NodeKind::BindingElement) || lo0 != x + || !punct_at(src, nodes, toks, gaps, h0, 0x3A, Ghost(GW { g, w: ":"@ })) + || lo1 != h0.saturating_add(1) { + return None; + } + (h1, v, h0) + }, + _ => { + return None; + }, + }; + let _ = (k1, mk); + if !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(a.nodes[k0 as int] == nodes@[k0 as int]@); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].op == nd.op); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k0 as int, g.cx, 0); + assert(kd(a, k0 as int) == kk0); + if nd.op == Op::KeyValue { + assert(h0.saturating_add(1) as int == h0 as int + 1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int, g.cx, 1); + assert(a.nodes[m as int].children =~= seq![k0 as int, k1 as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + } else { + assert(a.nodes[m as int].children =~= seq![k0 as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + } + lemma_binding_property_done(a, g.ts, g.cx, m as int, k0 as int, k1 as int, x as int, mk as int, j as int); + } + Some((x, j, -100)) +} + +/// §14.3.3 `ArrayBindingPattern : [ elements ]`. +#[verifier::spinoff_prover] +proof fn lemma_array_pattern_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= x, + x + 1 <= e < tn(ts), + a.nodes[m].kind == NodeKind::ArrayBindingPattern, + darray(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e), + forall|k: int| + 0 <= k < a.nodes[m].children.len() ==> array_item_mode_ok( + a, + #[trigger] a.nodes[m].children[k], + 6, + ), + rest_only_last(a, a.nodes[m].children), + is_p(ts, x, "["@), + is_p(ts, e, "]"@), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[e].end, + ensures + node_done(a, ts, m, cx, x, e + 1), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, e + 1)); + assert forall|k: int| 0 <= k < a.nodes[m].children.len() implies kd( + a, + #[trigger] a.nodes[m].children[k], + ) == NodeKind::BindingElement || kd(a, a.nodes[m].children[k]) == NodeKind::Elision || kd( + a, + a.nodes[m].children[k], + ) == NodeKind::BindingRestElement by { + assert(array_item_mode_ok(a, a.nodes[m].children[k], 6)); + } + assert(d_pat(a, ts, m, cx, x, e + 1)); + lemma_ed_of(a, ts, m, x, e + 1); +} + +/// §14.3.3 `ObjectBindingPattern : { BindingPropertyList ,? }`. +#[verifier::spinoff_prover] +proof fn lemma_object_pattern_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= x, + x + 1 <= e < tn(ts), + a.nodes[m].kind == NodeKind::ObjectBindingPattern, + dsep(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e, true), + forall|k: int| + 0 <= k < a.nodes[m].children.len() ==> list_item_ok(a, #[trigger] a.nodes[m].children[k], 7), + rest_only_last(a, a.nodes[m].children), + is_p(ts, x, "{"@), + is_p(ts, e, "}"@), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[e].end, + ensures + node_done(a, ts, m, cx, x, e + 1), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, e + 1)); + assert(all_kind2(a, a.nodes[m].children, 0, NodeKind::BindingProperty, NodeKind::BindingRestProperty)) by { + assert forall|k: int| 0 <= k < a.nodes[m].children.len() implies kd( + a, + #[trigger] a.nodes[m].children[k], + ) == NodeKind::BindingProperty || kd(a, a.nodes[m].children[k]) + == NodeKind::BindingRestProperty by { + assert(list_item_ok(a, a.nodes[m].children[k], 7)); + } + } + assert(d_pat(a, ts, m, cx, x, e + 1)); + lemma_ed_of(a, ts, m, x, e + 1); +} + +/// What `check_pattern` reads: the node and whether it is an array pattern. +pub struct PatShape { + /// The node. + pub m: usize, + /// An `ArrayBindingPattern` (else an `ObjectBindingPattern`). + pub array: bool, +} + +/// §14.3.3 `ArrayBindingPattern`, `ObjectBindingPattern`. +#[verifier::spinoff_prover] +fn check_pattern( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + sh: &PatShape, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + sh.m < nodes.len(), + nodes@[sh.m as int].kind == (if sh.array { + NodeKind::ArrayBindingPattern + } else { + NodeKind::ObjectBindingPattern + }), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, sh.m as int), + cx_ok(arena_of(nodes@), done.cxs@, sh.m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + sh.m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), sh.m as int), + None => true, + }, +{ + let m = sh.m; + proof { + lemma_brackets(); + lemma_brace_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let x1 = x.saturating_add(1); + let (e, close_ok): (usize, bool) = if sh.array { + if !punct_at(src, nodes, toks, gaps, x, 0x5B, Ghost(GW { g, w: "["@ })) { + return None; + } + let als = ListSpec { m, start: x1, mode: 6, trail: true }; + let e = match check_array_items(src, nodes, toks, gaps, done, &als, Ghost(g)) { + Some(e) => e, + None => { + return None; + }, + }; + (e, punct_at(src, nodes, toks, gaps, e, 0x5D, Ghost(GW { g, w: "]"@ }))) + } else { + if !punct_at(src, nodes, toks, gaps, x, 0x7B, Ghost(GW { g, w: "{"@ })) { + return None; + } + let ls = ListSpec { m, start: x1, mode: 7, trail: true }; + let e = match check_list(src, nodes, toks, gaps, done, &ls, Ghost(g)) { + Some(e) => e, + None => { + return None; + }, + }; + (e, punct_at(src, nodes, toks, gaps, e, 0x7D, Ghost(GW { g, w: "}"@ }))) + }; + if !close_ok || !end_ok(src, nodes, toks, gaps, nd.end, e.saturating_add(1), Ghost(g)) + || !check_rest_last(nodes, m) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x1 as int == x as int + 1); + assert(e.saturating_add(1) as int == e as int + 1); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + if sh.array { + lemma_array_pattern_done(a, g.ts, g.cx, m as int, x as int, e as int); + } else { + lemma_object_pattern_done(a, g.ts, g.cx, m as int, x as int, e as int); + } + } + Some((x, e.saturating_add(1), -100)) +} + } // verus! diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index 9f19f99d..b61eb741 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -82,6 +82,14 @@ var c;", "(async a => await a);", "(async (a) => 1);", "function f() { function g() { return 1 } return g }", + "var [a] = 1;", + "var [a, , b = 2, ...c] = d;", + "var {a, b: c, d = 3, ...e} = f;", + "let {a: {b}, c: [d, e]} = g;", + "const [x, [y, z], {w}] = h;", + "function f({a, b}, [c], d = 1, ...[e, f]) {}", + "function g(...{length}) {}", + "try { a } catch ({message}) { b }", "[];", "[1, 2, 3];", "[1, 2,];", @@ -146,7 +154,7 @@ var c;", #[test] fn other_programs_are_unsupported_not_failed() { - for s in ["for (a, b;;) ;", "var [a] = 1;", "new a;", "a++;"] { + for s in ["for (a, b;;) ;", "new a;", "a++;", "class A {}"] { assert!( derivation(s, SourceGoal::Script) == Some(Derivation::Unsupported), "{s}" From 969b95b95f4cfc0039b2f19c5f1cfe846d505567 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Thu, 19 Nov 2026 03:49:31 +0000 Subject: [PATCH 004/195] Check assignment patterns against the tokens (7.3) ObjectAssignmentPattern and ArrayAssignmentPattern with AssignmentProperty (shorthand with initializer, key: element), AssignmentElement and AssignmentRestElement/Property; an assignment with = takes a pattern as its target. Verus: 298 verified. Verified share 829 of 1568 (unchanged). Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 422 ++++++++++++++++++-- crates/clazel-js-syntax/tests/derivation.rs | 5 + 2 files changed, 396 insertions(+), 31 deletions(-) diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index 9eff835c..57407d74 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -1586,6 +1586,8 @@ pub open spec fn item_ok_val(l: int, k: NodeKind, mode: int) -> bool { k == NodeKind::PropertyDefinition } else if mode == 7 { k == NodeKind::BindingProperty || k == NodeKind::BindingRestProperty + } else if mode == 9 { + k == NodeKind::AssignmentProperty || k == NodeKind::AssignmentRestProperty } else { k == NodeKind::BindingElement || k == NodeKind::FunctionRestParameter } @@ -1608,6 +1610,8 @@ fn item_ok_exec(l: i32, k: NodeKind, mode: u8) -> (r: bool) matches!(k, NodeKind::PropertyDefinition) } else if mode == 7 { matches!(k, NodeKind::BindingProperty | NodeKind::BindingRestProperty) + } else if mode == 9 { + matches!(k, NodeKind::AssignmentProperty | NodeKind::AssignmentRestProperty) } else { matches!(k, NodeKind::BindingElement | NodeKind::FunctionRestParameter) } @@ -1734,7 +1738,10 @@ fn check_list( // The end: after a trailing `,` if one is allowed and there. let mut comma_after = false; let tok_after = if ls.trail - && !matches!(kc_kind, NodeKind::FunctionRestParameter | NodeKind::BindingRestProperty) { + && !matches!( + kc_kind, + NodeKind::FunctionRestParameter | NodeKind::BindingRestProperty | NodeKind::AssignmentRestProperty + ) { toks.get(hc) } else { None @@ -2850,6 +2857,7 @@ proof fn lemma_list_next( /// A `VariableDeclaration` or `LexicalBinding` of the check: a binding identifier and /// an optional initializer. #[verifier::spinoff_prover] +#[verifier::rlimit(150)] proof fn lemma_binding_done( a: AstV, ts: Stream, @@ -2869,9 +2877,9 @@ proof fn lemma_binding_done( 0 <= t < m, 0 <= init < m, a.nodes[m].kind == NodeKind::VariableDeclaration || a.nodes[m].kind - == NodeKind::LexicalBinding || (a.nodes[m].kind == NodeKind::BindingElement && cx_in(cx, true) == cx), + == NodeKind::LexicalBinding || ((a.nodes[m].kind == NodeKind::BindingElement || a.nodes[m].kind == NodeKind::AssignmentElement) && cx_in(cx, true) == cx), a.nodes[m].children =~= seq![t, init], - is_binding_target_kind(kd(a, t)), + if a.nodes[m].kind == NodeKind::AssignmentElement { is_destructuring_target(a, t) } else { is_binding_target_kind(kd(a, t)) }, node_done(a, ts, t, cx, lo_t, mt), a.nodes[m].start == ts.toks[lo_t].start, a.nodes[m].end == ts.toks[j - 1].end, @@ -2888,7 +2896,7 @@ proof fn lemma_binding_done( j, ) } else { - kd(a, init) == NodeKind::Absent && (a.nodes[m].kind == NodeKind::BindingElement || !is_binding_pattern_kind(kd(a, t))) && j == mt && d(a, ts, init, cx, mt, mt) && ed( + kd(a, init) == NodeKind::Absent && (a.nodes[m].kind == NodeKind::BindingElement || a.nodes[m].kind == NodeKind::AssignmentElement || !is_binding_pattern_kind(kd(a, t))) && j == mt && d(a, ts, init, cx, mt, mt) && ed( a, ts, init, @@ -2916,7 +2924,7 @@ proof fn lemma_binding_done( assert(dc(a, ts, m, init, cx, mt, mt)); assert(d_init(a, ts, m, init, cx, mt, j, false)); } - if a.nodes[m].kind == NodeKind::BindingElement { + if a.nodes[m].kind == NodeKind::BindingElement || a.nodes[m].kind == NodeKind::AssignmentElement { assert(d_pat(a, ts, m, cx, lo_t, j)); } else { assert(d_stmt(a, ts, m, cx, lo_t, j)); @@ -2937,7 +2945,7 @@ fn check_binding( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - nodes@[m as int].kind == NodeKind::BindingElement ==> cx_in(g.cx, true) == g.cx, + (nodes@[m as int].kind == NodeKind::BindingElement || nodes@[m as int].kind == NodeKind::AssignmentElement) ==> cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), @@ -2960,7 +2968,7 @@ fn check_binding( return None; }, }; - if !matches!(nd.kind, NodeKind::VariableDeclaration | NodeKind::LexicalBinding | NodeKind::BindingElement) + if !matches!(nd.kind, NodeKind::VariableDeclaration | NodeKind::LexicalBinding | NodeKind::BindingElement | NodeKind::AssignmentElement) || nd.children.len() != 2 { return None; } @@ -2998,11 +3006,22 @@ fn check_binding( return None; }, }; + let lv_t = match done.lv.get(t) { + Some(x) => *x, + None => { + return None; + }, + }; let target_ok = match nodes.get(t) { - Some(x) => matches!( - x.kind, - NodeKind::BindingIdentifier | NodeKind::ObjectBindingPattern | NodeKind::ArrayBindingPattern - ), + Some(x) => if matches!(nd.kind, NodeKind::AssignmentElement) { + matches!(x.kind, NodeKind::ObjectAssignmentPattern | NodeKind::ArrayAssignmentPattern) + || (lv_t >= 14 && !matches!(x.kind, NodeKind::ObjectLiteral | NodeKind::ArrayLiteral)) + } else { + matches!( + x.kind, + NodeKind::BindingIdentifier | NodeKind::ObjectBindingPattern | NodeKind::ArrayBindingPattern + ) + }, None => false, }; if !target_ok { @@ -3019,7 +3038,7 @@ fn check_binding( }, }; if init_absent { - let pat = !matches!(nd.kind, NodeKind::BindingElement) + let pat = !matches!(nd.kind, NodeKind::BindingElement | NodeKind::AssignmentElement) && match nodes.get(t) { Some(x) => !matches!(x.kind, NodeKind::BindingIdentifier), None => true, @@ -4508,9 +4527,11 @@ proof fn lemma_assign_done( a.nodes[m].kind == NodeKind::AssignmentExpression, a.nodes[m].children =~= seq![l, r], is_assign_op(a.nodes[m].op), - lvl(a, l) >= 14, - kd(a, l) != NodeKind::ObjectLiteral, - kd(a, l) != NodeKind::ArrayLiteral, + if a.nodes[m].op == Op::Assign { + is_destructuring_target(a, l) + } else { + is_lhs_expr(a, l) + }, lvl(a, r) >= 0, node_done(a, ts, l, cx, lo_l, mi), node_done(a, ts, r, cx, lo_r, j), @@ -4524,8 +4545,6 @@ proof fn lemma_assign_done( lvl(a, m) == 0, { assert(span_ok(a, ts, m, lo_l, j)); - assert(is_lhs_expr(a, l)); - assert(is_destructuring_target(a, l)); crate::derive::lemma_assignment_derives(a, ts, m, cx, lo_l, mi, j, l, r); lemma_ed_of(a, ts, m, lo_l, j); } @@ -4649,7 +4668,13 @@ fn check_assign( Some(x) => !matches!(x.kind, NodeKind::ObjectLiteral | NodeKind::ArrayLiteral), None => false, }; - if lvl_l < 14 || !left_plain || lvl_r < 0 || lo_r != mi.saturating_add(1) { + let left_pattern = matches!(nd.op, Op::Assign) + && matches!( + kind_at(nodes, l), + NodeKind::ObjectAssignmentPattern | NodeKind::ArrayAssignmentPattern + ); + if !((lvl_l >= 14 && left_plain) || left_pattern) || lvl_r < 0 + || lo_r != mi.saturating_add(1) { return None; } let opt = match toks.get(mi) { @@ -6232,8 +6257,16 @@ pub fn check_derivation( NodeKind::DefaultClause => check_default(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ReturnStatement => check_return(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::FormalParameters => check_params(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), - NodeKind::ArrayBindingPattern | NodeKind::ObjectBindingPattern => { - let sh = PatShape { m, array: matches!(nd.kind, NodeKind::ArrayBindingPattern) }; + NodeKind::AssignmentElement => check_binding(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::AssignmentProperty => check_assignment_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::AssignmentRestElement | NodeKind::AssignmentRestProperty => check_binding_rest(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ArrayBindingPattern | NodeKind::ObjectBindingPattern | NodeKind::ArrayAssignmentPattern + | NodeKind::ObjectAssignmentPattern => { + let sh = PatShape { + m, + array: matches!(nd.kind, NodeKind::ArrayBindingPattern | NodeKind::ArrayAssignmentPattern), + assign: matches!(nd.kind, NodeKind::ArrayAssignmentPattern | NodeKind::ObjectAssignmentPattern), + }; proof { assert(nd == &nodes@[m as int]); } @@ -11651,6 +11684,9 @@ pub open spec fn array_item_mode_ok(a: AstV, c: int, mode: int) -> bool { if mode == 6 { kd(a, c) == NodeKind::BindingElement || kd(a, c) == NodeKind::Elision || kd(a, c) == NodeKind::BindingRestElement + } else if mode == 8 { + kd(a, c) == NodeKind::AssignmentElement || kd(a, c) == NodeKind::Elision || kd(a, c) + == NodeKind::AssignmentRestElement } else { array_item_ok(a, c) } @@ -11662,12 +11698,17 @@ fn array_item_exec(l: i32, k: NodeKind, mode: u8) -> (r: bool) r ==> (if mode == 6 { k == NodeKind::BindingElement || k == NodeKind::Elision || k == NodeKind::BindingRestElement + } else if mode == 8 { + k == NodeKind::AssignmentElement || k == NodeKind::Elision || k + == NodeKind::AssignmentRestElement } else { l as int >= 0 || k == NodeKind::SpreadElement || k == NodeKind::Elision }), { if mode == 6 { matches!(k, NodeKind::BindingElement | NodeKind::Elision | NodeKind::BindingRestElement) + } else if mode == 8 { + matches!(k, NodeKind::AssignmentElement | NodeKind::Elision | NodeKind::AssignmentRestElement) } else { l >= 0 || matches!(k, NodeKind::SpreadElement | NodeKind::Elision) } @@ -11850,7 +11891,8 @@ fn check_array_items( lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, hc as int); assert(t == &toks@[hc as int]); } - if !is_hole && !matches!(kc_kind, NodeKind::BindingRestElement) + if !is_hole + && !matches!(kc_kind, NodeKind::BindingRestElement | NodeKind::AssignmentRestElement) && matches!(t.kind, TokKind::Punctuator) && text_is1(src, t, 0x2C) { comma_after = true; } @@ -12536,9 +12578,12 @@ proof fn lemma_binding_rest_done(a: AstV, ts: Stream, cx: Ctx, m: int, c: int, x 0 <= m < a.nodes.len(), 0 <= c < m, a.nodes[m].kind == NodeKind::BindingRestElement || a.nodes[m].kind - == NodeKind::BindingRestProperty, + == NodeKind::BindingRestProperty || a.nodes[m].kind == NodeKind::AssignmentRestElement + || a.nodes[m].kind == NodeKind::AssignmentRestProperty, a.nodes[m].children =~= seq![c], is_p(ts, x, "..."@), + (a.nodes[m].kind == NodeKind::AssignmentRestElement || a.nodes[m].kind + == NodeKind::AssignmentRestProperty) ==> is_destructuring_target(a, c), a.nodes[m].kind == NodeKind::BindingRestElement ==> is_binding_target_kind(kd(a, c)), a.nodes[m].kind == NodeKind::BindingRestProperty ==> kd(a, c) == NodeKind::BindingIdentifier, node_done(a, ts, c, cx, x + 1, j), @@ -12594,8 +12639,11 @@ fn check_binding_rest( return None; }, }; - if !matches!(nd.kind, NodeKind::BindingRestElement | NodeKind::BindingRestProperty) - || nd.children.len() != 1 { + if !matches!( + nd.kind, + NodeKind::BindingRestElement | NodeKind::BindingRestProperty | NodeKind::AssignmentRestElement + | NodeKind::AssignmentRestProperty + ) || nd.children.len() != 1 { return None; } let c = match kid_of(nodes, m, 0) { @@ -12610,7 +12658,7 @@ fn check_binding_rest( return None; }, }; - let (lo_c, j, _) = match done_at(done, c) { + let (lo_c, j, lv_c) = match done_at(done, c) { Some(r) => r, None => { return None; @@ -12622,7 +12670,9 @@ fn check_binding_rest( kc, NodeKind::BindingIdentifier | NodeKind::ObjectBindingPattern | NodeKind::ArrayBindingPattern ), - _ => matches!(kc, NodeKind::BindingIdentifier), + NodeKind::BindingRestProperty => matches!(kc, NodeKind::BindingIdentifier), + _ => matches!(kc, NodeKind::ObjectAssignmentPattern | NodeKind::ArrayAssignmentPattern) + || (lv_c >= 14 && !matches!(kc, NodeKind::ObjectLiteral | NodeKind::ArrayLiteral)), }; if !ellipsis_at(src, nodes, toks, gaps, x, Ghost(g)) || !kind_ok || lo_c != x.saturating_add(1) || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { @@ -12920,8 +12970,10 @@ proof fn lemma_object_pattern_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, pub struct PatShape { /// The node. pub m: usize, - /// An `ArrayBindingPattern` (else an `ObjectBindingPattern`). + /// An array pattern (else an object pattern). pub array: bool, + /// An assignment pattern (else a binding pattern). + pub assign: bool, } /// §14.3.3 `ArrayBindingPattern`, `ObjectBindingPattern`. @@ -12937,7 +12989,13 @@ fn check_pattern( ) -> (r: Option<(usize, usize, i32)>) requires sh.m < nodes.len(), - nodes@[sh.m as int].kind == (if sh.array { + nodes@[sh.m as int].kind == (if sh.assign { + if sh.array { + NodeKind::ArrayAssignmentPattern + } else { + NodeKind::ObjectAssignmentPattern + } + } else if sh.array { NodeKind::ArrayBindingPattern } else { NodeKind::ObjectBindingPattern @@ -12981,7 +13039,7 @@ fn check_pattern( if !punct_at(src, nodes, toks, gaps, x, 0x5B, Ghost(GW { g, w: "["@ })) { return None; } - let als = ListSpec { m, start: x1, mode: 6, trail: true }; + let als = ListSpec { m, start: x1, mode: if sh.assign { 8 } else { 6 }, trail: true }; let e = match check_array_items(src, nodes, toks, gaps, done, &als, Ghost(g)) { Some(e) => e, None => { @@ -12993,7 +13051,7 @@ fn check_pattern( if !punct_at(src, nodes, toks, gaps, x, 0x7B, Ghost(GW { g, w: "{"@ })) { return None; } - let ls = ListSpec { m, start: x1, mode: 7, trail: true }; + let ls = ListSpec { m, start: x1, mode: if sh.assign { 9 } else { 7 }, trail: true }; let e = match check_list(src, nodes, toks, gaps, done, &ls, Ghost(g)) { Some(e) => e, None => { @@ -13015,7 +13073,13 @@ fn check_pattern( assert(a.nodes[m as int].kind == nd.kind); assert(a.nodes[m as int].start == nd.start as int); assert(a.nodes[m as int].end == nd.end as int); - if sh.array { + if sh.assign { + if sh.array { + lemma_array_apattern_done(a, g.ts, g.cx, m as int, x as int, e as int); + } else { + lemma_object_apattern_done(a, g.ts, g.cx, m as int, x as int, e as int); + } + } else if sh.array { lemma_array_pattern_done(a, g.ts, g.cx, m as int, x as int, e as int); } else { lemma_object_pattern_done(a, g.ts, g.cx, m as int, x as int, e as int); @@ -13024,4 +13088,300 @@ fn check_pattern( Some((x, e.saturating_add(1), -100)) } +// --------------------------------------------------------------------- +// Assignment patterns (§13.15.5): `[a, b = 1, ...c] = d`, `({a, b: c, ...d} = e)`. +// --------------------------------------------------------------------- + +/// §13.15.5 `ArrayAssignmentPattern : [ elements ]`. +#[verifier::spinoff_prover] +proof fn lemma_array_apattern_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= x, + x + 1 <= e < tn(ts), + a.nodes[m].kind == NodeKind::ArrayAssignmentPattern, + darray(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e), + forall|k: int| + 0 <= k < a.nodes[m].children.len() ==> array_item_mode_ok( + a, + #[trigger] a.nodes[m].children[k], + 8, + ), + rest_only_last(a, a.nodes[m].children), + is_p(ts, x, "["@), + is_p(ts, e, "]"@), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[e].end, + ensures + node_done(a, ts, m, cx, x, e + 1), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, e + 1)); + assert forall|k: int| 0 <= k < a.nodes[m].children.len() implies kd( + a, + #[trigger] a.nodes[m].children[k], + ) == NodeKind::AssignmentElement || kd(a, a.nodes[m].children[k]) == NodeKind::Elision || kd( + a, + a.nodes[m].children[k], + ) == NodeKind::AssignmentRestElement by { + assert(array_item_mode_ok(a, a.nodes[m].children[k], 8)); + } + assert(d_pat(a, ts, m, cx, x, e + 1)); + lemma_ed_of(a, ts, m, x, e + 1); +} + +/// §13.15.5 `ObjectAssignmentPattern : { AssignmentPropertyList ,? }`. +#[verifier::spinoff_prover] +proof fn lemma_object_apattern_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= x, + x + 1 <= e < tn(ts), + a.nodes[m].kind == NodeKind::ObjectAssignmentPattern, + dsep(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e, true), + forall|k: int| + 0 <= k < a.nodes[m].children.len() ==> list_item_ok(a, #[trigger] a.nodes[m].children[k], 9), + rest_only_last(a, a.nodes[m].children), + is_p(ts, x, "{"@), + is_p(ts, e, "}"@), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[e].end, + ensures + node_done(a, ts, m, cx, x, e + 1), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, e + 1)); + assert(all_kind2(a, a.nodes[m].children, 0, NodeKind::AssignmentProperty, NodeKind::AssignmentRestProperty)) by { + assert forall|k: int| 0 <= k < a.nodes[m].children.len() implies kd( + a, + #[trigger] a.nodes[m].children[k], + ) == NodeKind::AssignmentProperty || kd(a, a.nodes[m].children[k]) + == NodeKind::AssignmentRestProperty by { + assert(list_item_ok(a, a.nodes[m].children[k], 9)); + } + } + assert(d_pat(a, ts, m, cx, x, e + 1)); + lemma_ed_of(a, ts, m, x, e + 1); +} + +/// §13.15.5 `AssignmentProperty : IdentifierReference Initializer? | PropertyName : AssignmentElement`. +#[verifier::spinoff_prover] +#[verifier::rlimit(100)] +proof fn lemma_assignment_property_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + k0: int, + k1: int, + x: int, + mk: int, + j: int, + with_init: bool, +) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= k0 < m, + 0 <= k1 < m, + a.nodes[m].kind == NodeKind::AssignmentProperty, + a.nodes[m].children =~= seq![k0, k1], + 0 <= x < j <= tn(ts), + if a.nodes[m].op == Op::Shorthand { + kd(a, k0) == NodeKind::IdentifierReference && node_done(a, ts, k0, cx, x, x + 1) && ( + if with_init { + is_p(ts, x + 1, "="@) && is_assign_expr(a, k1) && node_done(a, ts, k1, cx, x + 2, j) + } else { + kd(a, k1) == NodeKind::Absent && j == x + 1 && d(a, ts, k1, cx, x + 1, x + 1) + }) + } else { + a.nodes[m].op == Op::KeyValue && is_prop_name_kind(kd(a, k0)) && kd(a, k1) + == NodeKind::AssignmentElement && node_done(a, ts, k0, cx, x, mk) && is_p( + ts, + mk, + ":"@, + ) && node_done(a, ts, k1, cx, mk + 1, j) + }, + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == k0); + assert(a.nodes[m].children[1] == k1); + if a.nodes[m].op == Op::KeyValue { + assert(dc(a, ts, m, k0, cx, x, mk)); + assert(dc(a, ts, m, k1, cx, mk + 1, j)); + } else { + assert(dc(a, ts, m, k0, cx, x, x + 1)); + if with_init { + assert(dc(a, ts, m, k1, cx_in(cx, true), x + 2, j)); + assert(d_init(a, ts, m, k1, cx_in(cx, true), x + 1, j, false)); + } else { + assert(dc(a, ts, m, k1, cx_in(cx, true), x + 1, x + 1)); + assert(d_init(a, ts, m, k1, cx_in(cx, true), x + 1, j, false)); + } + } + assert(d_pat(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.15.5 `AssignmentProperty`. +#[verifier::spinoff_prover] +fn check_assignment_property( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + proof { + reveal_strlit("="); + assert("="@ =~= seq!['=']); + } + if !matches!(nd.kind, NodeKind::AssignmentProperty) || nd.children.len() != 2 { + return None; + } + let k0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let k1 = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let (lo0, h0, _) = match done_at(done, k0) { + Some(r) => r, + None => { + return None; + }, + }; + let kk0 = kind_at(nodes, k0); + let kk1 = kind_at(nodes, k1); + let x1 = x.saturating_add(1); + let (j, with_init): (usize, bool) = match nd.op { + Op::Shorthand => { + if !matches!(kk0, NodeKind::IdentifierReference) || lo0 != x || h0 != x1 { + return None; + } + if matches!(kk1, NodeKind::Absent) { + if !check_absent(src, nodes, toks, gaps, k1, x1, Ghost(g)) { + return None; + } + (x1, false) + } else { + let (lo1, h1, lv1) = match done_at(done, k1) { + Some(r) => r, + None => { + return None; + }, + }; + if lv1 < 0 || lo1 != x.saturating_add(2) + || !punct_at(src, nodes, toks, gaps, x1, 0x3D, Ghost(GW { g, w: "="@ })) { + return None; + } + (h1, true) + } + }, + Op::KeyValue => { + let (lo1, h1, _) = match done_at(done, k1) { + Some(r) => r, + None => { + return None; + }, + }; + if !matches!( + kk0, + NodeKind::IdentifierName | NodeKind::StringLiteral | NodeKind::NumericLiteral + | NodeKind::ComputedPropertyName + ) || !matches!(kk1, NodeKind::AssignmentElement) || lo0 != x + || !punct_at(src, nodes, toks, gaps, h0, 0x3A, Ghost(GW { g, w: ":"@ })) + || lo1 != h0.saturating_add(1) { + return None; + } + (h1, false) + }, + _ => { + return None; + }, + }; + let _ = with_init; + if !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x1 as int == x as int + 1); + assert(a.nodes[m as int].children =~= seq![k0 as int, k1 as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].op == nd.op); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k0 as int, g.cx, 0); + assert(kd(a, k0 as int) == kk0); + assert(kd(a, k1 as int) == kk1); + let mk: usize = if nd.op == Op::KeyValue { h0 } else { 0 }; + if nd.op == Op::KeyValue { + assert(h0.saturating_add(1) as int == h0 as int + 1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int, g.cx, 1); + } else if with_init { + assert(x.saturating_add(2) as int == x as int + 2); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int, g.cx, 1); + assert(is_assign_expr(a, k1 as int)); + } + lemma_assignment_property_done(a, g.ts, g.cx, m as int, k0 as int, k1 as int, x as int, mk as int, j as int, with_init); + } + Some((x, j, -100)) +} + } // verus! diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index b61eb741..a6c816bf 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -82,6 +82,11 @@ var c;", "(async a => await a);", "(async (a) => 1);", "function f() { function g() { return 1 } return g }", + "[a] = b;", + "[a, , b = 1, ...c.d] = e;", + "({a} = b);", + "({a = 1, b: c, d: [e], f: {g}, ...h} = i);", + "[a.b, c.d] = d;", "var [a] = 1;", "var [a, , b = 2, ...c] = d;", "var {a, b: c, d = 3, ...e} = f;", From 5541a4b01c11e53b2c57b6891a70fe825a48feed Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Thu, 19 Nov 2026 03:55:59 +0000 Subject: [PATCH 005/195] Check ++/--, a[b] and new against the tokens (7.3) UpdateExpression (prefix and postfix), MemberExpression with a bracket, and NewExpression (with and without arguments). Verus: 306 verified. Verified share 829 to 1414 of 1568 positive runs (90.2%); harness files 10 to 28 of 41. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 582 +++++++++++++++++++- crates/clazel-js-syntax/tests/derivation.rs | 11 +- 2 files changed, 581 insertions(+), 12 deletions(-) diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index 57407d74..a271664a 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -6073,6 +6073,7 @@ pub fn check_derivation( | NodeKind::BooleanLiteral | NodeKind::UnaryExpression | NodeKind::AssignmentExpression | NodeKind::MemberExpression | NodeKind::VariableDeclaration | NodeKind::LexicalBinding | NodeKind::VariableDeclarationList | NodeKind::ForDeclaration | NodeKind::LexicalDeclaration + | NodeKind::UpdateExpression ); if !plain && !any_ctx { return Derivation::Unsupported; @@ -6216,15 +6217,18 @@ pub fn check_derivation( m, Ghost(GCx { ts, cx }), ), - NodeKind::MemberExpression => check_member_dot( - src, - nodes, - toks, - gaps, - &done, - m, - Ghost(GCx { ts, cx }), - ), + NodeKind::MemberExpression => { + if matches!(nd.op, Op::Bracket) { + if !plain { + return Derivation::Unsupported; + } + check_member_bracket(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + } else { + check_member_dot(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + } + }, + NodeKind::UpdateExpression => check_update(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::NewExpression => check_new(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ExpressionStatement => check_exprstmt( src, nodes, @@ -6437,7 +6441,7 @@ fn child_cx(kind: NodeKind, k: usize, p: &Cx5, ident: bool, braced: bool) -> (r: | NodeKind::LogicalORExpression | NodeKind::CoalesceExpression | NodeKind::RelationalExpression | NodeKind::UnaryExpression | NodeKind::AssignmentExpression | NodeKind::MemberExpression | NodeKind::VariableDeclaration | NodeKind::LexicalBinding | NodeKind::VariableDeclarationList - | NodeKind::LexicalDeclaration | NodeKind::ForDeclaration + | NodeKind::LexicalDeclaration | NodeKind::ForDeclaration | NodeKind::UpdateExpression ) { return *p; } @@ -13384,4 +13388,562 @@ fn check_assignment_property( Some((x, j, -100)) } +// --------------------------------------------------------------------- +// `++` and `--` (§13.4), `a[b]` (§13.3.2) and `new` (§13.3.5). +// --------------------------------------------------------------------- + +/// The words `new` as code points, and the punctuators `++`, `--`. +proof fn lemma_words6() + ensures + cps("new"@) =~= seq![0x6Eu32, 0x65, 0x77], + cps("++"@) =~= seq![0x2Bu32, 0x2B], + cps("--"@) =~= seq![0x2Du32, 0x2D], +{ + reveal_strlit("new"); + reveal_strlit("++"); + reveal_strlit("--"); + assert("new"@ =~= seq!['n', 'e', 'w']); + assert("++"@ =~= seq!['+', '+']); + assert("--"@ =~= seq!['-', '-']); +} + +/// Token `x` is `++` (`inc`) or `--`. +fn incdec_at( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + x: usize, + inc: bool, + Ghost(g): Ghost, +) -> (r: bool) + requires + env_ok(src@, nodes@, toks@, gaps@, g.ts), + ensures + r ==> x < toks.len() && is_p(g.ts, x as int, if inc { + "++"@ + } else { + "--"@ + }), +{ + let _ = (nodes.len(), gaps.len()); + let t = match toks.get(x) { + Some(t) => t, + None => { + return false; + }, + }; + proof { + lemma_words6(); + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, x as int); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + assert(t == &toks@[x as int]); + } + let r = matches!(t.kind, TokKind::Punctuator) + && (if inc { text_is(src, t, &[0x2B, 0x2B]) } else { text_is(src, t, &[0x2D, 0x2D]) }); + proof { + if r { + assert(g.ts.toks[x as int].text =~= src@.subrange(t.start as int, t.end as int)); + } + } + r +} + +/// §13.4 `UpdateExpression`. +#[verifier::spinoff_prover] +#[verifier::rlimit(100)] +proof fn lemma_update_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + c: int, + x: int, + prefix: bool, + inc: bool, + mo: int, + j: int, +) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c < m, + a.nodes[m].kind == NodeKind::UpdateExpression, + a.nodes[m].children =~= seq![c], + a.nodes[m].op == (if prefix { + if inc { + Op::PrefixIncrement + } else { + Op::PrefixDecrement + } + } else if inc { + Op::PostfixIncrement + } else { + Op::PostfixDecrement + }), + if prefix { + is_p(ts, x, if inc { + "++"@ + } else { + "--"@ + }) && lvl(a, c) >= 12 && node_done(a, ts, c, cx, x + 1, j) + } else { + lvl(a, c) >= 14 && node_done(a, ts, c, cx, x, mo) && is_p(ts, mo, if inc { + "++"@ + } else { + "--"@ + }) && !nl(ts, mo) && j == mo + 1 + }, + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == 13, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c); + if prefix { + assert(dc(a, ts, m, c, cx, x + 1, j)); + assert(is_op_tok(ts, x, a.nodes[m].op)); + } else { + assert(is_lhs_expr(a, c)); + assert(dc(a, ts, m, c, cx, x, mo)); + assert(is_op_tok(ts, mo, a.nodes[m].op)); + } + assert(d_expr(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.4 `UpdateExpression`. +#[verifier::spinoff_prover] +fn check_update( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::UpdateExpression) || nd.children.len() != 1 { + return None; + } + let (prefix, inc): (bool, bool) = match nd.op { + Op::PrefixIncrement => (true, true), + Op::PrefixDecrement => (true, false), + Op::PostfixIncrement => (false, true), + Op::PostfixDecrement => (false, false), + _ => { + return None; + }, + }; + let c = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let (lo_c, hi_c, lv_c) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + let x1 = x.saturating_add(1); + let j: usize = if prefix { + if lv_c < 12 || lo_c != x1 || !incdec_at(src, nodes, toks, gaps, x, inc, Ghost(g)) { + return None; + } + hi_c + } else { + if lv_c < 14 || lo_c != x || !incdec_at(src, nodes, toks, gaps, hi_c, inc, Ghost(g)) + || !no_nl_at(src, nodes, toks, gaps, hi_c, Ghost(g)) { + return None; + } + hi_c.saturating_add(1) + }; + if !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x1 as int == x as int + 1); + assert(a.nodes[m as int].children =~= seq![c as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].op == nd.op); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 0); + if !prefix { + assert(hi_c.saturating_add(1) as int == hi_c as int + 1); + } + lemma_update_done(a, g.ts, g.cx, m as int, c as int, x as int, prefix, inc, hi_c as int, j as int); + } + Some((x, j, 13)) +} + +/// §13.3.2 `MemberExpression [ Expression ]`. +#[verifier::spinoff_prover] +#[verifier::rlimit(100)] +proof fn lemma_member_bracket_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + o: int, + p: int, + x: int, + mo: int, + q: int, +) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= o < m, + 0 <= p < m, + a.nodes[m].kind == NodeKind::MemberExpression, + a.nodes[m].op == Op::Bracket, + a.nodes[m].children =~= seq![o, p], + is_member_or_call(a, o), + node_done(a, ts, o, cx, x, mo), + is_p(ts, mo, "["@), + lvl(a, p) >= -1, + node_done(a, ts, p, cx, mo + 1, q), + is_p(ts, q, "]"@), + 0 <= x < q + 1 <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[q].end, + ensures + node_done(a, ts, m, cx, x, q + 1), + lvl(a, m) == (if lvl(a, o) == 17 { + 17int + } else { + 15int + }), +{ + assert(span_ok(a, ts, m, x, q + 1)); + assert(a.nodes[m].children[0] == o); + assert(a.nodes[m].children[1] == p); + assert(dc(a, ts, m, o, cx, x, mo)); + assert(dc(a, ts, m, p, cx_in(cx, true), mo + 1, q)); + assert(d_expr_lhs(a, ts, m, cx, x, q + 1)); + lemma_ed_of(a, ts, m, x, q + 1); +} + +/// §13.3.2 `object [ expression ]`. +#[verifier::spinoff_prover] +fn check_member_bracket( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_brackets(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::MemberExpression) || !matches!(nd.op, Op::Bracket) + || nd.children.len() != 2 { + return None; + } + let o = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let p = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_o, mo, lv_o) = match done_at(done, o) { + Some(r) => r, + None => { + return None; + }, + }; + let (lo_p, q, lv_p) = match done_at(done, p) { + Some(r) => r, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if lo_o != x || !(lv_o == 17 || lv_o == 15) || lv_p < -1 || lo_p != mo.saturating_add(1) + || !punct_at(src, nodes, toks, gaps, mo, 0x5B, Ghost(GW { g, w: "["@ })) + || !punct_at(src, nodes, toks, gaps, q, 0x5D, Ghost(GW { g, w: "]"@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, q.saturating_add(1), Ghost(g)) || lo_o >= q { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(mo.saturating_add(1) as int == mo as int + 1); + assert(q.saturating_add(1) as int == q as int + 1); + assert(a.nodes[m as int].children =~= seq![o as int, p as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].op == nd.op); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, o as int, g.cx, 0); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, p as int, g.cx, 1); + assert(is_member_or_call(a, o as int)); + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, q as int); + assert(g.ts.toks[q as int].end == nd.end as int); + lemma_member_bracket_done(a, g.ts, g.cx, m as int, o as int, p as int, lo_o as int, mo as int, q as int); + } + let own: i32 = if lv_o == 17 { 17 } else { 15 }; + Some((lo_o, q.saturating_add(1), own)) +} + +/// §13.3.5 `new MemberExpression Arguments`, `new NewExpression`. +#[verifier::spinoff_prover] +#[verifier::rlimit(100)] +proof fn lemma_new_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + c: int, + ar: int, + x: int, + mc: int, + with_args: bool, + j: int, +) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c < m, + 0 <= ar < m, + a.nodes[m].kind == NodeKind::NewExpression, + a.nodes[m].children =~= seq![c, ar], + is_kw(ts, x, "new"@), + node_done(a, ts, c, cx, x + 1, mc), + if with_args { + lvl(a, c) == 17 && kd(a, ar) == NodeKind::Arguments && node_done(a, ts, ar, cx, mc, j) + } else { + kd(a, ar) == NodeKind::Absent && (lvl(a, c) == 16 || lvl(a, c) == 17) && j == mc && d( + a, + ts, + ar, + cx, + mc, + mc, + ) && ed(a, ts, ar, mc) == mc + }, + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == (if with_args { + 17int + } else { + 16int + }), +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c); + assert(a.nodes[m].children[1] == ar); + assert(dc(a, ts, m, c, cx, x + 1, mc)); + if with_args { + assert(dc(a, ts, m, ar, cx, mc, j)); + } else { + assert(dc(a, ts, m, ar, cx, mc, mc)); + } + assert(d_expr_lhs(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.3.5 `new callee Arguments?`. +#[verifier::spinoff_prover] +fn check_new( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words6(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::NewExpression) || nd.children.len() != 2 { + return None; + } + let c = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let ar = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let (lo_c, mc, lv_c) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + if !word_at(src, nodes, toks, gaps, x, &[0x6E, 0x65, 0x77], Ghost(GW { g, w: "new"@ })) + || lo_c != x.saturating_add(1) { + return None; + } + let ka = kind_at(nodes, ar); + let with_args = !matches!(ka, NodeKind::Absent); + let j: usize = if with_args { + let (lo_a, h_a, _) = match done_at(done, ar) { + Some(r) => r, + None => { + return None; + }, + }; + if lv_c != 17 || !matches!(ka, NodeKind::Arguments) || lo_a != mc { + return None; + } + h_a + } else { + if !(lv_c == 16 || lv_c == 17) || !check_absent(src, nodes, toks, gaps, ar, mc, Ghost(g)) { + return None; + } + mc + }; + if !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(a.nodes[m as int].children =~= seq![c as int, ar as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 0); + assert(kd(a, ar as int) == ka); + if with_args { + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, ar as int, g.cx, 1); + } + lemma_new_done(a, g.ts, g.cx, m as int, c as int, ar as int, x as int, mc as int, with_args, j as int); + } + Some((x, j, if with_args { 17 } else { 16 })) +} + } // verus! diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index a6c816bf..4d0bd380 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -82,6 +82,13 @@ var c;", "(async a => await a);", "(async (a) => 1);", "function f() { function g() { return 1 } return g }", + "a++; b--; ++c; --d.e;", + "x = a[0] + b[c][d];", + "new a;", + "new a();", + "new a.b(1, 2);", + "new new a()();", + "new (f())();", "[a] = b;", "[a, , b = 1, ...c.d] = e;", "({a} = b);", @@ -159,7 +166,7 @@ var c;", #[test] fn other_programs_are_unsupported_not_failed() { - for s in ["for (a, b;;) ;", "new a;", "a++;", "class A {}"] { + for s in ["for (a, b;;) ;", "class A {}", "`a`;", "a?.b;"] { assert!( derivation(s, SourceGoal::Script) == Some(Derivation::Unsupported), "{s}" @@ -181,7 +188,7 @@ fn errors_are_still_errors() { fn what_the_check_costs() { let body = "(1 + 2 * 3) < 4 - 5 / 6 % 7;\n".repeat(60_000); let covered = cps(&body); - let stopped = cps(&format!("new a;\n{body}")); + let stopped = cps(&format!("class A {{}}\n{body}")); let time = |src: &[u32]| { let t = Instant::now(); let r = parse_checked(src, SourceGoal::Script); From e80be5a4b04e5e234ffdeb59b3706895e3160ed9 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Thu, 19 Nov 2026 04:25:30 +0000 Subject: [PATCH 006/195] Check classes and methods against the tokens (7.3) ClassDeclaration and ClassExpression (extends), ClassBody with its ';' (dclass), MethodDefinition (method, getter, setter, generator, async, async generator, static; in classes and object literals), FieldDefinition, ClassStaticBlock and PrivateIdentifier. Each part is in its production's context (cx_fn for the parameters and body, [+Await] for a static block). Verus: 324 verified. Verified share 1414 to 1560 of 1568 positive runs (99.5%); harness files stay 28 of 41. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 1337 ++++++++++++++++++- crates/clazel-js-syntax/tests/derivation.rs | 15 +- 2 files changed, 1346 insertions(+), 6 deletions(-) diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index a271664a..71d9329e 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -1583,7 +1583,7 @@ pub open spec fn item_ok_val(l: int, k: NodeKind, mode: int) -> bool { } else if mode == 3 { k == NodeKind::LexicalBinding } else if mode == 5 { - k == NodeKind::PropertyDefinition + k == NodeKind::PropertyDefinition || k == NodeKind::MethodDefinition } else if mode == 7 { k == NodeKind::BindingProperty || k == NodeKind::BindingRestProperty } else if mode == 9 { @@ -1607,7 +1607,7 @@ fn item_ok_exec(l: i32, k: NodeKind, mode: u8) -> (r: bool) } else if mode == 3 { matches!(k, NodeKind::LexicalBinding) } else if mode == 5 { - matches!(k, NodeKind::PropertyDefinition) + matches!(k, NodeKind::PropertyDefinition | NodeKind::MethodDefinition) } else if mode == 7 { matches!(k, NodeKind::BindingProperty | NodeKind::BindingRestProperty) } else if mode == 9 { @@ -5984,6 +5984,7 @@ pub fn check_derivation( proof { if plain { assert(cx_in(cx, true) == cx); + assert(!cx.deflt); } assert(cxm == done.cxs@[m as int]); } @@ -6015,6 +6016,26 @@ pub fn check_derivation( } check_for_in_of(src, nodes, toks, gaps, &done, &sh, Ghost(GCx { ts, cx })) } + } else if matches!(nd.kind, NodeKind::MethodDefinition) { + let is_async = matches!(nd.op, Op::AsyncMethod | Op::AsyncGeneratorMethod); + let is_gen = matches!(nd.op, Op::GeneratorMethod | Op::AsyncGeneratorMethod); + let (c0, c1, c2) = fn_cx5(&cxm, is_async, is_gen, false); + if !kids_cx3(nodes, done.cxs.as_slice(), m, &c0, &c1, &c2) { + return Derivation::Unsupported; + } + proof { + assert(nd == &nodes@[m as int]); + } + check_method(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + } else if matches!(nd.kind, NodeKind::ClassStaticBlock) { + let c0 = Cx5 { y: false, a: true, i: true, r: false, d: false }; + if !kids_cx1(nodes, done.cxs.as_slice(), m, &c0) { + return Derivation::Unsupported; + } + proof { + assert(nd == &nodes@[m as int]); + } + check_static_block(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) } else if is_arrow { let is_async = matches!(nd.kind, NodeKind::AsyncArrowFunction); if nd.children.len() != 2 { @@ -6278,6 +6299,16 @@ pub fn check_derivation( }, NodeKind::BindingProperty => check_binding_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::BindingRestElement | NodeKind::BindingRestProperty => check_binding_rest(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::PrivateIdentifier => check_private(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::FieldDefinition => check_field(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ClassBody => check_class_body(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ClassDeclaration | NodeKind::ClassExpression => { + let sh = ClassShape { m, is_expr: matches!(nd.kind, NodeKind::ClassExpression) }; + proof { + assert(nd == &nodes@[m as int]); + } + check_class(src, nodes, toks, gaps, &done, &sh, Ghost(GCx { ts, cx })) + }, NodeKind::ArrayLiteral => check_array(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ObjectLiteral => check_object(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::PropertyDefinition => check_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), @@ -6368,8 +6399,17 @@ fn assign_ctx(nodes: &[Node], module: bool) -> (r: Vec) let len = nd.children.len(); // An arrow function's parts depend on the kinds of its parameters and body. let arrow = matches!(nd.kind, NodeKind::ArrowFunction | NodeKind::AsyncArrowFunction); - let ident = arrow && child_kind_is(nodes, nd, 0, true); - let braced = arrow && child_kind_is(nodes, nd, 1, false); + let method = matches!(nd.kind, NodeKind::MethodDefinition); + let ident = if method { + matches!(nd.op, Op::AsyncMethod | Op::AsyncGeneratorMethod) + } else { + arrow && child_kind_is(nodes, nd, 0, true) + }; + let braced = if method { + matches!(nd.op, Op::GeneratorMethod | Op::AsyncGeneratorMethod) + } else { + arrow && child_kind_is(nodes, nd, 1, false) + }; let mut k: usize = 0; while k < len invariant @@ -6426,6 +6466,20 @@ fn child_cx(kind: NodeKind, k: usize, p: &Cx5, ident: bool, braced: bool) -> (r: let (c0, c1) = arrow_cx5(p, matches!(kind, NodeKind::AsyncArrowFunction), ident, braced); return if k == 0 { c0 } else { c1 }; } + if matches!(kind, NodeKind::MethodDefinition) { + // `ident` is `async`, `braced` a generator, for a method. + let (c0, c1, c2) = fn_cx5(p, ident, braced, false); + return if k == 0 { + c0 + } else if k == 1 { + c1 + } else { + c2 + }; + } + if matches!(kind, NodeKind::ClassStaticBlock) { + return Cx5 { y: false, a: true, i: true, r: false, d: false }; + } if matches!( kind, NodeKind::ForStatement | NodeKind::ForInStatement | NodeKind::ForOfStatement @@ -13946,4 +14000,1279 @@ fn check_new( Some((x, j, if with_args { 17 } else { 16 })) } +// --------------------------------------------------------------------- +// Classes (§15.7) and methods (§15.4 to §15.8): `class`, its body, methods, +// getters and setters, fields, static blocks, private names. +// --------------------------------------------------------------------- + +/// §12.7 `PrivateIdentifier`. +#[verifier::spinoff_prover] +fn check_private( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::PrivateIdentifier) || !nd.children.is_empty() { + return None; + } + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let t = match toks.get(x) { + Some(t) => t, + None => { + return None; + }, + }; + proof { + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, x as int); + assert(t == &toks@[x as int]); + } + if !matches!(t.kind, TokKind::PrivateIdentifier) || t.end != nd.end { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].children.len() == 0); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + assert(g.ts.toks[x as int].end == t.end as int); + assert(g.ts.toks[x as int].kind == TokKind::PrivateIdentifier); + assert(g.ts.toks[x as int].start < g.ts.toks[x as int].end); + assert(span_ok(a, g.ts, m as int, x as int, x as int + 1)); + assert(d_expr_lhs(a, g.ts, m as int, g.cx, x as int, x as int + 1)); + lemma_ed_of(a, g.ts, m as int, x as int, x as int + 1); + } + Some((x, x.saturating_add(1), -100)) +} + +/// The class element name kinds (§15.7 `ClassElementName`), executable. +fn element_name_exec(k: NodeKind) -> (r: bool) + ensures + r ==> is_class_element_name_kind(k), +{ + matches!( + k, + NodeKind::IdentifierName | NodeKind::StringLiteral | NodeKind::NumericLiteral + | NodeKind::ComputedPropertyName | NodeKind::PrivateIdentifier + ) +} + +/// §15.4 `MethodDefinition` and its generator, `async` and accessor forms. +#[verifier::spinoff_prover] +#[verifier::rlimit(150)] +proof fn lemma_method_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + n0: int, + p: int, + b: int, + x: int, + mn: int, + q: int, + j: int, +) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= n0 < m, + 0 <= p < m, + 0 <= b < m, + a.nodes[m].kind == NodeKind::MethodDefinition, + a.nodes[m].children =~= seq![n0, p, b], + a.nodes[m].op == Op::Method || a.nodes[m].op == Op::Getter || a.nodes[m].op == Op::Setter + || a.nodes[m].op == Op::GeneratorMethod || a.nodes[m].op == Op::AsyncMethod + || a.nodes[m].op == Op::AsyncGeneratorMethod, + !a.nodes[m].flag || is_kw(ts, x, "static"@), + ({ + let p0 = if a.nodes[m].flag { + x + 1 + } else { + x + }; + let op = a.nodes[m].op; + let nm = match op { + Op::Method => p0, + Op::Getter | Op::Setter | Op::GeneratorMethod | Op::AsyncMethod => p0 + 1, + _ => p0 + 2, + }; + let is_gen = op == Op::GeneratorMethod || op == Op::AsyncGeneratorMethod; + let is_async = op == Op::AsyncMethod || op == Op::AsyncGeneratorMethod; + (match op { + Op::Method => true, + Op::Getter => is_kw(ts, p0, "get"@), + Op::Setter => is_kw(ts, p0, "set"@), + Op::GeneratorMethod => is_p(ts, p0, "*"@), + Op::AsyncMethod => is_kw(ts, p0, "async"@) && !nl(ts, p0 + 1), + Op::AsyncGeneratorMethod => is_kw(ts, p0, "async"@) && !nl(ts, p0 + 1) && is_p( + ts, + p0 + 1, + "*"@, + ), + _ => false, + }) && is_class_element_name_kind(kd(a, n0)) && kd(a, p) == NodeKind::FormalParameters + && kd(a, b) == NodeKind::FunctionBody && (op == Op::Getter ==> kids(a, p).len() + == 0) && (op == Op::Setter ==> (kids(a, p).len() == 1 && kd( + a, + kid(kids(a, p), 0), + ) == NodeKind::BindingElement)) && node_done(a, ts, n0, cx, nm, mn) && node_done( + a, + ts, + p, + cx_fn(is_gen, is_async, false), + mn, + q, + ) && node_done(a, ts, b, cx_fn(is_gen, is_async, true), q, j) + }), + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == n0); + assert(a.nodes[m].children[1] == p); + assert(a.nodes[m].children[2] == b); + let p0 = if a.nodes[m].flag { + x + 1 + } else { + x + }; + let op = a.nodes[m].op; + let nm = match op { + Op::Method => p0, + Op::Getter | Op::Setter | Op::GeneratorMethod | Op::AsyncMethod => p0 + 1, + _ => p0 + 2, + }; + let is_gen = op == Op::GeneratorMethod || op == Op::AsyncGeneratorMethod; + let is_async = op == Op::AsyncMethod || op == Op::AsyncGeneratorMethod; + assert(dc(a, ts, m, n0, cx, nm, mn)); + assert(dc(a, ts, m, p, cx_fn(is_gen, is_async, false), mn, q)); + assert(dc(a, ts, m, b, cx_fn(is_gen, is_async, true), q, j)); + assert(ed(a, ts, n0, nm) == mn); + assert(ed(a, ts, p, mn) == q); + assert(d_method(a, ts, m, cx, x, j)); + assert(d_func(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §15.4 `MethodDefinition`. +#[verifier::spinoff_prover] +fn check_method( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + 0 <= m < done.cxs@.len(), + cx_of(done.cxs@[m as int]) == g.cx, + cx_kids3( + arena_of(nodes@), + done.cxs@, + m as int, + g.cx, + cx_fn( + nodes@[m as int].op == Op::GeneratorMethod || nodes@[m as int].op + == Op::AsyncGeneratorMethod, + nodes@[m as int].op == Op::AsyncMethod || nodes@[m as int].op + == Op::AsyncGeneratorMethod, + false, + ), + cx_fn( + nodes@[m as int].op == Op::GeneratorMethod || nodes@[m as int].op + == Op::AsyncGeneratorMethod, + nodes@[m as int].op == Op::AsyncMethod || nodes@[m as int].op + == Op::AsyncGeneratorMethod, + true, + ), + ), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words3(); + lemma_words7(); + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::MethodDefinition) || nd.children.len() != 3 { + return None; + } + let n0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let p = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let b = match kid_of(nodes, m, 2) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if nd.flag && !word_at(src, nodes, toks, gaps, x, &[0x73, 0x74, 0x61, 0x74, 0x69, 0x63], Ghost(GW { g, w: "static"@ })) { + return None; + } + let p0: usize = if nd.flag { x.saturating_add(1) } else { x }; + let p1 = p0.saturating_add(1); + let nm: usize = match nd.op { + Op::Method => p0, + Op::Getter | Op::Setter | Op::GeneratorMethod | Op::AsyncMethod => p1, + Op::AsyncGeneratorMethod => p0.saturating_add(2), + _ => { + return None; + }, + }; + let prefix_ok = match nd.op { + Op::Method => true, + Op::Getter => word_at(src, nodes, toks, gaps, p0, &[0x67, 0x65, 0x74], Ghost(GW { g, w: "get"@ })), + Op::Setter => word_at(src, nodes, toks, gaps, p0, &[0x73, 0x65, 0x74], Ghost(GW { g, w: "set"@ })), + Op::GeneratorMethod => punct_at(src, nodes, toks, gaps, p0, 0x2A, Ghost(GW { g, w: "*"@ })), + Op::AsyncMethod => word_at(src, nodes, toks, gaps, p0, &[0x61, 0x73, 0x79, 0x6E, 0x63], Ghost(GW { g, w: "async"@ })) + && no_nl_at(src, nodes, toks, gaps, p1, Ghost(g)), + _ => word_at(src, nodes, toks, gaps, p0, &[0x61, 0x73, 0x79, 0x6E, 0x63], Ghost(GW { g, w: "async"@ })) + && no_nl_at(src, nodes, toks, gaps, p1, Ghost(g)) + && punct_at(src, nodes, toks, gaps, p1, 0x2A, Ghost(GW { g, w: "*"@ })), + }; + let kn = kind_at(nodes, n0); + let (lo_n, mn, _) = match done_at(done, n0) { + Some(r) => r, + None => { + return None; + }, + }; + let (lo_p, q, _) = match done_at(done, p) { + Some(r) => r, + None => { + return None; + }, + }; + let (lo_b, j, _) = match done_at(done, b) { + Some(r) => r, + None => { + return None; + }, + }; + // A getter has no parameters; a setter has one `BindingElement`. + let pn = match nodes.get(p) { + Some(x) => x, + None => { + return None; + }, + }; + let params_ok = match nd.op { + Op::Getter => pn.children.is_empty(), + Op::Setter => { + pn.children.len() == 1 && match kid_of(nodes, p, 0) { + Some(c) => matches!(kind_at(nodes, c), NodeKind::BindingElement), + None => false, + } + }, + _ => true, + }; + if !prefix_ok || !element_name_exec(kn) || lo_n != nm || !params_ok + || !matches!(kind_at(nodes, p), NodeKind::FormalParameters) || lo_p != mn + || !matches!(kind_at(nodes, b), NodeKind::FunctionBody) || lo_b != q + || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(a.nodes[p as int] == nodes@[p as int]@); + assert(pn == &nodes@[p as int]); + assert(a.nodes[m as int].children =~= seq![n0 as int, p as int, b as int]) by { + assert(a.nodes[m as int].children.len() == 3); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].op == nd.op); + assert(a.nodes[m as int].flag == nd.flag); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + assert(x.saturating_add(1) as int == x as int + 1); + assert(p0 as int == (if nd.flag { x as int + 1 } else { x as int })); + assert(p0 < toks.len() || nd.op == Op::Method); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, n0 as int); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, p as int); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, b as int); + assert(kd(a, n0 as int) == kn); + assert(kd(a, p as int) == NodeKind::FormalParameters); + assert(kd(a, b as int) == NodeKind::FunctionBody); + assert(a.nodes[p as int].children.len() == pn.children.len()); + assert(kids(a, p as int) == a.nodes[p as int].children); + if nd.op == Op::Setter { + let c0 = a.nodes[p as int].children[0]; + assert(kid(kids(a, p as int), 0) == c0); + } + assert(cx_of(done.cxs@[n0 as int]) == g.cx); + lemma_method_done(a, g.ts, g.cx, m as int, n0 as int, p as int, b as int, x as int, mn as int, q as int, j as int); + } + Some((x, j, -100)) +} + +/// The words `static`, `get`, `set`, `extends`, as code points. +proof fn lemma_words7() + ensures + cps("static"@) =~= seq![0x73u32, 0x74, 0x61, 0x74, 0x69, 0x63], + cps("get"@) =~= seq![0x67u32, 0x65, 0x74], + cps("set"@) =~= seq![0x73u32, 0x65, 0x74], + cps("extends"@) =~= seq![0x65u32, 0x78, 0x74, 0x65, 0x6E, 0x64, 0x73], + cps("class"@) =~= seq![0x63u32, 0x6C, 0x61, 0x73, 0x73], +{ + reveal_strlit("static"); + reveal_strlit("get"); + reveal_strlit("set"); + reveal_strlit("extends"); + reveal_strlit("class"); + assert("static"@ =~= seq!['s', 't', 'a', 't', 'i', 'c']); + assert("get"@ =~= seq!['g', 'e', 't']); + assert("set"@ =~= seq!['s', 'e', 't']); + assert("extends"@ =~= seq!['e', 'x', 't', 'e', 'n', 'd', 's']); + assert("class"@ =~= seq!['c', 'l', 'a', 's', 's']); +} + +/// §15.7 `FieldDefinition : ClassElementName Initializer? ;`, with `static`. +#[verifier::spinoff_prover] +#[verifier::rlimit(100)] +proof fn lemma_field_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + n0: int, + k1: int, + x: int, + mn: int, + q: int, + j: int, + with_init: bool, +) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= n0 < m, + 0 <= k1 < m, + a.nodes[m].kind == NodeKind::FieldDefinition, + a.nodes[m].children =~= seq![n0, k1], + !a.nodes[m].flag || is_kw(ts, x, "static"@), + is_class_element_name_kind(kd(a, n0)), + node_done(a, ts, n0, cx, if a.nodes[m].flag { + x + 1 + } else { + x + }, mn), + if with_init { + is_p(ts, mn, "="@) && is_assign_expr(a, k1) && node_done(a, ts, k1, cx, mn + 1, q) + } else { + kd(a, k1) == NodeKind::Absent && q == mn && d(a, ts, k1, cx, mn, mn) && ed( + a, + ts, + k1, + mn, + ) == mn + }, + semi(ts, q, j, false), + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == n0); + assert(a.nodes[m].children[1] == k1); + let s = if a.nodes[m].flag { + x + 1 + } else { + x + }; + assert(dc(a, ts, m, n0, cx, s, mn)); + if with_init { + assert(dc(a, ts, m, k1, cx_in(cx, true), mn + 1, q)); + assert(d_init(a, ts, m, k1, cx_in(cx, true), mn, q, false)); + assert(ed(a, ts, k1, mn + 1) == q); + } else { + assert(dc(a, ts, m, k1, cx_in(cx, true), mn, mn)); + assert(d_init(a, ts, m, k1, cx_in(cx, true), mn, q, false)); + } + assert(d_func(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §15.7 `FieldDefinition`. +#[verifier::spinoff_prover] +fn check_field( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words7(); + reveal_strlit("="); + assert("="@ =~= seq!['=']); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::FieldDefinition) || nd.children.len() != 2 { + return None; + } + let n0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let k1 = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if nd.flag && !word_at(src, nodes, toks, gaps, x, &[0x73, 0x74, 0x61, 0x74, 0x69, 0x63], Ghost(GW { g, w: "static"@ })) { + return None; + } + let s: usize = if nd.flag { x.saturating_add(1) } else { x }; + let (lo_n, mn, _) = match done_at(done, n0) { + Some(r) => r, + None => { + return None; + }, + }; + if !element_name_exec(kind_at(nodes, n0)) || lo_n != s { + return None; + } + let ki = kind_at(nodes, k1); + let with_init = !matches!(ki, NodeKind::Absent); + let q: usize = if with_init { + let (lo1, h1, lv1) = match done_at(done, k1) { + Some(r) => r, + None => { + return None; + }, + }; + if lv1 < 0 || lo1 != mn.saturating_add(1) + || !punct_at(src, nodes, toks, gaps, mn, 0x3D, Ghost(GW { g, w: "="@ })) { + return None; + } + h1 + } else { + if !check_absent(src, nodes, toks, gaps, k1, mn, Ghost(g)) { + return None; + } + mn + }; + let j = match find_semi(src, nodes, toks, gaps, q, nd.end, Ghost(g)) { + Some(j) => j, + None => { + return None; + }, + }; + if j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(a.nodes[m as int].children =~= seq![n0 as int, k1 as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].flag == nd.flag); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + assert(x.saturating_add(1) as int == x as int + 1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, n0 as int, g.cx, 0); + assert(kd(a, k1 as int) == ki); + if with_init { + assert(mn.saturating_add(1) as int == mn as int + 1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int, g.cx, 1); + assert(is_assign_expr(a, k1 as int)); + } + lemma_field_done(a, g.ts, g.cx, m as int, n0 as int, k1 as int, x as int, mn as int, q as int, j as int, with_init); + } + Some((x, j, -100)) +} + +/// The one child of node `m` is checked in `c0`. +pub open spec fn cx_kid1(a: AstV, cxs: Seq, m: int, c0: Ctx) -> bool { + 0 <= m < a.nodes.len() && a.nodes[m].children.len() == 1 && 0 <= a.nodes[m].children[0] + < cxs.len() && cx_of(cxs[a.nodes[m].children[0]]) == c0 +} + +/// The one child of node `m` is checked in `c0`. +fn kids_cx1(nodes: &[Node], cxs: &[Cx5], m: usize, c0: &Cx5) -> (r: bool) + requires + m < nodes.len(), + cxs.len() == nodes.len(), + ast_wf(arena_of(nodes@)), + ensures + r ==> cx_kid1(arena_of(nodes@), cxs@, m as int, cx_of(*c0)), +{ + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return false; + }, + }; + if nd.children.len() != 1 { + return false; + } + let a0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return false; + }, + }; + match cxs.get(a0) { + Some(x) => cx_eq(x, c0), + None => false, + } +} + +/// §15.7 `ClassStaticBlock : static { ClassStaticBlockBody }`. +#[verifier::spinoff_prover] +proof fn lemma_static_block_done(a: AstV, ts: Stream, cx: Ctx, m: int, c: int, x: int, j: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c < m, + a.nodes[m].kind == NodeKind::ClassStaticBlock, + a.nodes[m].children =~= seq![c], + is_kw(ts, x, "static"@), + kd(a, c) == NodeKind::FunctionBody, + node_done( + a, + ts, + c, + Ctx { yield_: false, await_: true, in_: true, return_: false, deflt: false }, + x + 1, + j, + ), + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c); + assert(dc( + a, + ts, + m, + c, + Ctx { yield_: false, await_: true, in_: true, return_: false, deflt: false }, + x + 1, + j, + )); + assert(d_func(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §15.7 `ClassStaticBlock`. +#[verifier::spinoff_prover] +fn check_static_block( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + 0 <= m < done.cxs@.len(), + cx_of(done.cxs@[m as int]) == g.cx, + cx_kid1( + arena_of(nodes@), + done.cxs@, + m as int, + Ctx { yield_: false, await_: true, in_: true, return_: false, deflt: false }, + ), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words7(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ClassStaticBlock) || nd.children.len() != 1 { + return None; + } + let c = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let (lo_c, j, _) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + if !word_at(src, nodes, toks, gaps, x, &[0x73, 0x74, 0x61, 0x74, 0x69, 0x63], Ghost(GW { g, w: "static"@ })) + || !matches!(kind_at(nodes, c), NodeKind::FunctionBody) || lo_c != x.saturating_add(1) + || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(a.nodes[m as int].children =~= seq![c as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get_at(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int); + assert(kd(a, c as int) == NodeKind::FunctionBody); + lemma_static_block_done(a, g.ts, g.cx, m as int, c as int, x as int, j as int); + } + Some((x, j, -100)) +} + +/// A class element before a list (§15.7 `ClassElementList`). +#[verifier::spinoff_prover] +proof fn lemma_dclass_child( + a: AstV, + ts: Stream, + bound: int, + ks: Seq, + k: int, + cx: Ctx, + i: int, + m: int, + j: int, +) + requires + 0 <= k < ks.len(), + ed(a, ts, ks[k], i) == m, + dc(a, ts, bound, ks[k], cx, i, m), + dclass(a, ts, bound, ks, k + 1, cx, m, j), + ensures + dclass(a, ts, bound, ks, k, cx, i, j), +{ +} + +/// A `;` before a list (§15.7 `ClassElement : ;`). +#[verifier::spinoff_prover] +proof fn lemma_dclass_skip(a: AstV, ts: Stream, bound: int, ks: Seq, k: int, cx: Ctx, i: int, j: int) + requires + i < j, + is_p(ts, i, ";"@), + dclass(a, ts, bound, ks, k, cx, i + 1, j), + ensures + dclass(a, ts, bound, ks, k, cx, i, j), +{ +} + +/// §15.7 `ClassBody : { ClassElementList? }`. +#[verifier::spinoff_prover] +proof fn lemma_class_body_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= x, + x + 1 <= e < tn(ts), + a.nodes[m].kind == NodeKind::ClassBody, + forall|k: int| + 0 <= k < a.nodes[m].children.len() ==> kd(a, #[trigger] a.nodes[m].children[k]) + == NodeKind::MethodDefinition || kd(a, a.nodes[m].children[k]) + == NodeKind::FieldDefinition || kd(a, a.nodes[m].children[k]) + == NodeKind::ClassStaticBlock, + dclass(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e), + is_p(ts, x, "{"@), + is_p(ts, e, "}"@), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[e].end, + ensures + node_done(a, ts, m, cx, x, e + 1), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, e + 1)); + assert(d_func(a, ts, m, cx, x, e + 1)); + lemma_ed_of(a, ts, m, x, e + 1); +} + +/// §15.7 `ClassBody`. +#[verifier::spinoff_prover] +fn check_class_body( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_brace_text(); + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ClassBody) { + return None; + } + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if !punct_at(src, nodes, toks, gaps, x, 0x7B, Ghost(GW { g, w: "{"@ })) { + return None; + } + let start = x.saturating_add(1); + let len = nd.children.len(); + // Where the list ends: after the last element and any `;` that follow it. + let mut close: usize = if len == 0 { + start + } else { + let last = match kid_of(nodes, m, len.saturating_sub(1)) { + Some(c) => c, + None => { + return None; + }, + }; + match done_at(done, last) { + Some((_, h, _)) => h, + None => { + return None; + }, + } + }; + let ghost a = arena_of(nodes@); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + } + if close > toks.len() || close < start { + return None; + } + let ghost close0 = close; + loop + invariant + close <= toks.len(), + close0 <= close, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + cps(";"@) =~= seq![0x3Bu32], + decreases toks.len() - close, + { + if close < toks.len() && punct_at(src, nodes, toks, gaps, close, 0x3B, Ghost(GW { g, w: ";"@ })) { + close = close.saturating_add(1); + } else { + break; + } + } + if close > toks.len() || !punct_at(src, nodes, toks, gaps, close, 0x7D, Ghost(GW { g, w: "}"@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, close.saturating_add(1), Ghost(g)) { + return None; + } + // Backwards: each element ends where the rest starts, or a `;` is skipped. + let mut k = len; + let mut pos = close; + proof { + reveal_with_fuel(dclass, 2); + assert(dclass(a, g.ts, m as int, a.nodes[m as int].children, len as int, g.cx, close as int, close as int)); + } + while k > 0 || pos > start + invariant + m < nodes.len(), + nodes@.len() == nodes.len(), + nd == &nodes@[m as int], + a == arena_of(nodes@), + len == nd.children.len(), + len == a.nodes[m as int].children.len(), + k <= len, + start <= pos, + pos <= close, + close < toks.len(), + cps(";"@) =~= seq![0x3Bu32], + tn(g.ts) == toks.len(), + ast_wf(a), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(a, done.cxs@, m as int, g.cx), + dclass(a, g.ts, m as int, a.nodes[m as int].children, k as int, g.cx, pos as int, close as int), + forall|q: int| + k <= q < len ==> (kd(a, #[trigger] a.nodes[m as int].children[q]) == NodeKind::MethodDefinition + || kd(a, a.nodes[m as int].children[q]) == NodeKind::FieldDefinition + || kd(a, a.nodes[m as int].children[q]) == NodeKind::ClassStaticBlock), + decreases pos, + { + let ghost ks = a.nodes[m as int].children; + let child_ends_here = if k > 0 { + match kid_of(nodes, m, k.saturating_sub(1)) { + Some(c) => match done_at(done, c) { + Some((_, h, _)) => h == pos, + None => false, + }, + None => false, + } + } else { + false + }; + if child_ends_here { + let c = match kid_of(nodes, m, k.saturating_sub(1)) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_c, hi_c, _) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + let _ = hi_c; + let kc = kind_at(nodes, c); + if !matches!( + kc, + NodeKind::MethodDefinition | NodeKind::FieldDefinition | NodeKind::ClassStaticBlock + ) || lo_c < start { + return None; + } + proof { + assert(k >= 1); + assert(k.saturating_sub(1) as int == k as int - 1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, k as int - 1); + assert(kd(a, c as int) == kc); + assert(ed(a, g.ts, c as int, lo_c as int) == hi_c as int); + assert(dc(a, g.ts, m as int, c as int, g.cx, lo_c as int, hi_c as int)); + lemma_dclass_child(a, g.ts, m as int, ks, k as int - 1, g.cx, lo_c as int, hi_c as int, close as int); + } + pos = lo_c; + k = k.saturating_sub(1); + } else { + if pos <= start || pos < 1 { + return None; + } + let semi_before = pos.saturating_sub(1); + if !punct_at(src, nodes, toks, gaps, semi_before, 0x3B, Ghost(GW { g, w: ";"@ })) { + return None; + } + proof { + assert(semi_before as int == pos as int - 1); + lemma_dclass_skip(a, g.ts, m as int, ks, k as int, g.cx, pos as int - 1, close as int); + } + pos = semi_before; + } + } + proof { + assert(k == 0); + assert(pos == start); + assert(start as int == x as int + 1); + assert(forall|q: int| + 0 <= q < len ==> (kd(a, #[trigger] a.nodes[m as int].children[q]) == NodeKind::MethodDefinition + || kd(a, a.nodes[m as int].children[q]) == NodeKind::FieldDefinition + || kd(a, a.nodes[m as int].children[q]) == NodeKind::ClassStaticBlock)); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + assert(close.saturating_add(1) as int == close as int + 1); + lemma_class_body_done(a, g.ts, g.cx, m as int, x as int, close as int); + } + Some((x, close.saturating_add(1), -100)) +} + +/// §15.7 `class Name? ClassHeritage? ClassBody`. +#[verifier::spinoff_prover] +#[verifier::rlimit(150)] +proof fn lemma_class_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + k0: int, + k1: int, + k2: int, + is_expr: bool, + x: int, + mn: int, + h: int, + j: int, +) + requires + toks_wf(ts), + !cx.deflt, + 0 <= m < a.nodes.len(), + 0 <= k0 < m, + 0 <= k1 < m, + 0 <= k2 < m, + a.nodes[m].kind == (if is_expr { + NodeKind::ClassExpression + } else { + NodeKind::ClassDeclaration + }), + a.nodes[m].children =~= seq![k0, k1, k2], + is_kw(ts, x, "class"@), + kd(a, k2) == NodeKind::ClassBody, + if kd(a, k0) == NodeKind::Absent { + is_expr && d(a, ts, k0, cx, x + 1, x + 1) && mn == x + 1 && ed(a, ts, k0, x + 1) == mn + } else { + kd(a, k0) == NodeKind::BindingIdentifier && node_done(a, ts, k0, cx, x + 1, mn) + }, + if kd(a, k1) == NodeKind::Absent { + d(a, ts, k1, cx, mn, mn) && ed(a, ts, k1, mn) == mn && h == mn + } else { + is_lhs_expr(a, k1) && is_kw(ts, mn, "extends"@) && node_done(a, ts, k1, cx, mn + 1, h) + }, + node_done(a, ts, k2, cx, h, j), + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == (if is_expr { + 17int + } else { + -100int + }), +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == k0); + assert(a.nodes[m].children[1] == k1); + assert(a.nodes[m].children[2] == k2); + assert(dc(a, ts, m, k0, cx, x + 1, mn)); + let hs = if kd(a, k1) == NodeKind::Absent { + mn + } else { + mn + 1 + }; + assert(dc(a, ts, m, k1, cx, hs, h)); + assert(dc(a, ts, m, k2, cx, h, j)); + assert(d_class(a, ts, m, cx, x, j, is_expr)); + assert(d_func(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// What `check_class` reads: the node and whether it is an expression. +pub struct ClassShape { + /// The node. + pub m: usize, + /// A `ClassExpression` (else a `ClassDeclaration`). + pub is_expr: bool, +} + +/// §15.7 `ClassDeclaration`, `ClassExpression`. +#[verifier::spinoff_prover] +fn check_class( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + sh: &ClassShape, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + sh.m < nodes.len(), + !g.cx.deflt, + nodes@[sh.m as int].kind == (if sh.is_expr { + NodeKind::ClassExpression + } else { + NodeKind::ClassDeclaration + }), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, sh.m as int), + cx_ok(arena_of(nodes@), done.cxs@, sh.m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + sh.m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), sh.m as int), + None => true, + }, +{ + let m = sh.m; + proof { + lemma_words7(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if nd.children.len() != 3 { + return None; + } + let k0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let k1 = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let k2 = match kid_of(nodes, m, 2) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if !word_at(src, nodes, toks, gaps, x, &[0x63, 0x6C, 0x61, 0x73, 0x73], Ghost(GW { g, w: "class"@ })) { + return None; + } + let x1 = x.saturating_add(1); + let kn = kind_at(nodes, k0); + let mn: usize = if matches!(kn, NodeKind::Absent) { + if !sh.is_expr || !check_absent(src, nodes, toks, gaps, k0, x1, Ghost(g)) { + return None; + } + x1 + } else { + let (lo_n, hi_n, _) = match done_at(done, k0) { + Some(r) => r, + None => { + return None; + }, + }; + if !matches!(kn, NodeKind::BindingIdentifier) || lo_n != x1 { + return None; + } + hi_n + }; + let kh = kind_at(nodes, k1); + let h: usize = if matches!(kh, NodeKind::Absent) { + if !check_absent(src, nodes, toks, gaps, k1, mn, Ghost(g)) { + return None; + } + mn + } else { + let (lo_h, hi_h, lv_h) = match done_at(done, k1) { + Some(r) => r, + None => { + return None; + }, + }; + if lv_h < 14 || lo_h != mn.saturating_add(1) + || !word_at(src, nodes, toks, gaps, mn, &[0x65, 0x78, 0x74, 0x65, 0x6E, 0x64, 0x73], Ghost(GW { g, w: "extends"@ })) { + return None; + } + hi_h + }; + let (lo_b, j, _) = match done_at(done, k2) { + Some(r) => r, + None => { + return None; + }, + }; + if !matches!(kind_at(nodes, k2), NodeKind::ClassBody) || lo_b != h + || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x1 as int == x as int + 1); + assert(a.nodes[m as int].children =~= seq![k0 as int, k1 as int, k2 as int]) by { + assert(a.nodes[m as int].children.len() == 3); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + assert(kd(a, k0 as int) == kn); + assert(kd(a, k1 as int) == kh); + assert(kd(a, k2 as int) == NodeKind::ClassBody); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k2 as int, g.cx, 2); + if !matches!(kn, NodeKind::Absent) { + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k0 as int, g.cx, 0); + } + if !matches!(kh, NodeKind::Absent) { + assert(mn.saturating_add(1) as int == mn as int + 1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int, g.cx, 1); + assert(is_lhs_expr(a, k1 as int)); + } + lemma_class_done(a, g.ts, g.cx, m as int, k0 as int, k1 as int, k2 as int, sh.is_expr, x as int, mn as int, h as int, j as int); + } + let l: i32 = if sh.is_expr { 17 } else { -100 }; + Some((x, j, l)) +} + } // verus! diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index 4d0bd380..e52aebcd 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -82,6 +82,16 @@ var c;", "(async a => await a);", "(async (a) => 1);", "function f() { function g() { return 1 } return g }", + "class A {}", + "class A extends B { }", + "class A { m() {} static s(a) { return a } get g() { return 1 } set g(v) {} }", + "class A { *gen() { yield 1 } async am() { await 1 } async *ag() { yield 1 } }", + "class A { x; y = 1; static z = 2; 'q' = 3; [k] = 4; }", + "class A { #p = 1; #m() {} static #s; get #g() { return 1 } }", + "class A { ; ; m() {} ; }", + "class A { static { a; } static { var x = 1; } }", + "(class {}); (class B extends C {});", + "x = {m() {}, get a() { return 1 }, set a(v) {}, *g() {}, async f() {}, [k]() {}};", "a++; b--; ++c; --d.e;", "x = a[0] + b[c][d];", "new a;", @@ -166,7 +176,7 @@ var c;", #[test] fn other_programs_are_unsupported_not_failed() { - for s in ["for (a, b;;) ;", "class A {}", "`a`;", "a?.b;"] { + for s in ["for (a, b;;) ;", "`a`;", "a?.b;"] { assert!( derivation(s, SourceGoal::Script) == Some(Derivation::Unsupported), "{s}" @@ -188,7 +198,8 @@ fn errors_are_still_errors() { fn what_the_check_costs() { let body = "(1 + 2 * 3) < 4 - 5 / 6 % 7;\n".repeat(60_000); let covered = cps(&body); - let stopped = cps(&format!("class A {{}}\n{body}")); + let stopped = cps(&format!("`a`; +{body}")); let time = |src: &[u32]| { let t = Instant::now(); let r = parse_checked(src, SourceGoal::Script); From 221ba191e07380231e5dcef541e91148133c79e8 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Thu, 19 Nov 2026 04:29:56 +0000 Subject: [PATCH 007/195] Check template literals and tagged templates against the tokens (7.3) TemplateLiteral (elements and substitutions alternate, dtemplate, checked from the back), TemplateElement and TaggedTemplate. Verus: 332 verified. Verified share 1560 to 1562 of 1568 positive runs; harness files 28 to 36 of 41. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 489 ++++++++++++++++++++ crates/clazel-js-syntax/tests/derivation.rs | 11 +- 2 files changed, 497 insertions(+), 3 deletions(-) diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index 71d9329e..fec3d825 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -6299,6 +6299,9 @@ pub fn check_derivation( }, NodeKind::BindingProperty => check_binding_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::BindingRestElement | NodeKind::BindingRestProperty => check_binding_rest(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::TemplateElement => check_template_element(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::TemplateLiteral => check_template(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::TaggedTemplate => check_tagged(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::PrivateIdentifier => check_private(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::FieldDefinition => check_field(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ClassBody => check_class_body(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), @@ -15275,4 +15278,490 @@ fn check_class( Some((x, j, l)) } +// --------------------------------------------------------------------- +// Template literals (§13.2.8) and tagged templates (§13.3.11). +// --------------------------------------------------------------------- + +/// §13.2.8 a `TemplateElement`: one template token. +#[verifier::spinoff_prover] +fn check_template_element( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::TemplateElement) || !nd.children.is_empty() { + return None; + } + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let t = match toks.get(x) { + Some(t) => t, + None => { + return None; + }, + }; + proof { + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, x as int); + assert(t == &toks@[x as int]); + } + if !matches!(t.kind, TokKind::Template(_)) || t.end != nd.end { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(x.saturating_add(1) as int == x as int + 1); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].children.len() == 0); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + assert(g.ts.toks[x as int].end == t.end as int); + assert(g.ts.toks[x as int].kind == t.kind); + assert(g.ts.toks[x as int].start < g.ts.toks[x as int].end); + assert(span_ok(a, g.ts, m as int, x as int, x as int + 1)); + assert(d_expr_lhs(a, g.ts, m as int, g.cx, x as int, x as int + 1)); + lemma_ed_of(a, g.ts, m as int, x as int, x as int + 1); + } + Some((x, x.saturating_add(1), -100)) +} + +/// The last component of a template. +#[verifier::spinoff_prover] +proof fn lemma_dtemplate_last(a: AstV, ts: Stream, bound: int, ks: Seq, k: int, cx: Ctx, i: int, j: int) + requires + 0 <= k, + k + 1 == ks.len(), + j == i + 1, + kd(a, ks[k]) == NodeKind::TemplateElement, + dc(a, ts, bound, ks[k], cx, i, j), + if k == 0 { + is_kind(ts, i, TokKind::Template(TemplateKind::NoSubstitution)) + } else { + is_kind(ts, i, TokKind::Template(TemplateKind::Tail)) + }, + ensures + dtemplate(a, ts, bound, ks, k, cx, i, j), +{ +} + +/// A component before an expression and the rest of a template. +#[verifier::spinoff_prover] +proof fn lemma_dtemplate_step( + a: AstV, + ts: Stream, + bound: int, + ks: Seq, + k: int, + cx: Ctx, + i: int, + e: int, + j: int, +) + requires + 0 <= k, + k + 1 < ks.len(), + kd(a, ks[k]) == NodeKind::TemplateElement, + dc(a, ts, bound, ks[k], cx, i, i + 1), + if k == 0 { + is_kind(ts, i, TokKind::Template(TemplateKind::Head)) + } else { + is_kind(ts, i, TokKind::Template(TemplateKind::Middle)) + }, + lvl(a, ks[k + 1]) >= -1, + dc(a, ts, bound, ks[k + 1], cx, i + 1, e), + ed(a, ts, ks[k + 1], i + 1) == e, + dtemplate(a, ts, bound, ks, k + 2, cx, e, j), + ensures + dtemplate(a, ts, bound, ks, k, cx, i, j), +{ +} + +/// §13.2.8 `TemplateLiteral`. +#[verifier::spinoff_prover] +proof fn lemma_template_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, j: int) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + a.nodes[m].kind == NodeKind::TemplateLiteral, + dtemplate(a, ts, m, a.nodes[m].children, 0, cx, x, j), + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == 17, +{ + assert(span_ok(a, ts, m, x, j)); + assert(d_expr_lhs(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.2.8 `TemplateLiteral`: elements and substitutions alternate. +#[verifier::spinoff_prover] +fn check_template( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let len = nd.children.len(); + if !matches!(nd.kind, NodeKind::TemplateLiteral) || len == 0 || len % 2 == 0 { + return None; + } + let ghost a = arena_of(nodes@); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + } + let last_ix = len.saturating_sub(1); + let last = match kid_of(nodes, m, last_ix) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_l, hi_l, _) = match done_at(done, last) { + Some(r) => r, + None => { + return None; + }, + }; + let kl = kind_at(nodes, last); + let tk = match toks.get(lo_l) { + Some(t) => t, + None => { + return None; + }, + }; + proof { + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, lo_l as int); + assert(tk == &toks@[lo_l as int]); + } + let last_kind_ok = if last_ix == 0 { + matches!(tk.kind, TokKind::Template(TemplateKind::NoSubstitution)) + } else { + matches!(tk.kind, TokKind::Template(TemplateKind::Tail)) + }; + if !matches!(kl, NodeKind::TemplateElement) || !last_kind_ok || hi_l != lo_l.saturating_add(1) { + return None; + } + proof { + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, last as int, g.cx, last_ix as int); + assert(lo_l.saturating_add(1) as int == lo_l as int + 1); + assert(kd(a, last as int) == kl); + assert(lo_l < toks.len()); + let ks = a.nodes[m as int].children; + assert(dc(a, g.ts, m as int, last as int, g.cx, lo_l as int, hi_l as int)); + assert(g.ts.toks[lo_l as int].kind == tk.kind); + lemma_dtemplate_last(a, g.ts, m as int, ks, last_ix as int, g.cx, lo_l as int, hi_l as int); + } + let end = hi_l; + let mut k = last_ix; + let mut pos = lo_l; + while k > 0 + invariant + m < nodes.len(), + nodes@.len() == nodes.len(), + nd == &nodes@[m as int], + a == arena_of(nodes@), + len == nd.children.len(), + len == a.nodes[m as int].children.len(), + len % 2 == 1, + k < len, + k % 2 == 0, + end <= toks.len(), + pos < end, + tn(g.ts) == toks.len(), + ast_wf(a), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(a, done.cxs@, m as int, g.cx), + dtemplate(a, g.ts, m as int, a.nodes[m as int].children, k as int, g.cx, pos as int, end as int), + decreases k, + { + let ix_e = k.saturating_sub(2); + let ix_x = k.saturating_sub(1); + let el = match kid_of(nodes, m, ix_e) { + Some(c) => c, + None => { + return None; + }, + }; + let ex = match kid_of(nodes, m, ix_x) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_e, hi_e, _) = match done_at(done, el) { + Some(r) => r, + None => { + return None; + }, + }; + let (lo_x, hi_x, lv_x) = match done_at(done, ex) { + Some(r) => r, + None => { + return None; + }, + }; + let tt = match toks.get(lo_e) { + Some(t) => t, + None => { + return None; + }, + }; + proof { + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, lo_e as int); + assert(tt == &toks@[lo_e as int]); + } + let el_kind_ok = if ix_e == 0 { + matches!(tt.kind, TokKind::Template(TemplateKind::Head)) + } else { + matches!(tt.kind, TokKind::Template(TemplateKind::Middle)) + }; + if !matches!(kind_at(nodes, el), NodeKind::TemplateElement) || !el_kind_ok + || hi_e != lo_e.saturating_add(1) || lo_x != hi_e || hi_x != pos || lv_x < -1 { + return None; + } + proof { + assert(k >= 2); + assert(ix_e as int == k as int - 2); + assert(ix_x as int == k as int - 1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, el as int, g.cx, k as int - 2); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, ex as int, g.cx, k as int - 1); + assert(lo_e.saturating_add(1) as int == lo_e as int + 1); + assert(kd(a, el as int) == NodeKind::TemplateElement); + assert(lvl(a, ex as int) >= -1); + assert(lo_e < toks.len()); + let ks = a.nodes[m as int].children; + assert(g.ts.toks[lo_e as int].kind == tt.kind); + assert(dc(a, g.ts, m as int, el as int, g.cx, lo_e as int, lo_e as int + 1)); + assert(dc(a, g.ts, m as int, ex as int, g.cx, lo_e as int + 1, pos as int)); + assert(ed(a, g.ts, ex as int, lo_e as int + 1) == pos as int); + lemma_dtemplate_step(a, g.ts, m as int, ks, k as int - 2, g.cx, lo_e as int, pos as int, end as int); + } + pos = lo_e; + k = k.saturating_sub(2); + } + let x = pos; + if !end_ok(src, nodes, toks, gaps, nd.end, end, Ghost(g)) { + return None; + } + let first = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if first != x || end <= x { + return None; + } + proof { + assert(k == 0); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_template_done(a, g.ts, g.cx, m as int, x as int, end as int); + } + Some((x, end, 17)) +} + +/// §13.3.11 `tag TemplateLiteral`. +#[verifier::spinoff_prover] +proof fn lemma_tagged_done(a: AstV, ts: Stream, cx: Ctx, m: int, t: int, l: int, x: int, mt: int, j: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= t < m, + 0 <= l < m, + a.nodes[m].kind == NodeKind::TaggedTemplate, + a.nodes[m].children =~= seq![t, l], + is_member_or_call(a, t), + kd(a, l) == NodeKind::TemplateLiteral, + node_done(a, ts, t, cx, x, mt), + node_done(a, ts, l, cx, mt, j), + 0 <= x < j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == (if lvl(a, t) == 17 { + 17int + } else { + 15int + }), +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == t); + assert(a.nodes[m].children[1] == l); + assert(dc(a, ts, m, t, cx, x, mt)); + assert(dc(a, ts, m, l, cx, mt, j)); + assert(d_expr_lhs(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.3.11 `TaggedTemplate`. +#[verifier::spinoff_prover] +fn check_tagged( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::TaggedTemplate) || nd.children.len() != 2 { + return None; + } + let t = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let l = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let (lo_t, mt, lv_t) = match done_at(done, t) { + Some(r) => r, + None => { + return None; + }, + }; + let (lo_l, j, _) = match done_at(done, l) { + Some(r) => r, + None => { + return None; + }, + }; + if lo_t != x || !(lv_t == 17 || lv_t == 15) || lo_l != mt + || !matches!(kind_at(nodes, l), NodeKind::TemplateLiteral) + || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(a.nodes[m as int].children =~= seq![t as int, l as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, t as int, g.cx, 0); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, l as int, g.cx, 1); + assert(kd(a, l as int) == NodeKind::TemplateLiteral); + assert(is_member_or_call(a, t as int)); + lemma_tagged_done(a, g.ts, g.cx, m as int, t as int, l as int, x as int, mt as int, j as int); + } + let own: i32 = if lv_t == 17 { 17 } else { 15 }; + Some((x, j, own)) +} + } // verus! diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index e52aebcd..93684660 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -82,6 +82,12 @@ var c;", "(async a => await a);", "(async (a) => 1);", "function f() { function g() { return 1 } return g }", + "`a`;", + "`a${b}c`;", + "`${a}${b}`;", + "`a${b}c${d + 1}e${`n${f}`}`;", + "f`x${y}z`;", + "a.b`c`.d;", "class A {}", "class A extends B { }", "class A { m() {} static s(a) { return a } get g() { return 1 } set g(v) {} }", @@ -176,7 +182,7 @@ var c;", #[test] fn other_programs_are_unsupported_not_failed() { - for s in ["for (a, b;;) ;", "`a`;", "a?.b;"] { + for s in ["for (a, b;;) ;", "a?.b;"] { assert!( derivation(s, SourceGoal::Script) == Some(Derivation::Unsupported), "{s}" @@ -198,8 +204,7 @@ fn errors_are_still_errors() { fn what_the_check_costs() { let body = "(1 + 2 * 3) < 4 - 5 / 6 % 7;\n".repeat(60_000); let covered = cps(&body); - let stopped = cps(&format!("`a`; -{body}")); + let stopped = cps(&format!("a?.b;\n{body}")); let time = |src: &[u32]| { let t = Instant::now(); let r = parse_checked(src, SourceGoal::Script); From 2201facdd4dad3bac9b5a60e962a29de65f4c19d Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Thu, 19 Nov 2026 04:41:41 +0000 Subject: [PATCH 008/195] Check with and member-expression for-heads against the tokens (7.3) WithStatement (shares the while check), and a member expression as the head of a for-in or for-of. Verus: 332 verified. Verified share 1562 to 1568 of 1568 positive runs (100%); harness files stay 36 of 41. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 60 +++++++++++++++------ crates/clazel-js-syntax/tests/derivation.rs | 17 ++++++ 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index fec3d825..785a7f6c 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -6271,7 +6271,7 @@ pub fn check_derivation( NodeKind::DebuggerStatement => check_debugger(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ThrowStatement => check_throw(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::BreakStatement | NodeKind::ContinueStatement => check_jump(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), - NodeKind::WhileStatement => check_while(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::WhileStatement | NodeKind::WithStatement => check_while(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::DoWhileStatement => check_do_while(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::LabelledStatement => check_labelled(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::TryStatement => check_try(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), @@ -6707,7 +6707,10 @@ proof fn lemma_words2() cps("case"@) =~= seq![0x63u32, 0x61, 0x73, 0x65], cps("default"@) =~= seq![0x64u32, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74], cps("}"@) =~= seq![0x7Du32], + cps("with"@) =~= seq![0x77u32, 0x69, 0x74, 0x68], { + reveal_strlit("with"); + assert("with"@ =~= seq!['w', 'i', 't', 'h']); reveal_strlit("do"); reveal_strlit("while"); reveal_strlit("throw"); @@ -7489,10 +7492,10 @@ proof fn lemma_while_done( 0 <= m < a.nodes.len(), 0 <= t < m, 0 <= c < m, - a.nodes[m].kind == NodeKind::WhileStatement, + a.nodes[m].kind == NodeKind::WhileStatement || a.nodes[m].kind == NodeKind::WithStatement, a.nodes[m].children =~= seq![t, c], - is_kw(ts, x, "while"@), is_p(ts, x + 1, "("@), + is_kw(ts, x, if a.nodes[m].kind == NodeKind::WhileStatement { "while"@ } else { "with"@ }), lvl(a, t) >= -1, node_done(a, ts, t, cx, x + 2, mt), is_p(ts, mt, ")"@), @@ -7513,12 +7516,20 @@ proof fn lemma_while_done( assert(ed(a, ts, t, x + 2) == mt); assert(a.nodes[m].children.len() == 2); assert(is_p(ts, mt, ")"@)); - assert(d_stmt(a, ts, m, cx, x, j)); + if a.nodes[m].kind == NodeKind::WhileStatement { + assert(is_kw(ts, x, "while"@)); + assert(d_stmt(a, ts, m, cx, x, j)); + } else { + assert(a.nodes[m].kind == NodeKind::WithStatement); + assert(is_kw(ts, x, "with"@)); + assert(d_stmt(a, ts, m, cx, x, j)); + } lemma_ed_of(a, ts, m, x, j); } /// §14.7.3 `while ( Expression ) Statement`. #[verifier::spinoff_prover] +#[verifier::rlimit(100)] fn check_while( src: &[u32], nodes: &[Node], @@ -7558,7 +7569,7 @@ fn check_while( return None; }, }; - if !matches!(nd.kind, NodeKind::WhileStatement) || nd.children.len() != 2 { + if !matches!(nd.kind, NodeKind::WhileStatement | NodeKind::WithStatement) || nd.children.len() != 2 { return None; } let t = match kid_of(nodes, m, 0) { @@ -7595,7 +7606,12 @@ fn check_while( if !c_ok || lv_t < -1 || lo_t != x.saturating_add(2) || lo_c != mt.saturating_add(1) { return None; } - if !word_at(src, nodes, toks, gaps, x, &[0x77, 0x68, 0x69, 0x6C, 0x65], Ghost(GW { g, w: "while"@ })) + let kw_ok = if matches!(nd.kind, NodeKind::WhileStatement) { + word_at(src, nodes, toks, gaps, x, &[0x77, 0x68, 0x69, 0x6C, 0x65], Ghost(GW { g, w: "while"@ })) + } else { + word_at(src, nodes, toks, gaps, x, &[0x77, 0x69, 0x74, 0x68], Ghost(GW { g, w: "with"@ })) + }; + if !kw_ok || !punct_at(src, nodes, toks, gaps, x.saturating_add(1), 0x28, Ghost(GW { g, w: "("@ })) || !punct_at(src, nodes, toks, gaps, mt, 0x29, Ghost(GW { g, w: ")"@ })) || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { @@ -7618,6 +7634,11 @@ fn check_while( lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 1); assert(lvl(a, t as int) >= -1); assert(is_statement_kind(kd(a, c as int))); + if matches!(nd.kind, NodeKind::WhileStatement) { + assert(is_kw(g.ts, x as int, "while"@)); + } else { + assert(is_kw(g.ts, x as int, "with"@)); + } lemma_while_done(a, g.ts, g.cx, m as int, t as int, c as int, x as int, mt as int, j as int); } Some((x, j, -100)) @@ -11609,7 +11630,7 @@ fn check_for_in_of( let kh = kind_at(nodes, h); let decl = matches!(kh, NodeKind::ForDeclaration); // A head that is not a declaration is an identifier reference, not `let` (`async` for `of`). - let head_ok = decl || (matches!(kh, NodeKind::IdentifierReference) + let head_ok = decl || (matches!(kh, NodeKind::IdentifierReference | NodeKind::MemberExpression) && not_word_at(src, nodes, toks, gaps, s, &[0x6C, 0x65, 0x74], Ghost(GW { g, w: "let"@ })) && (!sh.of || not_word_at(src, nodes, toks, gaps, s, &[0x61, 0x73, 0x79, 0x6E, 0x63], Ghost(GW { g, w: "async"@ })))); let head_first_ok = if decl { @@ -11618,12 +11639,15 @@ fn check_for_in_of( None => false, } } else { - match nodes.get(h) { - Some(hn) => hn.children.is_empty(), - None => false, + match kid_of(nodes, h, 0) { + Some(c) => !matches!(kind_at(nodes, c), NodeKind::VariableDeclaration), + None => match nodes.get(h) { + Some(hn) => hn.children.is_empty(), + None => false, + }, } }; - let (lo_h, mh, _) = match done_at(done, h) { + let (lo_h, mh, lv_h) = match done_at(done, h) { Some(r) => r, None => { return None; @@ -11647,7 +11671,7 @@ fn check_for_in_of( word_at(src, nodes, toks, gaps, mh, &[0x69, 0x6E], Ghost(GW { g, w: "in"@ })) }; let e_ok = if sh.of { lv_e >= 0 } else { lv_e >= -1 }; - if !head_ok || !head_first_ok || lo_h != s || !kw_ok || !e_ok || lo_e != mh.saturating_add(1) + if !head_ok || !head_first_ok || (!decl && lv_h < 14) || lo_h != s || !kw_ok || !e_ok || lo_e != mh.saturating_add(1) || !punct_at(src, nodes, toks, gaps, q, 0x29, Ghost(GW { g, w: ")"@ })) || !stmt_kind_exec(kind_at(nodes, b)) || lo_b != q.saturating_add(1) || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { @@ -11683,8 +11707,10 @@ fn check_for_in_of( } // The head. if !decl { - assert(kd(a, h as int) == NodeKind::IdentifierReference); - assert(lvl(a, h as int) == 17); + assert(lvl(a, h as int) == lv_h as int); + assert(lvl(a, h as int) >= 14); + assert(kd(a, h as int) == NodeKind::IdentifierReference || kd(a, h as int) + == NodeKind::MemberExpression); assert(is_destructuring_target(a, h as int)); } assert(a.nodes[h as int] == nodes@[h as int]@); @@ -11698,9 +11724,11 @@ fn check_for_in_of( if decl { let hc = a.nodes[h as int].children[0]; assert(kid(kids(a, h as int), 0) == hc); - } else { - assert(a.nodes[h as int].children.len() == 0); + } else if a.nodes[h as int].children.len() == 0 { assert(kid(kids(a, h as int), 0) == -1int); + } else { + let hc = a.nodes[h as int].children[0]; + assert(kid(kids(a, h as int), 0) == hc); } } } diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index 93684660..0391462c 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -180,6 +180,23 @@ var c;", } } +/// Productions only a sloppy-mode `Script` has. +#[test] +fn covered_sloppy_programs_are_verified() { + for s in [ + "with (a) b;", + "with (a) { b = 1; }", + "for (a.b of c) ;", + "for (a.b.c in d) ;", + "for (x of y) with (x) z;", + ] { + assert!( + derivation(s, SourceGoal::Script) == Some(Derivation::Verified), + "{s}" + ); + } +} + #[test] fn other_programs_are_unsupported_not_failed() { for s in ["for (a, b;;) ;", "a?.b;"] { From a79d9350f4a02c9c7bbdafbe8ceadce72a8d1d07 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Thu, 19 Nov 2026 04:46:58 +0000 Subject: [PATCH 009/195] Check obj.#name against the tokens; document what the arena check covers (7.3) MemberExpression with a private name. The header of arena_d and of the crate now list the covered productions and what is not covered. Verus: 334 verified. Harness files 36 to 37 of 41; positive runs stay 1568 of 1568. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 180 ++++++++++++++++++-- crates/clazel-js-syntax/src/lib.rs | 15 +- crates/clazel-js-syntax/tests/derivation.rs | 2 +- 3 files changed, 175 insertions(+), 22 deletions(-) diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index 785a7f6c..3c321640 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -5,20 +5,25 @@ //! [`Derivation::Verified`] only if `derives_root` holds for it: every node //! derives the tokens it spans, bottom-up, in the context the root's goal gives. //! -//! **Covered:** a `Script` or `Module` of statements, in the one context of the -//! root: literals, parentheses, every binary level, unary, conditional and -//! assignment, member-dot, identifiers, arguments, calls, the comma operator, -//! spread, `this`/`null`/`true`/`false`; and the statements expression, empty, -//! `var`/`let`/`const` (no destructuring), block, `if`, `while`, `do`-`while`, -//! `throw`, `break`/`continue`, labelled, `try`/`catch`/`finally`, `switch` and -//! `debugger`, `return`; `for` (all heads); function declarations and expressions, generators, -//! `async` functions, arrow functions (simple parameters, defaults and `...rest` -//! of a name), `yield` and `await`. Each node is checked in the context its -//! parent's production gives it (`Done::cxs`, [`Cx5`]); the assignment is +//! **Covered:** a `Script` or `Module` whose nodes are: literals, identifiers, +//! parentheses, every binary level, unary, `++`/`--`, conditional, assignment +//! (with assignment patterns), member access (`.name`, `.#name`, `[expr]`), +//! arguments, calls, `new`, the comma operator, spread, array and object +//! literals (properties, methods, accessors, computed names), templates and tagged +//! templates, `this`/`null`/`true`/`false`, function and class declarations and +//! expressions (generators, `async`, arrows, methods, fields, static blocks, +//! private names), `yield` and `await`, binding patterns; and every statement of +//! §14 (`for` with declarations and identifier or member heads, `with`, +//! `switch`, `try`, labels, ...). Each node is checked in the context its +//! parent's production gives it (`Done::cxs`, [`Cx5`]: `[~In]` in a `for` head, +//! `cx_fn` in functions, `[+Await]` in a static block, ...); the assignment is //! untrusted and compared by the parent's check. For any other node the result is -//! [`Derivation::Unsupported`]: nothing is claimed. The `for` statements (their -//! heads are `[~In]`, which the checks do not take yet), destructuring, classes, -//! array and object literals, templates and modules have no checks yet. +//! [`Derivation::Unsupported`]: nothing is claimed. Not covered: optional chains, +//! `super`, `new.target`, `import(...)` and `import.meta`, patterns as `for` +//! heads, `for await`, the Annex B forms (`for (var x = 1 in o)`, function +//! declarations as statements), expressions and patterns inside `[~In]` heads +//! other than the simplest, `CoverInitializedName`, and modules' `import` and +//! `export`. //! //! [`crate::exec::parse_checked`] runs [`check_derivation_canon`] on every arena //! the parser builds, and rejects it if a covered node is `Failed`. @@ -6244,6 +6249,8 @@ pub fn check_derivation( return Derivation::Unsupported; } check_member_bracket(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + } else if matches!(nd.op, Op::PrivateDot) { + check_member_private(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) } else { check_member_dot(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) } @@ -15792,4 +15799,151 @@ fn check_tagged( Some((x, j, own)) } +// --------------------------------------------------------------------- +// `object.#name` (§13.3.2). +// --------------------------------------------------------------------- + +/// §13.3.2 `MemberExpression . PrivateIdentifier`. +#[verifier::spinoff_prover] +#[verifier::rlimit(100)] +proof fn lemma_member_private_done(a: AstV, ts: Stream, cx: Ctx, m: int, o: int, p: int, x: int, mo: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= o < m, + 0 <= p < m, + a.nodes[m].kind == NodeKind::MemberExpression, + a.nodes[m].op == Op::PrivateDot, + a.nodes[m].children =~= seq![o, p], + is_member_or_call(a, o), + kd(a, p) == NodeKind::PrivateIdentifier, + node_done(a, ts, o, cx, x, mo), + is_p(ts, mo, "."@), + node_done(a, ts, p, cx, mo + 1, mo + 2), + 0 <= x, + mo + 2 <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[mo + 1].end, + ensures + node_done(a, ts, m, cx, x, mo + 2), + lvl(a, m) == (if lvl(a, o) == 17 { + 17int + } else { + 15int + }), +{ + assert(span_ok(a, ts, m, x, mo + 2)); + assert(a.nodes[m].children[0] == o); + assert(a.nodes[m].children[1] == p); + assert(dc(a, ts, m, o, cx, x, mo)); + assert(dc(a, ts, m, p, cx, mo + 1, mo + 2)); + assert(d_expr_lhs(a, ts, m, cx, x, mo + 2)); + lemma_ed_of(a, ts, m, x, mo + 2); +} + +/// §13.3.2 `object . #name`. +#[verifier::spinoff_prover] +fn check_member_private( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::MemberExpression) || !matches!(nd.op, Op::PrivateDot) + || nd.children.len() != 2 { + return None; + } + let o = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let p = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let (lo_o, mo, lv_o) = match done_at(done, o) { + Some(r) => r, + None => { + return None; + }, + }; + let (lo_p, hi_p, _) = match done_at(done, p) { + Some(r) => r, + None => { + return None; + }, + }; + let mo1 = mo.saturating_add(1); + if lo_o != x || !(lv_o == 17 || lv_o == 15) || !matches!(kind_at(nodes, p), NodeKind::PrivateIdentifier) + || lo_p != mo1 || hi_p != mo.saturating_add(2) + || !punct_at(src, nodes, toks, gaps, mo, 0x2E, Ghost(GW { g, w: "."@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, hi_p, Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(mo1 as int == mo as int + 1); + assert(a.nodes[m as int].children =~= seq![o as int, p as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].op == nd.op); + assert(a.nodes[m as int].start == nd.start as int); + assert(a.nodes[m as int].end == nd.end as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, o as int, g.cx, 0); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, p as int, g.cx, 1); + assert(kd(a, p as int) == NodeKind::PrivateIdentifier); + assert(is_member_or_call(a, o as int)); + assert(hi_p as int == mo as int + 2); + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, hi_p as int - 1); + assert(g.ts.toks[mo as int + 1].end == nd.end as int); + lemma_member_private_done(a, g.ts, g.cx, m as int, o as int, p as int, x as int, mo as int); + } + let own: i32 = if lv_o == 17 { 17 } else { 15 }; + Some((x, hi_p, own)) +} + } // verus! diff --git a/crates/clazel-js-syntax/src/lib.rs b/crates/clazel-js-syntax/src/lib.rs index 82b96270..60cabe28 100644 --- a/crates/clazel-js-syntax/src/lib.rs +++ b/crates/clazel-js-syntax/src/lib.rs @@ -39,14 +39,13 @@ //! parse ([`contract::parse_ensures`]). So [`exec::parse`] does not implement //! [`api::JsParser`], and the crate stays at Tier 0. The first steps towards //! that proof are in [`arena_d`], a proven check of `spec::d` over the whole arena -//! against the tokens the parser consumed, for the productions it covers (a -//! `Script` or `Module` of empty and expression statements over literals, -//! parentheses and `+ - * / % < >`), run by [`exec::parse_checked`]; and in [`derive`]: rule lemmas that a node of the shape the parser -//! builds is derived by [`spec::d`] (literals, names, keywords, unary, binary, -//! conditional, assignment, parenthesized and member-dot expressions), and -//! `check_leaf`, a checked leaf against the executable tokens. They are not yet -//! applied to the parser's output, and they assume the tokens are the lexer -//! specification's, which the executable lexer does not meet yet. +//! against the tokens the parser consumed, for the productions it covers (every +//! statement and nearly every expression, function, class and pattern; the list is +//! at the top of the module, and 1568 of the 1568 vendored positive Test262 runs +//! are covered end to end), run by [`exec::parse_checked`]; and in [`derive`]: rule +//! lemmas that a node of the shape the parser builds is derived by [`spec::d`]. +//! The check assumes the tokens are the lexer specification's, which the +//! executable lexer does not meet yet, and that inserted `;` are justified. //! //! Where the parser differs from the specification, on purpose or not: //! diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index 0391462c..4144ae30 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -93,7 +93,7 @@ var c;", "class A { m() {} static s(a) { return a } get g() { return 1 } set g(v) {} }", "class A { *gen() { yield 1 } async am() { await 1 } async *ag() { yield 1 } }", "class A { x; y = 1; static z = 2; 'q' = 3; [k] = 4; }", - "class A { #p = 1; #m() {} static #s; get #g() { return 1 } }", + "class A { #p = 1; #m() {} static #s; get #g() { return this.#p } m(o) { return o.#p.x } }", "class A { ; ; m() {} ; }", "class A { static { a; } static { var x = 1; } }", "(class {}); (class B extends C {});", From 1cc14fc964e290321bc9c6c8a574d54d042dfc47 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 09:02:55 +0000 Subject: [PATCH 010/195] js-syntax: cover optional chains, super, new.target, import(), import.meta, for-await, Annex B heads, patterns in for heads and [~In] operands in the derivation check The remaining script syntax of item 7.3's whole-arena check. New checks in arena_e (meta properties, super, import(), optional chains); arena_d gets mixed contexts (cx_ok_t: bracketed operands are [+In]; cx_ok_init: initializers, consequents and a[b] properties) so pattern elements, calls, arguments, literals, conditionals and comma expressions work inside a [~In] head, for await, Annex B for (var x = 1 in o), patterns and declarations with pattern targets as for-in/of heads, and function declarations as if/label bodies. Verus: 357 verified, 0 errors. Mutate: 6 of 6 killed. Verified share: 1567/1567 script and 1/1 module positive runs, 41/41 harness files. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 767 +++++++++---- crates/clazel-js-syntax/src/arena_e.rs | 1129 +++++++++++++++++++ crates/clazel-js-syntax/src/lib.rs | 1 + crates/clazel-js-syntax/tests/derivation.rs | 70 +- crates/clazel-js-syntax/tests/test262.rs | 96 +- 5 files changed, 1861 insertions(+), 202 deletions(-) create mode 100644 crates/clazel-js-syntax/src/arena_e.rs diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index 3c321640..c441da9a 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -18,12 +18,13 @@ //! parent's production gives it (`Done::cxs`, [`Cx5`]: `[~In]` in a `for` head, //! `cx_fn` in functions, `[+Await]` in a static block, ...); the assignment is //! untrusted and compared by the parent's check. For any other node the result is -//! [`Derivation::Unsupported`]: nothing is claimed. Not covered: optional chains, -//! `super`, `new.target`, `import(...)` and `import.meta`, patterns as `for` -//! heads, `for await`, the Annex B forms (`for (var x = 1 in o)`, function -//! declarations as statements), expressions and patterns inside `[~In]` heads -//! other than the simplest, `CoverInitializedName`, and modules' `import` and -//! `export`. +//! [`Derivation::Unsupported`]: nothing is claimed. Also covered, in [`crate::arena_e`] +//! and here: optional chains, `super`, `new.target`, `import(...)`, `import.meta`, +//! patterns and Annex B forms as `for` heads, `for await`, function declarations as +//! statement bodies, and operands of `[~In]` heads (bracketed operands are `[+In]`: +//! `cx_ok_t`, `cx_ok_init`). `CoverInitializedName` never survives the early errors; its +//! assignment-pattern reading is covered. Not covered: `await`, `yield` and class +//! expressions inside `[~In]` heads, and modules' `import` and `export`. //! //! [`crate::exec::parse_checked`] runs [`check_derivation_canon`] on every arena //! the parser builds, and rejects it if a covered node is `Failed`. @@ -81,7 +82,7 @@ pub open spec fn arena_of(nodes: Seq) -> AstV { } /// `ed` of a node that spans tokens `lo..hi` is `hi`. -proof fn lemma_ed_of(a: AstV, ts: Stream, c: int, lo: int, hi: int) +pub(crate) proof fn lemma_ed_of(a: AstV, ts: Stream, c: int, lo: int, hi: int) requires toks_wf(ts), 0 <= c < a.nodes.len(), @@ -162,7 +163,7 @@ proof fn lemma_empty_statement_derives(a: AstV, ts: Stream, n: int, cx: Ctx, i: /// §16.1 and §16.2: a root whose items derive consecutive token ranges that make /// the whole stream. `dl` is built from the back. -proof fn lemma_dl_cons(a: AstV, ts: Stream, bound: int, ks: Seq, k: int, cx: Ctx, i: int, m: int, j: int) +pub(crate) proof fn lemma_dl_cons(a: AstV, ts: Stream, bound: int, ks: Seq, k: int, cx: Ctx, i: int, m: int, j: int) requires 0 <= k < ks.len(), ed(a, ts, ks[k], i) == m, @@ -424,7 +425,7 @@ fn op_slice(op: Op) -> (r: &'static [u32]) } /// The source text of the token is the code points `w`. -fn text_is(src: &[u32], t: &DTok, w: &[u32]) -> (r: bool) +pub(crate) fn text_is(src: &[u32], t: &DTok, w: &[u32]) -> (r: bool) requires t.start <= t.end <= src.len(), ensures @@ -497,10 +498,10 @@ fn tok_is_op(src: &[u32], t: &DTok, op: Op) -> (r: bool) } /// The index of the first element, named so that it is not read as a request for `first()`. -const ZERO: usize = 0; +pub(crate) const ZERO: usize = 0; /// The source text of the token is the one code point `code`. -fn text_is1(src: &[u32], t: &DTok, code: u32) -> (r: bool) +pub(crate) fn text_is1(src: &[u32], t: &DTok, code: u32) -> (r: bool) requires t.start <= t.end <= src.len(), ensures @@ -537,7 +538,7 @@ pub open spec fn op_code(op: Op) -> u32 { } /// The text of the punctuators the check reads, as code points. -proof fn lemma_punct_text() +pub(crate) proof fn lemma_punct_text() ensures cps(";"@) =~= seq![0x3Bu32], cps("("@) =~= seq![0x28u32], @@ -630,12 +631,24 @@ fn cx_eq(p: &Cx5, q: &Cx5) -> (r: bool) /// Node `m` is checked in `cx`, and so are all its children (the productions of /// the statements and expressions the check covers pass their context down). pub open spec fn cx_ok(a: AstV, cxs: Seq, m: int, cx: Ctx) -> bool { - 0 <= m < a.nodes.len() && m < cxs.len() && cx_of(cxs[m]) == cx && (forall|k: int| + kids_ok(a, cxs, m, cx) && cx_of(cxs[m]) == cx +} + +/// Every child of node `m` is checked in `cx` (the node itself is checked in another +/// context where its production gives its children `[+In]`: [`cx_ok_t`]). +pub open spec fn kids_ok(a: AstV, cxs: Seq, m: int, cx: Ctx) -> bool { + 0 <= m < a.nodes.len() && m < cxs.len() && (forall|k: int| 0 <= k < a.nodes[m].children.len() ==> 0 <= a.nodes[m].children[k] < cxs.len() && cx_of( cxs[#[trigger] a.nodes[m].children[k]], ) == cx) } +/// Node `m` is checked in `cx` and its children in `cx_in(cx, true)`: the +/// productions whose operands are in brackets, `[+In]` whatever the context. +pub open spec fn cx_ok_t(a: AstV, cxs: Seq, m: int, cx: Ctx) -> bool { + kids_ok(a, cxs, m, cx_in(cx, true)) && cx_of(cxs[m]) == cx +} + /// What a processed node `j < m` has proven: it derives tokens `lo[j]..hi[j]` in /// its context `cxs[j]`, and has the binding strength `lv[j]`. #[verifier::opaque] @@ -786,7 +799,7 @@ pub open spec fn env_ok( } /// The children of a node of a well-formed arena are before it. -proof fn lemma_child_before(a: AstV, m: int, k: int) +pub(crate) proof fn lemma_child_before(a: AstV, m: int, k: int) requires ast_wf(a), 0 <= m < a.nodes.len(), @@ -1652,7 +1665,7 @@ fn check_list( ls.m < nodes.len(), env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, ls.m as int), - cx_ok(arena_of(nodes@), done.cxs@, ls.m as int, g.cx), + kids_ok(arena_of(nodes@), done.cxs@, ls.m as int, g.cx), ensures match r { Some(e) => ls.start <= e && e <= toks.len() && dsep( @@ -1811,7 +1824,7 @@ fn check_list( ast_wf(a), env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(a, done.cxs@, m as int, g.cx), + kids_ok(a, done.cxs@, m as int, g.cx), dsep( a, g.ts, @@ -1929,13 +1942,12 @@ fn check_list( proof fn lemma_arguments_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) requires toks_wf(ts), - cx_in(cx, true) == cx, 0 <= m < a.nodes.len(), 0 <= x, e < tn(ts), x + 1 <= e, a.nodes[m].kind == NodeKind::Arguments, - dsep(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e, true), + dsep(a, ts, m, a.nodes[m].children, 0, cx_in(cx, true), x + 1, e, true), forall|k: int| 0 <= k < a.nodes[m].children.len() ==> list_item_ok( a, @@ -1982,10 +1994,9 @@ fn check_arguments( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + cx_ok_t(arena_of(nodes@), done.cxs@, m as int, g.cx), ensures match r { Some((l0, h0, l)) => node_done( @@ -2028,8 +2039,9 @@ fn check_arguments( != nd.start { return None; } + let ghost gt = GCx { ts: g.ts, cx: cx_in(g.cx, true) }; let ls = ListSpec { m, start: x.saturating_add(1), mode: 1, trail: true }; - let e = match check_list(src, nodes, toks, gaps, done, &ls, Ghost(g)) { + let e = match check_list(src, nodes, toks, gaps, done, &ls, Ghost(gt)) { Some(e) => e, None => { return None; @@ -2069,7 +2081,7 @@ fn check_arguments( assert(e < toks.len()); assert(x as int + 1 <= e as int) by { // The list starts at x + 1 and ends at e; its items lie between. - assert(dsep(a, g.ts, m as int, a.nodes[m as int].children, 0, g.cx, x as int + 1, e as int, true)); + assert(dsep(a, g.ts, m as int, a.nodes[m as int].children, 0, cx_in(g.cx, true), x as int + 1, e as int, true)); } lemma_arguments_done(a, g.ts, g.cx, m as int, x as int, e as int); } @@ -2304,7 +2316,6 @@ fn check_expression( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), @@ -2544,7 +2555,7 @@ fn check_spread( } /// The words `this`, `null`, `true` and `false`, as code points. -proof fn lemma_literal_words() +pub(crate) proof fn lemma_literal_words() ensures cps("this"@) =~= seq![0x74u32, 0x68, 0x69, 0x73], cps("null"@) =~= seq![0x6Eu32, 0x75, 0x6C, 0x6C], @@ -2683,7 +2694,7 @@ fn check_keyword_leaf( /// An `Absent` node at token position `p` of the check: placed where the production /// has the optional symbol (`spec::span_ok`, `spec::d`). -fn check_absent( +pub(crate) fn check_absent( src: &[u32], nodes: &[Node], toks: &[DTok], @@ -2770,7 +2781,7 @@ fn check_absent( /// The end of a statement that ends with `;`: a real `;` at token `hc`, or one /// inserted in the gap before it; `end` is where the statement's last token ends. -fn find_semi( +pub(crate) fn find_semi( src: &[u32], nodes: &[Node], toks: &[DTok], @@ -2875,6 +2886,7 @@ proof fn lemma_binding_done( j: int, with_init: bool, lo_i: int, + ci: Ctx, ) requires toks_wf(ts), @@ -2882,7 +2894,14 @@ proof fn lemma_binding_done( 0 <= t < m, 0 <= init < m, a.nodes[m].kind == NodeKind::VariableDeclaration || a.nodes[m].kind - == NodeKind::LexicalBinding || ((a.nodes[m].kind == NodeKind::BindingElement || a.nodes[m].kind == NodeKind::AssignmentElement) && cx_in(cx, true) == cx), + == NodeKind::LexicalBinding || a.nodes[m].kind == NodeKind::BindingElement + || a.nodes[m].kind == NodeKind::AssignmentElement, + ci == (if a.nodes[m].kind == NodeKind::BindingElement || a.nodes[m].kind + == NodeKind::AssignmentElement { + cx_in(cx, true) + } else { + cx + }), a.nodes[m].children =~= seq![t, init], if a.nodes[m].kind == NodeKind::AssignmentElement { is_destructuring_target(a, t) } else { is_binding_target_kind(kd(a, t)) }, node_done(a, ts, t, cx, lo_t, mt), @@ -2896,12 +2915,12 @@ proof fn lemma_binding_done( a, ts, init, - cx, + ci, lo_i, j, ) } else { - kd(a, init) == NodeKind::Absent && (a.nodes[m].kind == NodeKind::BindingElement || a.nodes[m].kind == NodeKind::AssignmentElement || !is_binding_pattern_kind(kd(a, t))) && j == mt && d(a, ts, init, cx, mt, mt) && ed( + kd(a, init) == NodeKind::Absent && (a.nodes[m].kind == NodeKind::BindingElement || a.nodes[m].kind == NodeKind::AssignmentElement || !is_binding_pattern_kind(kd(a, t))) && j == mt && d(a, ts, init, ci, mt, mt) && ed( a, ts, init, @@ -2922,12 +2941,12 @@ proof fn lemma_binding_done( assert("="@ =~= seq!['=']); assert(is_p(ts, mt, "="@)); assert(is_assign_expr(a, init)); - assert(dc(a, ts, m, init, cx, lo_i, j)); - assert(d_init(a, ts, m, init, cx, mt, j, false)); - assert(d_init(a, ts, m, init, cx, mt, j, true)); + assert(dc(a, ts, m, init, ci, lo_i, j)); + assert(d_init(a, ts, m, init, ci, mt, j, false)); + assert(d_init(a, ts, m, init, ci, mt, j, true)); } else { - assert(dc(a, ts, m, init, cx, mt, mt)); - assert(d_init(a, ts, m, init, cx, mt, j, false)); + assert(dc(a, ts, m, init, ci, mt, mt)); + assert(d_init(a, ts, m, init, ci, mt, j, false)); } if a.nodes[m].kind == NodeKind::BindingElement || a.nodes[m].kind == NodeKind::AssignmentElement { assert(d_pat(a, ts, m, cx, lo_t, j)); @@ -2950,10 +2969,20 @@ fn check_binding( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - (nodes@[m as int].kind == NodeKind::BindingElement || nodes@[m as int].kind == NodeKind::AssignmentElement) ==> cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + cx_ok_init( + arena_of(nodes@), + done.cxs@, + m as int, + g.cx, + if nodes@[m as int].kind == NodeKind::BindingElement || nodes@[m as int].kind + == NodeKind::AssignmentElement { + cx_in(g.cx, true) + } else { + g.cx + }, + ), ensures match r { Some((l0, h0, l)) => node_done( @@ -2977,6 +3006,12 @@ fn check_binding( || nd.children.len() != 2 { return None; } + let ghost ci: Ctx = if nd.kind == NodeKind::BindingElement || nd.kind == NodeKind::AssignmentElement { + cx_in(g.cx, true) + } else { + g.cx + }; + let ghost gi = GCx { ts: g.ts, cx: ci }; let t = match nd.children.as_slice().get(ZERO) { Some(x) => *x as usize, None => { @@ -3048,7 +3083,7 @@ fn check_binding( Some(x) => !matches!(x.kind, NodeKind::BindingIdentifier), None => true, }; - if pat || !check_absent(src, nodes, toks, gaps, init, mt, Ghost(g)) { + if pat || !check_absent(src, nodes, toks, gaps, init, mt, Ghost(gi)) { return None; } let prev = match toks.get(mt.saturating_sub(1)) { @@ -3062,7 +3097,7 @@ fn check_binding( } proof { let a = arena_of(nodes@); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, t as int, g.cx, 0); + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, t as int, g.cx, ci, 0); lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, lo_t as int); lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, mt as int - 1); assert(nd == &nodes@[m as int]); @@ -3079,7 +3114,7 @@ fn check_binding( assert(first.start as int == g.ts.toks[lo_t as int].start); assert(prev.end as int == g.ts.toks[mt as int - 1].end); assert(mt <= toks.len()); - lemma_binding_done(a, g.ts, g.cx, m as int, t as int, init as int, lo_t as int, mt as int, mt as int, false, 0); + lemma_binding_done(a, g.ts, g.cx, m as int, t as int, init as int, lo_t as int, mt as int, mt as int, false, 0, ci); } return Some((lo_t, mt, -100)); } @@ -3123,8 +3158,8 @@ fn check_binding( } proof { let a = arena_of(nodes@); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, t as int, g.cx, 0); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, init as int, g.cx, 1); + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, t as int, g.cx, ci, 0); + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, init as int, g.cx, ci, 1); lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, lo_t as int); lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, j as int - 1); assert(nd == &nodes@[m as int]); @@ -3146,10 +3181,10 @@ fn check_binding( assert(g.ts.toks[mt as int].kind == TokKind::Punctuator); assert(g.ts.toks[mt as int].text =~= seq![0x3Du32]); assert(lvl(a, init as int) >= 0); - assert(node_done(a, g.ts, init as int, g.cx, lo_i as int, j as int)); + assert(node_done(a, g.ts, init as int, ci, lo_i as int, j as int)); assert(mt < j); assert(j <= toks.len()); - lemma_binding_done(a, g.ts, g.cx, m as int, t as int, init as int, lo_t as int, mt as int, j as int, true, lo_i as int); + lemma_binding_done(a, g.ts, g.cx, m as int, t as int, init as int, lo_t as int, mt as int, j as int, true, lo_i as int, ci); } Some((lo_t, j, -100)) } @@ -3390,6 +3425,15 @@ fn stmt_kind_exec(k: NodeKind) -> (r: bool) ) } +/// A `Statement` kind or a `FunctionDeclaration`, executable (`spec::is_stmt_or_function`): the +/// body of an `if` clause (Annex B.3.3) or a label (§14.13, Annex B.3.1). +fn stmt_or_fn_exec(k: NodeKind) -> (r: bool) + ensures + r ==> (is_statement_kind(k) || k == NodeKind::FunctionDeclaration), +{ + stmt_kind_exec(k) || matches!(k, NodeKind::FunctionDeclaration) +} + /// A `StatementListItem` kind, executable (`spec::is_item_kind`). fn item_kind_exec(k: NodeKind) -> (r: bool) ensures @@ -3601,7 +3645,7 @@ proof fn lemma_block_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) } /// The brace texts as code points. -proof fn lemma_brace_text() +pub(crate) proof fn lemma_brace_text() ensures cps("{"@) =~= seq![0x7Bu32], cps("}"@) =~= seq![0x7Du32], @@ -3923,7 +3967,7 @@ fn check_if( }, }; let c_ok = match nodes.get(c) { - Some(x) => stmt_kind_exec(x.kind), + Some(x) => stmt_or_fn_exec(x.kind), None => false, }; let kw = match toks.get(x) { @@ -3976,7 +4020,7 @@ fn check_if( (q, 0) } else { let alt_ok = match nodes.get(alt) { - Some(x) => stmt_kind_exec(x.kind), + Some(x) => stmt_or_fn_exec(x.kind), None => false, }; let ej = match done.hi.get(alt) { @@ -4045,7 +4089,6 @@ fn check_if( assert(a.nodes[m as int].end == nd.end as int); assert(kd(a, c as int) == nodes@[c as int].kind); assert(kd(a, c as int) != NodeKind::Absent); - assert(is_statement_kind(kd(a, c as int))); assert(is_stmt_or_function(a, c as int)); assert(last.end as int == g.ts.toks[j as int - 1].end); assert(kw.start as int == g.ts.toks[x as int].start); @@ -4065,7 +4108,6 @@ fn check_if( lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, q as int); assert(q < toks.len()); assert(kd(a, alt as int) == nodes@[alt as int].kind); - assert(is_statement_kind(kd(a, alt as int))); assert(is_stmt_or_function(a, alt as int)); assert(kd(a, alt as int) != NodeKind::Absent); lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, alt as int, g.cx, 2); @@ -4273,7 +4315,6 @@ proof fn lemma_conditional_done( ) requires toks_wf(ts), - cx_in(cx, true) == cx, 0 <= m < a.nodes.len(), 0 <= t < m, 0 <= c < m, @@ -4284,7 +4325,7 @@ proof fn lemma_conditional_done( lvl(a, c) >= 0, lvl(a, e) >= 0, node_done(a, ts, t, cx, lo_t, mt), - node_done(a, ts, c, cx, lo_c, mc), + node_done(a, ts, c, cx_in(cx, true), lo_c, mc), node_done(a, ts, e, cx, lo_e, j), lo_c == mt + 1, lo_e == mc + 1, @@ -4321,10 +4362,9 @@ fn check_conditional( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + cx_ok_init(arena_of(nodes@), done.cxs@, m as int, g.cx, cx_in(g.cx, true)), ensures match r { Some((l0, h0, l)) => node_done( @@ -4484,9 +4524,9 @@ fn check_conditional( assert(a.nodes[m as int].children[1] == c as int); assert(a.nodes[m as int].children[2] == e as int); } - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, t as int, g.cx, 0); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 1); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, e as int, g.cx, 2); + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, t as int, g.cx, cx_in(g.cx, true), 0); + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, cx_in(g.cx, true), 1); + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, e as int, g.cx, cx_in(g.cx, true), 2); lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, lo_t as int); lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, j as int - 1); assert(mt < toks.len()); @@ -4946,7 +4986,7 @@ fn check_member_dot( } /// Node `j < m`, the child `k` of node `m` checked in `cx`, is done (`inv`). -proof fn lemma_inv_get( +pub(crate) proof fn lemma_inv_get( a: AstV, ts: Stream, cxs: Seq, @@ -4960,7 +5000,7 @@ proof fn lemma_inv_get( ) requires inv(a, ts, cxs, lo, hi, lv, m), - cx_ok(a, cxs, m, cx), + kids_ok(a, cxs, m, cx), 0 <= j < m, 0 <= k < a.nodes[m].children.len(), a.nodes[m].children[k] == j, @@ -4978,8 +5018,81 @@ proof fn lemma_inv_get( } } +/// Node `m` is checked in `cx`, its second child (the initializer of a pattern +/// element) in `ci`, and every other child in `cx`: the productions with an +/// `Initializer[+In]` inside a `[~In]` head. +pub open spec fn cx_ok_init(a: AstV, cxs: Seq, m: int, cx: Ctx, ci: Ctx) -> bool { + 0 <= m < a.nodes.len() && m < cxs.len() && cx_of(cxs[m]) == cx && (forall|k: int| + 0 <= k < a.nodes[m].children.len() ==> 0 <= a.nodes[m].children[k] < cxs.len() && cx_of( + cxs[#[trigger] a.nodes[m].children[k]], + ) == (if k == 1 { + ci + } else { + cx + })) +} + +/// [`lemma_inv_get`] for a node under [`cx_ok_init`]. +pub(crate) proof fn lemma_inv_get_init( + a: AstV, + ts: Stream, + cxs: Seq, + lo: Seq, + hi: Seq, + lv: Seq, + m: int, + j: int, + cx: Ctx, + ci: Ctx, + k: int, +) + requires + inv(a, ts, cxs, lo, hi, lv, m), + cx_ok_init(a, cxs, m, cx, ci), + 0 <= j < m, + 0 <= k < a.nodes[m].children.len(), + a.nodes[m].children[k] == j, + ensures + kd(a, j) != NodeKind::Absent ==> node_done( + a, + ts, + j, + if k == 1 { + ci + } else { + cx + }, + lo[j] as int, + hi[j] as int, + ), + lvl(a, j) != -100 ==> node_done( + a, + ts, + j, + if k == 1 { + ci + } else { + cx + }, + lo[j] as int, + hi[j] as int, + ), + lv[j] as int == lvl(a, j), +{ + reveal(inv); + assert(cx_of(cxs[a.nodes[m].children[k]]) == (if k == 1 { + ci + } else { + cx + })); + assert(lv[j] as int == lvl(a, j)); + if kd(a, j) == NodeKind::Absent { + assert(lvl(a, j) == -100); + } +} + /// Token `k` of the executable tokens is the specification's. -proof fn lemma_env_tok(src: Seq, nodes: Seq, toks: Seq, gaps: Seq, ts: Stream, k: int) +pub(crate) proof fn lemma_env_tok(src: Seq, nodes: Seq, toks: Seq, gaps: Seq, ts: Stream, k: int) requires env_ok(src, nodes, toks, gaps, ts), 0 <= k < toks.len(), @@ -4990,7 +5103,7 @@ proof fn lemma_env_tok(src: Seq, nodes: Seq, toks: Seq, gaps: S } /// The specification's tokens are not empty and their ends increase. -proof fn lemma_env_toks_wf(src: Seq, nodes: Seq, toks: Seq, gaps: Seq, ts: Stream) +pub(crate) proof fn lemma_env_toks_wf(src: Seq, nodes: Seq, toks: Seq, gaps: Seq, ts: Stream) requires env_ok(src, nodes, toks, gaps, ts), ensures @@ -5177,12 +5290,11 @@ proof fn lemma_paren_done( ) requires toks_wf(ts), - cx_in(cx, true) == cx, 0 <= m < a.nodes.len(), 0 <= c < m, a.nodes[m].kind == NodeKind::ParenthesizedExpression, a.nodes[m].children =~= seq![c], - node_done(a, ts, c, cx, lo_c, hc), + node_done(a, ts, c, cx_in(cx, true), lo_c, hc), lvl(a, c) >= -1, 1 <= lo_c, hc < tn(ts), @@ -5291,10 +5403,9 @@ fn check_paren( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + cx_ok_t(arena_of(nodes@), done.cxs@, m as int, g.cx), ensures match r { Some((l0, h0, l)) => node_done(arena_of(nodes@), g.ts, m as int, g.cx, l0 as int, h0 as int) @@ -5379,7 +5490,7 @@ fn check_paren( assert(a.nodes[m as int].children.len() == 1); assert(a.nodes[m as int].children[0] == c as int); } - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 0); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, cx_in(g.cx, true), 0); assert(a.nodes[m as int].kind == nd.kind); assert(a.nodes[m as int].start == nd.start as int); assert(a.nodes[m as int].end == nd.end as int); @@ -5826,6 +5937,7 @@ fn check_root( /// (`gaps.len() == toks.len() + 1`). Proven: `Verified` implies /// `derives_root(ast, ts, goal)` for every stream `ts` that is the executable /// one (`stream_matches`), which is the assumption; see the module header. +#[verifier::rlimit(400)] pub fn check_derivation( src: &[u32], nodes: &[Node], @@ -6041,6 +6153,63 @@ pub fn check_derivation( assert(nd == &nodes@[m as int]); } check_static_block(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + } else if matches!( + nd.kind, + NodeKind::VariableDeclaration | NodeKind::LexicalBinding | NodeKind::BindingElement + | NodeKind::AssignmentElement | NodeKind::AssignmentProperty + ) { + // A binding or pattern element has an `Initializer[+In]`; a declaration has `[?In]`. + let own_init = matches!(nd.kind, NodeKind::BindingElement | NodeKind::AssignmentElement) + || (matches!(nd.kind, NodeKind::AssignmentProperty) && matches!(nd.op, Op::Shorthand)); + let ci = cx5_in(&cxm); + let c1 = if own_init { ci } else { cxm }; + if !kids_init(nodes, done.cxs.as_slice(), m, &cxm, &c1) { + return Derivation::Unsupported; + } + proof { + assert(nd == &nodes@[m as int]); + } + if matches!(nd.kind, NodeKind::AssignmentProperty) { + check_assignment_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + } else { + check_binding(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + } + } else if matches!(nd.kind, NodeKind::ConditionalExpression) + || (matches!(nd.kind, NodeKind::MemberExpression) && matches!(nd.op, Op::Bracket)) + { + // The second child (the consequent, the bracketed property) is `[+In]`. + let ci = cx5_in(&cxm); + if !kids_init(nodes, done.cxs.as_slice(), m, &cxm, &ci) { + return Derivation::Unsupported; + } + proof { + assert(nd == &nodes@[m as int]); + } + if matches!(nd.kind, NodeKind::ConditionalExpression) { + check_conditional(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + } else { + check_member_bracket(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + } + } else if matches!( + nd.kind, + NodeKind::ParenthesizedExpression | NodeKind::Arguments | NodeKind::ArrayLiteral + | NodeKind::ObjectLiteral | NodeKind::TemplateLiteral + ) { + // Operands in brackets are `[+In]` whatever the context of the node. + let ct = cx5_in(&cxm); + if !kids_cx_t(nodes, done.cxs.as_slice(), m, &cxm, &ct) { + return Derivation::Unsupported; + } + proof { + assert(nd == &nodes@[m as int]); + } + match nd.kind { + NodeKind::ParenthesizedExpression => check_paren(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::Arguments => check_arguments(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ArrayLiteral => check_array(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ObjectLiteral => check_object(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + _ => check_template(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + } } else if is_arrow { let is_async = matches!(nd.kind, NodeKind::AsyncArrowFunction); if nd.children.len() != 2 { @@ -6099,7 +6268,15 @@ pub fn check_derivation( | NodeKind::BooleanLiteral | NodeKind::UnaryExpression | NodeKind::AssignmentExpression | NodeKind::MemberExpression | NodeKind::VariableDeclaration | NodeKind::LexicalBinding | NodeKind::VariableDeclarationList | NodeKind::ForDeclaration | NodeKind::LexicalDeclaration - | NodeKind::UpdateExpression + | NodeKind::UpdateExpression | NodeKind::NewTarget | NodeKind::ImportMeta + | NodeKind::SuperProperty | NodeKind::SuperCall | NodeKind::OptionalChain + | NodeKind::OptionalExpression | NodeKind::ArrayBindingPattern + | NodeKind::ObjectBindingPattern | NodeKind::ArrayAssignmentPattern + | NodeKind::ObjectAssignmentPattern | NodeKind::BindingProperty + | NodeKind::BindingRestElement | NodeKind::BindingRestProperty + | NodeKind::AssignmentRestElement | NodeKind::AssignmentRestProperty + | NodeKind::Elision | NodeKind::CallExpression | NodeKind::NewExpression + | NodeKind::TaggedTemplate | NodeKind::Expression ); if !plain && !any_ctx { return Derivation::Unsupported; @@ -6113,15 +6290,6 @@ pub fn check_derivation( } check_literal(nodes, toks, &done.by_start, m, Ghost(ts), Ghost(cx)) }, - NodeKind::ParenthesizedExpression => check_paren( - src, - nodes, - toks, - gaps, - &done, - m, - Ghost(GCx { ts, cx }), - ), NodeKind::AdditiveExpression | NodeKind::MultiplicativeExpression | NodeKind::ExponentiationExpression | NodeKind::ShiftExpression | NodeKind::EqualityExpression | NodeKind::BitwiseANDExpression | NodeKind::BitwiseXORExpression | NodeKind::BitwiseORExpression | NodeKind::LogicalANDExpression | NodeKind::LogicalORExpression | NodeKind::CoalesceExpression | NodeKind::RelationalExpression => check_binary( src, @@ -6162,15 +6330,6 @@ pub fn check_derivation( m, Ghost(GCx { ts, cx }), ), - NodeKind::VariableDeclaration | NodeKind::LexicalBinding | NodeKind::BindingElement => check_binding( - src, - nodes, - toks, - gaps, - &done, - m, - Ghost(GCx { ts, cx }), - ), NodeKind::VariableStatement | NodeKind::LexicalDeclaration => check_decl_stmt( src, nodes, @@ -6180,15 +6339,6 @@ pub fn check_derivation( m, Ghost(GCx { ts, cx }), ), - NodeKind::Arguments => check_arguments( - src, - nodes, - toks, - gaps, - &done, - m, - Ghost(GCx { ts, cx }), - ), NodeKind::CallExpression => check_call( src, nodes, @@ -6225,15 +6375,6 @@ pub fn check_derivation( m, Ghost(GCx { ts, cx }), ), - NodeKind::ConditionalExpression => check_conditional( - src, - nodes, - toks, - gaps, - &done, - m, - Ghost(GCx { ts, cx }), - ), NodeKind::AssignmentExpression => check_assign( src, nodes, @@ -6245,10 +6386,7 @@ pub fn check_derivation( ), NodeKind::MemberExpression => { if matches!(nd.op, Op::Bracket) { - if !plain { - return Derivation::Unsupported; - } - check_member_bracket(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + return Derivation::Unsupported; } else if matches!(nd.op, Op::PrivateDot) { check_member_private(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) } else { @@ -6289,8 +6427,6 @@ pub fn check_derivation( NodeKind::DefaultClause => check_default(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ReturnStatement => check_return(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::FormalParameters => check_params(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), - NodeKind::AssignmentElement => check_binding(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), - NodeKind::AssignmentProperty => check_assignment_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::AssignmentRestElement | NodeKind::AssignmentRestProperty => check_binding_rest(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ArrayBindingPattern | NodeKind::ObjectBindingPattern | NodeKind::ArrayAssignmentPattern | NodeKind::ObjectAssignmentPattern => { @@ -6307,7 +6443,6 @@ pub fn check_derivation( NodeKind::BindingProperty => check_binding_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::BindingRestElement | NodeKind::BindingRestProperty => check_binding_rest(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::TemplateElement => check_template_element(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), - NodeKind::TemplateLiteral => check_template(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::TaggedTemplate => check_tagged(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::PrivateIdentifier => check_private(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::FieldDefinition => check_field(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), @@ -6319,14 +6454,23 @@ pub fn check_derivation( } check_class(src, nodes, toks, gaps, &done, &sh, Ghost(GCx { ts, cx })) }, - NodeKind::ArrayLiteral => check_array(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), - NodeKind::ObjectLiteral => check_object(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::PropertyDefinition => check_property(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::ComputedPropertyName => check_computed(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::Elision => check_elision(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::FunctionRestParameter => check_rest_param(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::YieldExpression => check_yield(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::AwaitExpression => check_await(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::NewTarget | NodeKind::ImportMeta => crate::arena_e::check_meta(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::SuperProperty => crate::arena_e::check_super_prop(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::SuperCall => crate::arena_e::check_super_call(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ImportCall => { + if !plain { + return Derivation::Unsupported; + } + crate::arena_e::check_import_call(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) + }, + NodeKind::OptionalChain => crate::arena_e::check_chain_link(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::OptionalExpression => crate::arena_e::check_optional(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), _ => { return Derivation::Unsupported; }, @@ -6412,6 +6556,10 @@ fn assign_ctx(nodes: &[Node], module: bool) -> (r: Vec) let method = matches!(nd.kind, NodeKind::MethodDefinition); let ident = if method { matches!(nd.op, Op::AsyncMethod | Op::AsyncGeneratorMethod) + } else if matches!(nd.kind, NodeKind::AssignmentProperty) { + matches!(nd.op, Op::Shorthand) + } else if matches!(nd.kind, NodeKind::MemberExpression) { + matches!(nd.op, Op::Bracket) } else { arrow && child_kind_is(nodes, nd, 0, true) }; @@ -6496,6 +6644,13 @@ fn child_cx(kind: NodeKind, k: usize, p: &Cx5, ident: bool, braced: bool) -> (r: ) { return if k == 0 { cx5_noin(p) } else { *p }; } + // `a[b]`: the property is `[+In]` (`ident` is the bracket form); `a ? b : c`: so is `b`. + if matches!(kind, NodeKind::MemberExpression) { + return if k == 1 && ident { Cx5 { y: p.y, a: p.a, i: true, r: p.r, d: false } } else { *p }; + } + if matches!(kind, NodeKind::ConditionalExpression) { + return if k == 1 { Cx5 { y: p.y, a: p.a, i: true, r: p.r, d: false } } else { *p }; + } // These productions pass their own context to their children. if matches!( kind, @@ -6506,9 +6661,25 @@ fn child_cx(kind: NodeKind, k: usize, p: &Cx5, ident: bool, braced: bool) -> (r: | NodeKind::UnaryExpression | NodeKind::AssignmentExpression | NodeKind::MemberExpression | NodeKind::VariableDeclaration | NodeKind::LexicalBinding | NodeKind::VariableDeclarationList | NodeKind::LexicalDeclaration | NodeKind::ForDeclaration | NodeKind::UpdateExpression + | NodeKind::SuperProperty | NodeKind::SuperCall | NodeKind::OptionalChain + | NodeKind::OptionalExpression | NodeKind::ArrayBindingPattern + | NodeKind::ObjectBindingPattern | NodeKind::ArrayAssignmentPattern + | NodeKind::ObjectAssignmentPattern | NodeKind::BindingProperty + | NodeKind::BindingRestElement | NodeKind::BindingRestProperty + | NodeKind::AssignmentRestElement | NodeKind::AssignmentRestProperty + | NodeKind::CallExpression | NodeKind::NewExpression | NodeKind::TaggedTemplate + | NodeKind::Expression ) { return *p; } + // A pattern element's initializer is `[+In]`, its target the element's own. + if matches!(kind, NodeKind::BindingElement | NodeKind::AssignmentElement) { + return if k == 0 { *p } else { Cx5 { y: p.y, a: p.a, i: true, r: p.r, d: false } }; + } + // `ident` is a shorthand property: `{ a = 1 }`. + if matches!(kind, NodeKind::AssignmentProperty) { + return if k == 0 || !ident { *p } else { Cx5 { y: p.y, a: p.a, i: true, r: p.r, d: false } }; + } Cx5 { y: p.y, a: p.a, i: true, r: p.r, d: false } } @@ -6586,6 +6757,83 @@ fn kids_cx(nodes: &[Node], cxs: &[Cx5], m: usize, p: &Cx5) -> (r: bool) true } +/// Node `m` is checked in `c` and each of its children in `ct`, the `[+In]` context of `c` +/// (`cx_ok_t`): the productions whose operands are in brackets. +fn kids_cx_t(nodes: &[Node], cxs: &[Cx5], m: usize, c: &Cx5, ct: &Cx5) -> (r: bool) + requires + m < nodes.len(), + cxs.len() == nodes.len(), + ast_wf(arena_of(nodes@)), + cx_of(*ct) == cx_in(cx_of(*c), true), + ensures + r ==> cx_ok_t(arena_of(nodes@), cxs@, m as int, cx_of(*c)), +{ + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return false; + }, + }; + match cxs.get(m) { + Some(x) => { + if !cx_eq(x, c) { + return false; + } + }, + None => { + return false; + }, + } + let len = nd.children.len(); + let ghost a = arena_of(nodes@); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + } + let mut k: usize = 0; + while k < len + invariant + m < nodes.len(), + nodes@.len() == nodes.len(), + a == arena_of(nodes@), + ast_wf(a), + nd == &nodes@[m as int], + len == nd.children.len(), + len == a.nodes[m as int].children.len(), + k <= len, + cxs.len() == nodes.len(), + cx_of(*ct) == cx_in(cx_of(*c), true), + cx_of(cxs@[m as int]) == cx_of(*c), + forall|q: int| + 0 <= q < k ==> 0 <= #[trigger] a.nodes[m as int].children[q] < cxs.len() + && cx_of(cxs@[a.nodes[m as int].children[q]]) == cx_of(*ct), + decreases len - k, + { + let ch = match nd.children.as_slice().get(k) { + Some(x) => *x as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[k as int] == ch as int); + lemma_child_before(a, m as int, k as int); + } + let cc = match cxs.get(ch) { + Some(x) => x, + None => { + return false; + }, + }; + if !cx_eq(cc, ct) { + return false; + } + k = k.saturating_add(1); + } + true +} + /// The specification's token for an executable one: the fields the check reads, and /// the lexer's other fields (`name`, `legacy`, ...) left as the empty or false /// default; the productions the check covers read none of them. @@ -6699,7 +6947,7 @@ proof fn lemma_empty_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int) // --------------------------------------------------------------------- /// The words of those statements, as code points. -proof fn lemma_words2() +pub(crate) proof fn lemma_words2() ensures cps("do"@) =~= seq![0x64u32, 0x6F], cps("while"@) =~= seq![0x77u32, 0x68, 0x69, 0x6C, 0x65], @@ -6747,7 +6995,7 @@ proof fn lemma_words2() } /// Child `k` of node `m` of a well-formed arena, which is before `m`. -fn kid_of(nodes: &[Node], m: usize, k: usize) -> (r: Option) +pub(crate) fn kid_of(nodes: &[Node], m: usize, k: usize) -> (r: Option) requires m < nodes.len(), ast_wf(arena_of(nodes@)), @@ -6784,7 +7032,7 @@ fn kid_of(nodes: &[Node], m: usize, k: usize) -> (r: Option) } /// The kind of node `c`. -fn kind_at(nodes: &[Node], c: usize) -> (r: NodeKind) +pub(crate) fn kind_at(nodes: &[Node], c: usize) -> (r: NodeKind) requires c < nodes.len(), ensures @@ -6809,7 +7057,7 @@ fn kind_at(nodes: &[Node], c: usize) -> (r: NodeKind) } /// What the check recorded of node `c`: first token, one past the last, strength. -fn done_at(done: &Done, c: usize) -> (r: Option<(usize, usize, i32)>) +pub(crate) fn done_at(done: &Done, c: usize) -> (r: Option<(usize, usize, i32)>) ensures match r { Some((l, h, v)) => c < done.lo@.len() && c < done.hi@.len() && c < done.lv@.len() && l @@ -6839,7 +7087,7 @@ fn done_at(done: &Done, c: usize) -> (r: Option<(usize, usize, i32)>) } /// The token a node starts at. -fn start_tok( +pub(crate) fn start_tok( src: &[u32], nodes: &[Node], toks: &[DTok], @@ -6896,7 +7144,7 @@ pub struct GW { } /// Token `x` is the keyword `w` (`gw.w` as characters). -fn word_at( +pub(crate) fn word_at( src: &[u32], nodes: &[Node], toks: &[DTok], @@ -6936,7 +7184,7 @@ fn word_at( } /// Token `x` is the one-character punctuator `lit` (code point `code`). -fn punct_at( +pub(crate) fn punct_at( src: &[u32], nodes: &[Node], toks: &[DTok], @@ -6976,7 +7224,7 @@ fn punct_at( } /// No line terminator before token `x`. -fn no_nl_at( +pub(crate) fn no_nl_at( src: &[u32], nodes: &[Node], toks: &[DTok], @@ -7006,7 +7254,7 @@ fn no_nl_at( } /// The token before `j` ends where `e` says. -fn end_ok( +pub(crate) fn end_ok( src: &[u32], nodes: &[Node], toks: &[DTok], @@ -7039,7 +7287,7 @@ fn end_ok( } /// [`find_semi`] for the `;` after `do`-`while` (§12.10.1 rule 1, third condition). -fn find_semi_dw( +pub(crate) fn find_semi_dw( src: &[u32], nodes: &[Node], toks: &[DTok], @@ -7923,7 +8171,7 @@ fn check_labelled( return None; }, }; - let b_ok = stmt_kind_exec(kind_at(nodes, b)); + let b_ok = stmt_or_fn_exec(kind_at(nodes, b)); let l_ok = matches!(kind_at(nodes, l), NodeKind::LabelIdentifier); if !b_ok || !l_ok || lo_l != x || hi_l != x.saturating_add(1) || lo_b != x.saturating_add(2) { return None; @@ -7946,7 +8194,6 @@ fn check_labelled( assert(a.nodes[m as int].end == nd.end as int); lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, l as int, g.cx, 0); lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, b as int, g.cx, 1); - assert(is_statement_kind(kd(a, b as int))); assert(is_stmt_or_function(a, b as int)); lemma_labelled_done(a, g.ts, g.cx, m as int, l as int, b as int, x as int, j as int); } @@ -10673,7 +10920,7 @@ fn check_await( } /// The words `yield` and `await`, as code points. -proof fn lemma_words4() +pub(crate) proof fn lemma_words4() ensures cps("yield"@) =~= seq![0x79u32, 0x69, 0x65, 0x6C, 0x64], cps("await"@) =~= seq![0x61u32, 0x77, 0x61, 0x69, 0x74], @@ -10842,6 +11089,94 @@ fn cx5_noin(p: &Cx5) -> (r: Cx5) Cx5 { y: p.y, a: p.a, i: false, r: p.r, d: false } } +/// The same context with `[+In]` and `[Default]` cleared (`cx_in(cx, true)`). +fn cx5_in(p: &Cx5) -> (r: Cx5) + ensures + cx_of(r) == cx_in(cx_of(*p), true), +{ + Cx5 { y: p.y, a: p.a, i: true, r: p.r, d: false } +} + +/// Node `m` is checked in `c0`, its second child in `c1` (the initializer of a binding or +/// pattern element, the consequent of a conditional, the property of `a[b]`) and every other +/// child in `c0`: `cx_ok_init`. +fn kids_init(nodes: &[Node], cxs: &[Cx5], m: usize, c0: &Cx5, c1: &Cx5) -> (r: bool) + requires + m < nodes.len(), + cxs.len() == nodes.len(), + ast_wf(arena_of(nodes@)), + ensures + r ==> cx_ok_init(arena_of(nodes@), cxs@, m as int, cx_of(*c0), cx_of(*c1)), +{ + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return false; + }, + }; + match cxs.get(m) { + Some(x) => { + if !cx_eq(x, c0) { + return false; + } + }, + None => { + return false; + }, + } + let len = nd.children.len(); + let ghost a = arena_of(nodes@); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + } + let mut k: usize = 0; + while k < len + invariant + m < nodes.len(), + nodes@.len() == nodes.len(), + a == arena_of(nodes@), + ast_wf(a), + nd == &nodes@[m as int], + len == nd.children.len(), + len == a.nodes[m as int].children.len(), + k <= len, + cxs.len() == nodes.len(), + cx_of(cxs@[m as int]) == cx_of(*c0), + forall|q: int| + 0 <= q < k ==> 0 <= #[trigger] a.nodes[m as int].children[q] < cxs.len() + && cx_of(cxs@[a.nodes[m as int].children[q]]) == (if q == 1 { + cx_of(*c1) + } else { + cx_of(*c0) + }), + decreases len - k, + { + let ch = match nd.children.as_slice().get(k) { + Some(x) => *x as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[k as int] == ch as int); + lemma_child_before(a, m as int, k as int); + } + let cc = match cxs.get(ch) { + Some(x) => x, + None => { + return false; + }, + }; + if !cx_eq(cc, if k == 1 { c1 } else { c0 }) { + return false; + } + k = k.saturating_add(1); + } + true +} + /// The four children of node `m` are checked in `c0`..`c3`. pub open spec fn cx_kids4(a: AstV, cxs: Seq, m: int, c0: Ctx, c1: Ctx, c2: Ctx, c3: Ctx) -> bool { 0 <= m < a.nodes.len() && a.nodes[m].children.len() == 4 && (forall|k: int| @@ -11074,7 +11409,7 @@ proof fn lemma_for_decl_done(a: AstV, ts: Stream, cx: Ctx, m: int, c: int, x: in } else { a.nodes[m].op == Op::Const && is_kw(ts, x, "const"@) }, - kd(a, c) == NodeKind::BindingIdentifier, + is_binding_target_kind(kd(a, c)) || (a.nodes[m].op == Op::Var && kd(a, c) == NodeKind::VariableDeclaration), node_done(a, ts, c, cx, x + 1, j), x < j <= tn(ts), a.nodes[m].start == ts.toks[x].start, @@ -11156,7 +11491,12 @@ fn check_for_decl( return None; }, }; - if !kw_ok || !matches!(kind_at(nodes, c), NodeKind::BindingIdentifier) + let target_ok = match kind_at(nodes, c) { + NodeKind::BindingIdentifier | NodeKind::ObjectBindingPattern | NodeKind::ArrayBindingPattern => true, + NodeKind::VariableDeclaration => matches!(nd.op, Op::Var), + _ => false, + }; + if !kw_ok || !target_ok || lo_c != x.saturating_add(1) || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { return None; @@ -11490,6 +11830,7 @@ proof fn lemma_for_in_of_done( mh: int, q: int, j: int, + s: int, ) requires toks_wf(ts), @@ -11504,10 +11845,15 @@ proof fn lemma_for_in_of_done( NodeKind::ForInStatement }), a.nodes[m].children =~= seq![h, e, b], - !a.nodes[m].flag, + a.nodes[m].flag ==> (of && cx.await_ && is_kw(ts, x + 1, "await"@)), + s == (if a.nodes[m].flag { + x + 3 + } else { + x + 2 + }), is_kw(ts, x, "for"@), - is_p(ts, x + 1, "("@), - for_head_ok(a, ts, h, x + 2, of, false), + is_p(ts, s - 1, "("@), + for_head_ok(a, ts, h, s, of, a.nodes[m].flag), of ==> first_kid_kind(a, h) != NodeKind::VariableDeclaration, if of { is_assign_expr(a, e) @@ -11515,8 +11861,8 @@ proof fn lemma_for_in_of_done( lvl(a, e) >= -1 }, is_statement_kind(kd(a, b)), - d(a, ts, h, cx_in(cx, false), x + 2, mh), - ed(a, ts, h, x + 2) == mh, + d(a, ts, h, cx_in(cx, false), s, mh), + ed(a, ts, h, s) == mh, is_kw(ts, mh, if of { "of"@ } else { @@ -11537,7 +11883,7 @@ proof fn lemma_for_in_of_done( assert(a.nodes[m].children[0] == h); assert(a.nodes[m].children[1] == e); assert(a.nodes[m].children[2] == b); - assert(dc(a, ts, m, h, cx_in(cx, false), x + 2, mh)); + assert(dc(a, ts, m, h, cx_in(cx, false), s, mh)); assert(dc(a, ts, m, e, cx, mh + 1, q)); assert(dc(a, ts, m, b, cx, q + 1, j)); assert(d_stmt(a, ts, m, cx, x, j)); @@ -11593,6 +11939,7 @@ fn check_for_in_of( let m = sh.m; proof { lemma_words5(); + lemma_words4(); lemma_punct_text(); lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); } @@ -11602,9 +11949,15 @@ fn check_for_in_of( return None; }, }; - if nd.children.len() != 3 || nd.flag { + if nd.children.len() != 3 || (nd.flag && !sh.of) { return None; } + let cxm = match done.cxs.get(m) { + Some(c) => c, + None => { + return None; + }, + }; let h = match kid_of(nodes, m, 0) { Some(c) => c, None => { @@ -11629,20 +11982,33 @@ fn check_for_in_of( return None; }, }; + let flag = nd.flag; + // `for await (`: the `await` is the second token, the head starts after the `(`. + let s = if flag { x.saturating_add(3) } else { x.saturating_add(2) }; if !word_at(src, nodes, toks, gaps, x, &[0x66, 0x6F, 0x72], Ghost(GW { g, w: "for"@ })) - || !punct_at(src, nodes, toks, gaps, x.saturating_add(1), 0x28, Ghost(GW { g, w: "("@ })) { + || (flag && !(cxm.a && word_at(src, nodes, toks, gaps, x.saturating_add(1), &[0x61, 0x77, 0x61, 0x69, 0x74], Ghost(GW { g, w: "await"@ })))) + || !punct_at(src, nodes, toks, gaps, s.saturating_sub(1), 0x28, Ghost(GW { g, w: "("@ })) { return None; } - let s = x.saturating_add(2); let kh = kind_at(nodes, h); let decl = matches!(kh, NodeKind::ForDeclaration); - // A head that is not a declaration is an identifier reference, not `let` (`async` for `of`). - let head_ok = decl || (matches!(kh, NodeKind::IdentifierReference | NodeKind::MemberExpression) + let (lo_h, mh, lv_h) = match done_at(done, h) { + Some(r) => r, + None => { + return None; + }, + }; + // A head that is not a declaration is a `LeftHandSideExpression` that is not an object or + // array literal, or an assignment pattern; not `let` (`async` for `of`). + let lhs_ok = matches!(kh, NodeKind::ArrayAssignmentPattern | NodeKind::ObjectAssignmentPattern) + || (lv_h >= 14 && !matches!(kh, NodeKind::ObjectLiteral | NodeKind::ArrayLiteral)); + let head_ok = decl || (lhs_ok && not_word_at(src, nodes, toks, gaps, s, &[0x6C, 0x65, 0x74], Ghost(GW { g, w: "let"@ })) && (!sh.of || not_word_at(src, nodes, toks, gaps, s, &[0x61, 0x73, 0x79, 0x6E, 0x63], Ghost(GW { g, w: "async"@ })))); + // Only `for (var a = 1 in x)` (Annex B.3.5) has a `VariableDeclaration` in its head. let head_first_ok = if decl { match kid_of(nodes, h, 0) { - Some(c) => !matches!(kind_at(nodes, c), NodeKind::VariableDeclaration), + Some(c) => !sh.of || !matches!(kind_at(nodes, c), NodeKind::VariableDeclaration), None => false, } } else { @@ -11654,12 +12020,6 @@ fn check_for_in_of( }, } }; - let (lo_h, mh, lv_h) = match done_at(done, h) { - Some(r) => r, - None => { - return None; - }, - }; let (lo_e, q, lv_e) = match done_at(done, e) { Some(r) => r, None => { @@ -11678,7 +12038,7 @@ fn check_for_in_of( word_at(src, nodes, toks, gaps, mh, &[0x69, 0x6E], Ghost(GW { g, w: "in"@ })) }; let e_ok = if sh.of { lv_e >= 0 } else { lv_e >= -1 }; - if !head_ok || !head_first_ok || (!decl && lv_h < 14) || lo_h != s || !kw_ok || !e_ok || lo_e != mh.saturating_add(1) + if !head_ok || !head_first_ok || lo_h != s || !kw_ok || !e_ok || lo_e != mh.saturating_add(1) || !punct_at(src, nodes, toks, gaps, q, 0x29, Ghost(GW { g, w: ")"@ })) || !stmt_kind_exec(kind_at(nodes, b)) || lo_b != q.saturating_add(1) || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { @@ -11689,7 +12049,14 @@ fn check_for_in_of( assert(nd == &nodes@[m as int]); assert(a.nodes[m as int] == nodes@[m as int]@); assert(x.saturating_add(1) as int == x as int + 1); - assert(s as int == x as int + 2); + assert(a.nodes[m as int].flag == nd.flag); + assert(s as int == (if a.nodes[m as int].flag { + x as int + 3 + } else { + x as int + 2 + })); + assert(s.saturating_sub(1) as int == s as int - 1); + assert(cxm == &done.cxs@[m as int]); assert(mh.saturating_add(1) as int == mh as int + 1); assert(q.saturating_add(1) as int == q as int + 1); assert(a.nodes[m as int].children =~= seq![h as int, e as int, b as int]) by { @@ -11715,13 +12082,10 @@ fn check_for_in_of( // The head. if !decl { assert(lvl(a, h as int) == lv_h as int); - assert(lvl(a, h as int) >= 14); - assert(kd(a, h as int) == NodeKind::IdentifierReference || kd(a, h as int) - == NodeKind::MemberExpression); assert(is_destructuring_target(a, h as int)); } assert(a.nodes[h as int] == nodes@[h as int]@); - assert(for_head_ok(a, g.ts, h as int, x as int + 2, sh.of, false)) by { + assert(for_head_ok(a, g.ts, h as int, s as int, sh.of, a.nodes[m as int].flag)) by { if !decl { assert(!is_kw(g.ts, s as int, "let"@)); } @@ -11739,7 +12103,7 @@ fn check_for_in_of( } } } - lemma_for_in_of_done(a, g.ts, g.cx, m as int, h as int, e as int, b as int, sh.of, x as int, mh as int, q as int, j as int); + lemma_for_in_of_done(a, g.ts, g.cx, m as int, h as int, e as int, b as int, sh.of, x as int, mh as int, q as int, j as int, s as int); } Some((x, j, -100)) } @@ -11909,7 +12273,7 @@ fn check_array_items( ls.m < nodes.len(), env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, ls.m as int), - cx_ok(arena_of(nodes@), done.cxs@, ls.m as int, g.cx), + kids_ok(arena_of(nodes@), done.cxs@, ls.m as int, g.cx), ensures match r { Some(e) => ls.start <= e && e <= toks.len() && darray( @@ -12034,7 +12398,7 @@ fn check_array_items( ast_wf(a), env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(a, done.cxs@, m as int, g.cx), + kids_ok(a, done.cxs@, m as int, g.cx), darray(a, g.ts, m as int, a.nodes[m as int].children, k as int, g.cx, pos as int, e as int), forall|q: int| k <= q < len ==> array_item_mode_ok(a, #[trigger] a.nodes[m as int].children[q], ls.mode as int), @@ -12122,12 +12486,11 @@ fn check_array_items( proof fn lemma_array_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) requires toks_wf(ts), - cx_in(cx, true) == cx, 0 <= m < a.nodes.len(), 0 <= x, x + 1 <= e < tn(ts), a.nodes[m].kind == NodeKind::ArrayLiteral, - darray(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e), + darray(a, ts, m, a.nodes[m].children, 0, cx_in(cx, true), x + 1, e), forall|k: int| 0 <= k < a.nodes[m].children.len() ==> array_item_ok(a, #[trigger] a.nodes[m].children[k]), is_p(ts, x, "["@), @@ -12156,10 +12519,9 @@ fn check_array( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + cx_ok_t(arena_of(nodes@), done.cxs@, m as int, g.cx), ensures match r { Some((l0, h0, l)) => node_done( @@ -12195,8 +12557,9 @@ fn check_array( if !punct_at(src, nodes, toks, gaps, x, 0x5B, Ghost(GW { g, w: "["@ })) { return None; } + let ghost gt = GCx { ts: g.ts, cx: cx_in(g.cx, true) }; let als = ListSpec { m, start: x.saturating_add(1), mode: 0, trail: true }; - let e = match check_array_items(src, nodes, toks, gaps, done, &als, Ghost(g)) { + let e = match check_array_items(src, nodes, toks, gaps, done, &als, Ghost(gt)) { Some(e) => e, None => { return None; @@ -12223,7 +12586,7 @@ fn check_array( } /// The brackets `[` and `]`, as code points. -proof fn lemma_brackets() +pub(crate) proof fn lemma_brackets() ensures cps("["@) =~= seq![0x5Bu32], cps("]"@) =~= seq![0x5Du32], @@ -12239,12 +12602,11 @@ proof fn lemma_brackets() proof fn lemma_object_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, e: int) requires toks_wf(ts), - cx_in(cx, true) == cx, 0 <= m < a.nodes.len(), 0 <= x, x + 1 <= e < tn(ts), a.nodes[m].kind == NodeKind::ObjectLiteral, - dsep(a, ts, m, a.nodes[m].children, 0, cx, x + 1, e, true), + dsep(a, ts, m, a.nodes[m].children, 0, cx_in(cx, true), x + 1, e, true), forall|k: int| 0 <= k < a.nodes[m].children.len() ==> list_item_ok(a, #[trigger] a.nodes[m].children[k], 5), is_p(ts, x, "{"@), @@ -12281,10 +12643,9 @@ fn check_object( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + cx_ok_t(arena_of(nodes@), done.cxs@, m as int, g.cx), ensures match r { Some((l0, h0, l)) => node_done( @@ -12321,8 +12682,9 @@ fn check_object( if !punct_at(src, nodes, toks, gaps, x, 0x7B, Ghost(GW { g, w: "{"@ })) { return None; } + let ghost gt = GCx { ts: g.ts, cx: cx_in(g.cx, true) }; let ls = ListSpec { m, start: x.saturating_add(1), mode: 5, trail: true }; - let e = match check_list(src, nodes, toks, gaps, done, &ls, Ghost(g)) { + let e = match check_list(src, nodes, toks, gaps, done, &ls, Ghost(gt)) { Some(e) => e, None => { return None; @@ -13279,7 +13641,6 @@ proof fn lemma_assignment_property_done( ) requires toks_wf(ts), - cx_in(cx, true) == cx, 0 <= m < a.nodes.len(), 0 <= k0 < m, 0 <= k1 < m, @@ -13289,9 +13650,23 @@ proof fn lemma_assignment_property_done( if a.nodes[m].op == Op::Shorthand { kd(a, k0) == NodeKind::IdentifierReference && node_done(a, ts, k0, cx, x, x + 1) && ( if with_init { - is_p(ts, x + 1, "="@) && is_assign_expr(a, k1) && node_done(a, ts, k1, cx, x + 2, j) + is_p(ts, x + 1, "="@) && is_assign_expr(a, k1) && node_done( + a, + ts, + k1, + cx_in(cx, true), + x + 2, + j, + ) } else { - kd(a, k1) == NodeKind::Absent && j == x + 1 && d(a, ts, k1, cx, x + 1, x + 1) + kd(a, k1) == NodeKind::Absent && j == x + 1 && d( + a, + ts, + k1, + cx_in(cx, true), + x + 1, + x + 1, + ) }) } else { a.nodes[m].op == Op::KeyValue && is_prop_name_kind(kd(a, k0)) && kd(a, k1) @@ -13340,10 +13715,19 @@ fn check_assignment_property( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + cx_ok_init( + arena_of(nodes@), + done.cxs@, + m as int, + g.cx, + if nodes@[m as int].op == Op::Shorthand { + cx_in(g.cx, true) + } else { + g.cx + }, + ), ensures match r { Some((l0, h0, l)) => node_done( @@ -13371,6 +13755,7 @@ fn check_assignment_property( reveal_strlit("="); assert("="@ =~= seq!['=']); } + let ghost gi = GCx { ts: g.ts, cx: cx_in(g.cx, true) }; if !matches!(nd.kind, NodeKind::AssignmentProperty) || nd.children.len() != 2 { return None; } @@ -13407,7 +13792,7 @@ fn check_assignment_property( return None; } if matches!(kk1, NodeKind::Absent) { - if !check_absent(src, nodes, toks, gaps, k1, x1, Ghost(g)) { + if !check_absent(src, nodes, toks, gaps, k1, x1, Ghost(gi)) { return None; } (x1, false) @@ -13463,16 +13848,17 @@ fn check_assignment_property( assert(a.nodes[m as int].op == nd.op); assert(a.nodes[m as int].start == nd.start as int); assert(a.nodes[m as int].end == nd.end as int); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k0 as int, g.cx, 0); + let ci = if nd.op == Op::Shorthand { cx_in(g.cx, true) } else { g.cx }; + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k0 as int, g.cx, ci, 0); assert(kd(a, k0 as int) == kk0); assert(kd(a, k1 as int) == kk1); let mk: usize = if nd.op == Op::KeyValue { h0 } else { 0 }; if nd.op == Op::KeyValue { assert(h0.saturating_add(1) as int == h0 as int + 1); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int, g.cx, 1); + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int, g.cx, ci, 1); } else if with_init { assert(x.saturating_add(2) as int == x as int + 2); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int, g.cx, 1); + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, k1 as int, g.cx, ci, 1); assert(is_assign_expr(a, k1 as int)); } lemma_assignment_property_done(a, g.ts, g.cx, m as int, k0 as int, k1 as int, x as int, mk as int, j as int, with_init); @@ -13728,7 +14114,6 @@ proof fn lemma_member_bracket_done( ) requires toks_wf(ts), - cx_in(cx, true) == cx, 0 <= m < a.nodes.len(), 0 <= o < m, 0 <= p < m, @@ -13739,7 +14124,7 @@ proof fn lemma_member_bracket_done( node_done(a, ts, o, cx, x, mo), is_p(ts, mo, "["@), lvl(a, p) >= -1, - node_done(a, ts, p, cx, mo + 1, q), + node_done(a, ts, p, cx_in(cx, true), mo + 1, q), is_p(ts, q, "]"@), 0 <= x < q + 1 <= tn(ts), a.nodes[m].start == ts.toks[x].start, @@ -13774,10 +14159,9 @@ fn check_member_bracket( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + cx_ok_init(arena_of(nodes@), done.cxs@, m as int, g.cx, cx_in(g.cx, true)), ensures match r { Some((l0, h0, l)) => node_done( @@ -13854,8 +14238,8 @@ fn check_member_bracket( assert(a.nodes[m as int].op == nd.op); assert(a.nodes[m as int].start == nd.start as int); assert(a.nodes[m as int].end == nd.end as int); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, o as int, g.cx, 0); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, p as int, g.cx, 1); + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, o as int, g.cx, cx_in(g.cx, true), 0); + lemma_inv_get_init(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, p as int, g.cx, cx_in(g.cx, true), 1); assert(is_member_or_call(a, o as int)); lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, q as int); assert(g.ts.toks[q as int].end == nd.end as int); @@ -15450,10 +15834,9 @@ proof fn lemma_dtemplate_step( proof fn lemma_template_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, j: int) requires toks_wf(ts), - cx_in(cx, true) == cx, 0 <= m < a.nodes.len(), a.nodes[m].kind == NodeKind::TemplateLiteral, - dtemplate(a, ts, m, a.nodes[m].children, 0, cx, x, j), + dtemplate(a, ts, m, a.nodes[m].children, 0, cx_in(cx, true), x, j), 0 <= x < j <= tn(ts), a.nodes[m].start == ts.toks[x].start, a.nodes[m].end == ts.toks[j - 1].end, @@ -15479,10 +15862,9 @@ fn check_template( ) -> (r: Option<(usize, usize, i32)>) requires m < nodes.len(), - cx_in(g.cx, true) == g.cx, env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + cx_ok_t(arena_of(nodes@), done.cxs@, m as int, g.cx), ensures match r { Some((l0, h0, l)) => node_done( @@ -15496,6 +15878,7 @@ fn check_template( None => true, }, { + let ghost cxt = cx_in(g.cx, true); proof { lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); } @@ -15548,14 +15931,14 @@ fn check_template( return None; } proof { - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, last as int, g.cx, last_ix as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, last as int, cxt, last_ix as int); assert(lo_l.saturating_add(1) as int == lo_l as int + 1); assert(kd(a, last as int) == kl); assert(lo_l < toks.len()); let ks = a.nodes[m as int].children; - assert(dc(a, g.ts, m as int, last as int, g.cx, lo_l as int, hi_l as int)); + assert(dc(a, g.ts, m as int, last as int, cxt, lo_l as int, hi_l as int)); assert(g.ts.toks[lo_l as int].kind == tk.kind); - lemma_dtemplate_last(a, g.ts, m as int, ks, last_ix as int, g.cx, lo_l as int, hi_l as int); + lemma_dtemplate_last(a, g.ts, m as int, ks, last_ix as int, cxt, lo_l as int, hi_l as int); } let end = hi_l; let mut k = last_ix; @@ -15577,8 +15960,8 @@ fn check_template( ast_wf(a), env_ok(src@, nodes@, toks@, gaps@, g.ts), inv(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), - cx_ok(a, done.cxs@, m as int, g.cx), - dtemplate(a, g.ts, m as int, a.nodes[m as int].children, k as int, g.cx, pos as int, end as int), + kids_ok(a, done.cxs@, m as int, cxt), + dtemplate(a, g.ts, m as int, a.nodes[m as int].children, k as int, cxt, pos as int, end as int), decreases k, { let ix_e = k.saturating_sub(2); @@ -15630,18 +16013,18 @@ fn check_template( assert(k >= 2); assert(ix_e as int == k as int - 2); assert(ix_x as int == k as int - 1); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, el as int, g.cx, k as int - 2); - lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, ex as int, g.cx, k as int - 1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, el as int, cxt, k as int - 2); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, ex as int, cxt, k as int - 1); assert(lo_e.saturating_add(1) as int == lo_e as int + 1); assert(kd(a, el as int) == NodeKind::TemplateElement); assert(lvl(a, ex as int) >= -1); assert(lo_e < toks.len()); let ks = a.nodes[m as int].children; assert(g.ts.toks[lo_e as int].kind == tt.kind); - assert(dc(a, g.ts, m as int, el as int, g.cx, lo_e as int, lo_e as int + 1)); - assert(dc(a, g.ts, m as int, ex as int, g.cx, lo_e as int + 1, pos as int)); + assert(dc(a, g.ts, m as int, el as int, cxt, lo_e as int, lo_e as int + 1)); + assert(dc(a, g.ts, m as int, ex as int, cxt, lo_e as int + 1, pos as int)); assert(ed(a, g.ts, ex as int, lo_e as int + 1) == pos as int); - lemma_dtemplate_step(a, g.ts, m as int, ks, k as int - 2, g.cx, lo_e as int, pos as int, end as int); + lemma_dtemplate_step(a, g.ts, m as int, ks, k as int - 2, cxt, lo_e as int, pos as int, end as int); } pos = lo_e; k = k.saturating_sub(2); diff --git a/crates/clazel-js-syntax/src/arena_e.rs b/crates/clazel-js-syntax/src/arena_e.rs new file mode 100644 index 00000000..b45bfb64 --- /dev/null +++ b/crates/clazel-js-syntax/src/arena_e.rs @@ -0,0 +1,1129 @@ +//! More checks of [`spec::d`] for [`crate::arena_d::check_derivation`]: the +//! constructs of the script grammar that [`crate::arena_d`] did not cover when +//! it was written. Each `check_*` here is dispatched from `check_derivation` +//! and has the same contract as its siblings there: it reads what the parser +//! built (the node, its children's recorded ranges) and the executable tokens, +//! and returns the node's token range and binding strength only if +//! `node_done` (the node derives that range in its context, and ends there) +//! follows from the specification. +//! +//! **Covered here:** `new.target`, `import.meta` (§13.3.12), `super.name`, +//! `super[expr]` and `super(args)` (§13.3.7), `import(spec, options)` +//! (§13.3.10), and optional chains (§13.3.9: `a?.b`, `a?.[b]`, `a?.(c)`, +//! `a?.#p`, `a?.b.c(d)`). +//! +//! The assumptions are those of [`crate::arena_d`]. + +use crate::arena_d::*; +use crate::ast::*; +use crate::spec::*; +use vstd::prelude::*; + +verus! { + +/// The words and punctuators of these checks, as code points. +pub(crate) proof fn lemma_words_e() + ensures + cps("super"@) =~= seq![0x73u32, 0x75, 0x70, 0x65, 0x72], + cps("import"@) =~= seq![0x69u32, 0x6D, 0x70, 0x6F, 0x72, 0x74], + cps("meta"@) =~= seq![0x6Du32, 0x65, 0x74, 0x61], + cps("new"@) =~= seq![0x6Eu32, 0x65, 0x77], + cps("target"@) =~= seq![0x74u32, 0x61, 0x72, 0x67, 0x65, 0x74], + cps("?."@) =~= seq![0x3Fu32, 0x2E], + cps(","@) =~= seq![0x2Cu32], +{ + reveal_strlit("super"); + reveal_strlit("import"); + reveal_strlit("meta"); + reveal_strlit("new"); + reveal_strlit("target"); + reveal_strlit("?."); + reveal_strlit(","); + assert("super"@ =~= seq!['s', 'u', 'p', 'e', 'r']); + assert("import"@ =~= seq!['i', 'm', 'p', 'o', 'r', 't']); + assert("meta"@ =~= seq!['m', 'e', 't', 'a']); + assert("new"@ =~= seq!['n', 'e', 'w']); + assert("target"@ =~= seq!['t', 'a', 'r', 'g', 'e', 't']); + assert("?."@ =~= seq!['?', '.']); + assert(","@ =~= seq![',']); +} + +/// Token `x` is the punctuator `gw.w`, whose code points are `w`. +pub(crate) fn punct_n_at( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + x: usize, + w: &[u32], + Ghost(gw): Ghost, +) -> (r: bool) + requires + env_ok(src@, nodes@, toks@, gaps@, gw.g.ts), + cps(gw.w) =~= w@, + ensures + r ==> x < toks.len() && is_p(gw.g.ts, x as int, gw.w), +{ + let _ = (nodes.len(), gaps.len()); + let ghost g = gw.g; + let ghost lit = gw.w; + let t = match toks.get(x) { + Some(t) => t, + None => { + return false; + }, + }; + proof { + lemma_env_tok(src@, nodes@, toks@, gaps@, g.ts, x as int); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + assert(t == &toks@[x as int]); + } + let r = matches!(t.kind, TokKind::Punctuator) && text_is(src, t, w); + proof { + if r { + assert(g.ts.toks[x as int].text =~= src@.subrange(t.start as int, t.end as int)); + assert(g.ts.toks[x as int].text =~= cps(lit)); + } + } + r +} + +/// The facts the checks read of node `m` of the arena of `nodes`. +pub(crate) proof fn lemma_node_view(nodes: Seq, m: int) + requires + 0 <= m < nodes.len(), + ensures + arena_of(nodes).nodes.len() == nodes.len(), + arena_of(nodes).nodes[m] == nodes[m]@, + arena_of(nodes).nodes[m].kind == nodes[m].kind, + arena_of(nodes).nodes[m].op == nodes[m].op, + arena_of(nodes).nodes[m].flag == nodes[m].flag, + arena_of(nodes).nodes[m].start == nodes[m].start as int, + arena_of(nodes).nodes[m].end == nodes[m].end as int, + arena_of(nodes).nodes[m].children.len() == nodes[m].children@.len(), +{ +} + +// --------------------------------------------------------------------- +// §13.3.12 `new.target`, `import.meta`. +// --------------------------------------------------------------------- + +/// `NewTarget : new . target` and `ImportMeta : import . meta`. +#[verifier::spinoff_prover] +proof fn lemma_meta_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= x, + x + 3 <= tn(ts), + a.nodes[m].children.len() == 0, + a.nodes[m].kind == NodeKind::NewTarget && is_kw(ts, x, "new"@) && is_p(ts, x + 1, "."@) + && is_kw(ts, x + 2, "target"@) || a.nodes[m].kind == NodeKind::ImportMeta && is_kw( + ts, + x, + "import"@, + ) && is_p(ts, x + 1, "."@) && is_kw(ts, x + 2, "meta"@), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[x + 2].end, + ensures + node_done(a, ts, m, cx, x, x + 3), + lvl(a, m) == 17, +{ + assert(span_ok(a, ts, m, x, x + 3)); + assert(d_expr_lhs(a, ts, m, cx, x, x + 3)); + assert(d_expr(a, ts, m, cx, x, x + 3)); + lemma_ed_of(a, ts, m, x, x + 3); +} + +/// §13.3.12 `new . target`, `import . meta`. +#[verifier::spinoff_prover] +pub(crate) fn check_meta( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_e(); + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let is_new = matches!(nd.kind, NodeKind::NewTarget); + if !(is_new || matches!(nd.kind, NodeKind::ImportMeta)) || !nd.children.is_empty() { + return None; + } + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let x1 = x.saturating_add(1); + let x2 = x.saturating_add(2); + let x3 = x.saturating_add(3); + if is_new { + if !word_at(src, nodes, toks, gaps, x, &[0x6E, 0x65, 0x77], Ghost(GW { g, w: "new"@ })) + || !word_at( + src, + nodes, + toks, + gaps, + x2, + &[0x74, 0x61, 0x72, 0x67, 0x65, 0x74], + Ghost(GW { g, w: "target"@ }), + ) { + return None; + } + } else { + if !word_at( + src, + nodes, + toks, + gaps, + x, + &[0x69, 0x6D, 0x70, 0x6F, 0x72, 0x74], + Ghost(GW { g, w: "import"@ }), + ) || !word_at(src, nodes, toks, gaps, x2, &[0x6D, 0x65, 0x74, 0x61], Ghost(GW { g, w: "meta"@ })) { + return None; + } + } + if !punct_at(src, nodes, toks, gaps, x1, 0x2E, Ghost(GW { g, w: "."@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, x3, Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(x1 as int == x as int + 1); + assert(x2 as int == x as int + 2); + assert(x3 as int == x as int + 3); + assert(a.nodes[m as int].children.len() == 0); + lemma_meta_done(a, g.ts, g.cx, m as int, x as int); + } + Some((x, x3, 17)) +} + +// --------------------------------------------------------------------- +// §13.3.7 `super.name`, `super[expr]`, `super(args)`. +// --------------------------------------------------------------------- + +/// `SuperProperty : super . IdentifierName | super [ Expression ]`. +#[verifier::spinoff_prover] +proof fn lemma_super_prop_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + c: int, + x: int, + lo_c: int, + hi_c: int, + j: int, +) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c < m, + 0 <= x, + a.nodes[m].kind == NodeKind::SuperProperty, + a.nodes[m].children =~= seq![c], + is_kw(ts, x, "super"@), + x + 3 <= j <= tn(ts), + lo_c == x + 2, + node_done(a, ts, c, cx, lo_c, hi_c), + match a.nodes[m].op { + Op::Dot => is_p(ts, x + 1, "."@) && kd(a, c) == NodeKind::IdentifierName && j == x + 3, + Op::Bracket => cx_in(cx, true) == cx && is_p(ts, x + 1, "["@) && lvl(a, c) >= -1 + && is_p(ts, hi_c, "]"@) && j == hi_c + 1, + _ => false, + }, + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == 17, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c); + assert(dc(a, ts, m, c, cx, lo_c, hi_c)); + assert(d_expr_lhs(a, ts, m, cx, x, j)); + assert(d_expr(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.3.7 `super . name` and `super [ expression ]`. +#[verifier::spinoff_prover] +pub(crate) fn check_super_prop( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_e(); + lemma_punct_text(); + lemma_brackets(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let dot = matches!(nd.op, Op::Dot); + if !matches!(nd.kind, NodeKind::SuperProperty) || !(dot || matches!(nd.op, Op::Bracket)) + || nd.children.len() != 1 { + return None; + } + let cxm = match done.cxs.get(m) { + Some(c) => c, + None => { + return None; + }, + }; + let c = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_c, hi_c, lv_c) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let x1 = x.saturating_add(1); + let x2 = x.saturating_add(2); + if lo_c != x2 + || !word_at(src, nodes, toks, gaps, x, &[0x73, 0x75, 0x70, 0x65, 0x72], Ghost(GW { g, w: "super"@ })) { + return None; + } + let j: usize; + if dot { + j = x.saturating_add(3); + if !punct_at(src, nodes, toks, gaps, x1, 0x2E, Ghost(GW { g, w: "."@ })) + || !matches!(kind_at(nodes, c), NodeKind::IdentifierName) || hi_c != j { + return None; + } + } else { + if !cxm.i || cxm.d || lv_c < -1 || !punct_at(src, nodes, toks, gaps, x1, 0x5B, Ghost(GW { g, w: "["@ })) + || !punct_at(src, nodes, toks, gaps, hi_c, 0x5D, Ghost(GW { g, w: "]"@ })) { + return None; + } + j = hi_c.saturating_add(1); + } + if !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(cxm == &done.cxs@[m as int]); + assert(x1 as int == x as int + 1); + assert(x2 as int == x as int + 2); + assert(a.nodes[m as int].children =~= seq![c as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 0); + if dot { + assert(j as int == x as int + 3); + } else { + assert(j as int == hi_c as int + 1); + assert(g.cx.in_ && !g.cx.deflt); + assert(cx_in(g.cx, true) == g.cx); + } + lemma_super_prop_done(a, g.ts, g.cx, m as int, c as int, x as int, lo_c as int, hi_c as int, j as int); + } + Some((x, j, 17)) +} + +/// `SuperCall : super Arguments`. +#[verifier::spinoff_prover] +proof fn lemma_super_call_done(a: AstV, ts: Stream, cx: Ctx, m: int, c: int, x: int, lo_c: int, j: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c < m, + 0 <= x, + a.nodes[m].kind == NodeKind::SuperCall, + a.nodes[m].children =~= seq![c], + is_kw(ts, x, "super"@), + kd(a, c) == NodeKind::Arguments, + lo_c == x + 1, + node_done(a, ts, c, cx, lo_c, j), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == 15, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c); + assert(dc(a, ts, m, c, cx, lo_c, j)); + assert(d_expr_lhs(a, ts, m, cx, x, j)); + assert(d_expr(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.3.7 `super Arguments`. +#[verifier::spinoff_prover] +pub(crate) fn check_super_call( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_e(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::SuperCall) || nd.children.len() != 1 { + return None; + } + let c = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_c, j, _lv_c) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let x1 = x.saturating_add(1); + if lo_c != x1 || !matches!(kind_at(nodes, c), NodeKind::Arguments) + || !word_at(src, nodes, toks, gaps, x, &[0x73, 0x75, 0x70, 0x65, 0x72], Ghost(GW { g, w: "super"@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(x1 as int == x as int + 1); + assert(a.nodes[m as int].children =~= seq![c as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 0); + lemma_super_call_done(a, g.ts, g.cx, m as int, c as int, x as int, lo_c as int, j as int); + } + Some((x, j, 15)) +} + +// --------------------------------------------------------------------- +// §13.3.10 `import(specifier)`, `import(specifier, options)`. +// --------------------------------------------------------------------- + +/// `ImportCall`: the specifier, the options or `Absent`, a trailing `,` allowed. +#[verifier::spinoff_prover] +proof fn lemma_import_call_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + s: int, + o: int, + x: int, + mc: int, + q: int, + lo_o: int, + j: int, +) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= s < m, + 0 <= o < m, + 0 <= x, + a.nodes[m].kind == NodeKind::ImportCall, + a.nodes[m].children =~= seq![s, o], + is_kw(ts, x, "import"@), + is_p(ts, x + 1, "("@), + lvl(a, s) >= 0, + node_done(a, ts, s, cx, x + 2, mc), + if kd(a, o) == NodeKind::Absent { + d(a, ts, o, cx, mc, mc) && ed(a, ts, o, mc) == mc && q == mc + } else { + lvl(a, o) >= 0 && is_p(ts, mc, ","@) && lo_o == mc + 1 && node_done(a, ts, o, cx, lo_o, q) + }, + (is_p(ts, q, ")"@) && j == q + 1) || (is_p(ts, q, ","@) && is_p(ts, q + 1, ")"@) && j == q + + 2), + x + 3 <= j <= tn(ts), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == 15, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == s); + assert(a.nodes[m].children[1] == o); + assert(dc(a, ts, m, s, cx, x + 2, mc)); + assert(is_assign_expr(a, s)); + if kd(a, o) == NodeKind::Absent { + assert(dc(a, ts, m, o, cx, mc, mc)); + } else { + assert(dc(a, ts, m, o, cx, mc + 1, q)); + assert(is_assign_expr(a, o)); + } + assert(d_expr_lhs(a, ts, m, cx, x, j)); + assert(d_expr(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.3.10 `import ( specifier ,? )` and `import ( specifier , options ,? )`. +#[verifier::spinoff_prover] +pub(crate) fn check_import_call( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_e(); + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ImportCall) || nd.children.len() != 2 { + return None; + } + let s = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let o = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_s, mc, lv_s) = match done_at(done, s) { + Some(r) => r, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let x1 = x.saturating_add(1); + let x2 = x.saturating_add(2); + if lv_s < 0 || lo_s != x2 + || !word_at(src, nodes, toks, gaps, x, &[0x69, 0x6D, 0x70, 0x6F, 0x72, 0x74], Ghost(GW { g, w: "import"@ })) + || !punct_at(src, nodes, toks, gaps, x1, 0x28, Ghost(GW { g, w: "("@ })) { + return None; + } + let absent = matches!(kind_at(nodes, o), NodeKind::Absent); + let (lo_o, q_e, lv_o) = if absent { + if !check_absent(src, nodes, toks, gaps, o, mc, Ghost(g)) { + return None; + } + (mc, mc, 0i32) + } else { + match done_at(done, o) { + Some(r) => r, + None => { + return None; + }, + } + }; + if !absent && (lv_o < 0 || lo_o != mc.saturating_add(1) + || !punct_n_at(src, nodes, toks, gaps, mc, &[0x2C], Ghost(GW { g, w: ","@ }))) { + return None; + } + // After the last operand, which ends at `q_e`: `)`, or `, )`. + let e1 = q_e.saturating_add(1); + let j: usize = if punct_at(src, nodes, toks, gaps, q_e, 0x29, Ghost(GW { g, w: ")"@ })) { + e1 + } else if punct_n_at(src, nodes, toks, gaps, q_e, &[0x2C], Ghost(GW { g, w: ","@ })) + && punct_at(src, nodes, toks, gaps, e1, 0x29, Ghost(GW { g, w: ")"@ })) { + q_e.saturating_add(2) + } else { + return None; + }; + if !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(x1 as int == x as int + 1); + assert(x2 as int == x as int + 2); + assert(e1 as int == q_e as int + 1); + assert(a.nodes[m as int].children =~= seq![s as int, o as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, s as int, g.cx, 0); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, o as int, g.cx, 1); + if !absent { + assert(kd(a, o as int) != NodeKind::Absent); + } + lemma_import_call_done( + a, + g.ts, + g.cx, + m as int, + s as int, + o as int, + x as int, + mc as int, + q_e as int, + lo_o as int, + j as int, + ); + } + Some((x, j, 15)) +} + +// --------------------------------------------------------------------- +// §13.3.9 optional chains: `a?.b`, `a?.[b]`, `a?.(c)`, `a?.#p`, and the links that +// continue them. +// --------------------------------------------------------------------- + +/// One link of an `OptionalChain`. +#[verifier::spinoff_prover] +proof fn lemma_chain_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + c: int, + x: int, + s: int, + lo_c: int, + hi_c: int, + j: int, +) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c < m, + 0 <= x < j <= tn(ts), + a.nodes[m].kind == NodeKind::OptionalChain, + a.nodes[m].children =~= seq![c], + s == (if a.nodes[m].flag { + x + 1 + } else { + x + }), + a.nodes[m].flag ==> is_p(ts, x, "?."@), + node_done(a, ts, c, cx, lo_c, hi_c), + match a.nodes[m].op { + Op::ChainDot => (a.nodes[m].flag || is_p(ts, x, "."@)) && kd(a, c) + == NodeKind::IdentifierName && j == x + 2 && lo_c == x + 1 && hi_c == j, + Op::ChainPrivateDot => (a.nodes[m].flag || is_p(ts, x, "."@)) && kd(a, c) + == NodeKind::PrivateIdentifier && j == x + 2 && lo_c == x + 1 && hi_c == j, + Op::ChainBracket => cx_in(cx, true) == cx && is_p(ts, s, "["@) && lvl(a, c) >= -1 + && lo_c == s + 1 && is_p(ts, hi_c, "]"@) && j == hi_c + 1, + Op::ChainCall => kd(a, c) == NodeKind::Arguments && lo_c == s && j == hi_c, + _ => false, + }, + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c); + assert(dc(a, ts, m, c, cx, lo_c, hi_c)); + assert(d_chain_link(a, ts, m, cx, x, j)); + assert(d_expr_lhs(a, ts, m, cx, x, j)); + assert(d_expr(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.3.9 one link of an `OptionalChain`: `?. name`, `?. [ expr ]`, `?. ( args )`, `?. #name`, +/// or the same without the `?.` (`. name`, `[ expr ]`, `( args )`, `. #name`). +#[verifier::spinoff_prover] +pub(crate) fn check_chain_link( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_e(); + lemma_punct_text(); + lemma_brackets(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::OptionalChain) || nd.children.len() != 1 { + return None; + } + let cxm = match done.cxs.get(m) { + Some(c) => c, + None => { + return None; + }, + }; + let c = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_c, hi_c, lv_c) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let x1 = x.saturating_add(1); + let flag = nd.flag; + let s: usize = if flag { + x1 + } else { + x + }; + if flag && !punct_n_at(src, nodes, toks, gaps, x, &[0x3F, 0x2E], Ghost(GW { g, w: "?."@ })) { + return None; + } + let j: usize = match nd.op { + Op::ChainDot | Op::ChainPrivateDot => { + let private = matches!(nd.op, Op::ChainPrivateDot); + let kc = kind_at(nodes, c); + let kind_ok = if private { + matches!(kc, NodeKind::PrivateIdentifier) + } else { + matches!(kc, NodeKind::IdentifierName) + }; + let j = x.saturating_add(2); + if (!flag && !punct_at(src, nodes, toks, gaps, x, 0x2E, Ghost(GW { g, w: "."@ }))) || !kind_ok + || lo_c != x1 || hi_c != j { + return None; + } + j + }, + Op::ChainBracket => { + if !cxm.i || cxm.d || lv_c < -1 || lo_c != s.saturating_add(1) + || !punct_at(src, nodes, toks, gaps, s, 0x5B, Ghost(GW { g, w: "["@ })) + || !punct_at(src, nodes, toks, gaps, hi_c, 0x5D, Ghost(GW { g, w: "]"@ })) { + return None; + } + hi_c.saturating_add(1) + }, + Op::ChainCall => { + if !matches!(kind_at(nodes, c), NodeKind::Arguments) || lo_c != s { + return None; + } + hi_c + }, + _ => { + return None; + }, + }; + if !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(cxm == &done.cxs@[m as int]); + assert(x1 as int == x as int + 1); + assert(s as int == (if a.nodes[m as int].flag { + x as int + 1 + } else { + x as int + })); + assert(a.nodes[m as int].children =~= seq![c as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 0); + match a.nodes[m as int].op { + Op::ChainDot => { + assert(j as int == x as int + 2); + }, + Op::ChainPrivateDot => { + assert(j as int == x as int + 2); + }, + Op::ChainBracket => { + assert(s.saturating_add(1) as int == s as int + 1); + assert(hi_c.saturating_add(1) as int == hi_c as int + 1); + assert(g.cx.in_ && !g.cx.deflt); + assert(cx_in(g.cx, true) == g.cx); + }, + _ => {}, + } + lemma_chain_done( + a, + g.ts, + g.cx, + m as int, + c as int, + x as int, + s as int, + lo_c as int, + hi_c as int, + j as int, + ); + } + Some((x, j, -100)) +} + +/// `OptionalExpression : base link links...`. +#[verifier::spinoff_prover] +proof fn lemma_optional_done(a: AstV, ts: Stream, cx: Ctx, m: int, base: int, x: int, mb: int, j: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= base < m, + 0 <= x < j <= tn(ts), + a.nodes[m].kind == NodeKind::OptionalExpression, + a.nodes[m].children.len() >= 2, + a.nodes[m].children[0] == base, + is_member_or_call(a, base), + all_kind2(a, a.nodes[m].children, 1, NodeKind::OptionalChain, NodeKind::OptionalChain), + flag_of(a, a.nodes[m].children[1]), + node_done(a, ts, base, cx, x, mb), + dl(a, ts, m, a.nodes[m].children, 1, cx, mb, j), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == 14, +{ + assert(span_ok(a, ts, m, x, j)); + assert(dc(a, ts, m, base, cx, x, mb)); + assert(d_expr_lhs(a, ts, m, cx, x, j)); + assert(d_expr(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §13.3.9 `OptionalExpression`: a base and its links. +#[verifier::spinoff_prover] +pub(crate) fn check_optional( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let len = nd.children.len(); + if !matches!(nd.kind, NodeKind::OptionalExpression) || len < 2 { + return None; + } + let base = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let first_link = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let last_link = match kid_of(nodes, m, len.saturating_sub(1)) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_b, mb, lv_b) = match done_at(done, base) { + Some(r) => r, + None => { + return None; + }, + }; + let (_lo_l, j, _lv_l) = match done_at(done, last_link) { + Some(r) => r, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + let flag_first = match nodes.get(first_link) { + Some(l) => l.flag, + None => { + return None; + }, + }; + if !(lv_b == 15 || lv_b == 17) || lo_b != x || !flag_first + || !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + let ghost a = arena_of(nodes@); + proof { + assert(nd == &nodes@[m as int]); + assert(first_link < nodes.len()); + assert(nodes@[first_link as int].flag == a.nodes[first_link as int].flag); + } + let mut k = len; + let mut pos = j; + while k > 1 + invariant + m < nodes.len(), + nodes@.len() == nodes.len(), + a == arena_of(nodes@), + ast_wf(a), + nd == &nodes@[m as int], + len == nd.children.len(), + len == a.nodes[m as int].children.len(), + 1 <= k <= len, + pos <= toks.len(), + j <= toks.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(a, done.cxs@, m as int, g.cx), + dl(a, g.ts, m as int, a.nodes[m as int].children, k as int, g.cx, pos as int, j as int), + forall|q: int| + k <= q < len ==> kd(a, #[trigger] a.nodes[m as int].children[q]) + == NodeKind::OptionalChain, + decreases k, + { + let km1 = k.saturating_sub(1); + let c = match kid_of(nodes, m, km1) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_c, hi_c, _lv_c) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + if hi_c != pos || !matches!(kind_at(nodes, c), NodeKind::OptionalChain) { + return None; + } + proof { + assert(km1 as int == k as int - 1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, km1 as int); + assert(a.nodes[m as int].children[k as int - 1] == c as int); + lemma_dl_cons( + a, + g.ts, + m as int, + a.nodes[m as int].children, + k as int - 1, + g.cx, + lo_c as int, + hi_c as int, + j as int, + ); + } + pos = lo_c; + k = km1; + } + if pos != mb { + return None; + } + proof { + assert(a.nodes[m as int].children[0] == base as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, base as int, g.cx, 0); + assert(all_kind2( + a, + a.nodes[m as int].children, + 1, + NodeKind::OptionalChain, + NodeKind::OptionalChain, + )); + assert(a.nodes[m as int].children[1] == first_link as int); + assert(flag_of(a, first_link as int)); + assert(is_member_or_call(a, base as int)); + lemma_optional_done(a, g.ts, g.cx, m as int, base as int, x as int, mb as int, j as int); + } + Some((x, j, 14)) +} + +} // verus! diff --git a/crates/clazel-js-syntax/src/lib.rs b/crates/clazel-js-syntax/src/lib.rs index 60cabe28..97b78f93 100644 --- a/crates/clazel-js-syntax/src/lib.rs +++ b/crates/clazel-js-syntax/src/lib.rs @@ -56,6 +56,7 @@ pub mod api; pub mod arena_d; +pub mod arena_e; pub mod ast; pub mod check; pub mod contract; diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index b3cea5d9..8f16fb3a 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -180,6 +180,72 @@ var c;", } } +/// The remaining script syntax: optional chains, `super`, `new.target`, `import()`, +/// `import.meta`, `for await`, Annex B's `for (var x = 1 in o)` and function declarations +/// as statement bodies, patterns as `for` heads, and operands of `[~In]` heads. +#[test] +fn remaining_script_syntax_is_verified() { + for s in [ + "a?.b;", + "a?.[b];", + "a?.();", + "a?.b.c(d)?.[e];", + "a?.b\n.c?.d(e)\n[f];", + "class A extends B { constructor() { super(); super(1, ...a); } m() { super.x; super[x](); } }", + "x = { m() { return super.m; } };", + "function f() { new.target; new.target.x; }", + "function f() { return a?.b?.(c)?.[d]; }", + "class A { #x; m() { return this?.#x; } }", + "import('a');", + "import('a', {});", + "import('a',);", + "import('a', b,);", + "async function f() { for await (x of y) ; }", + "async function f() { for await (const [a, b] of c) d; }", + "for (var x = 1 in o) ;", + "if (a) function f() {} else function g() {}", + "l: function f() {}", + "for (let [a, b] of o) ;", + "for (const {a, b: [c = 1]} of o) ;", + "for (var [a] in o) ;", + "for ([a, b = 1, ...c] of o) ;", + "for ({a, b: c = 2, ...d} in o) ;", + "for (a.b[c] of d) ;", + "for (f().x of y) ;", + "for (let [a = (1, 2)] of b) ;", + "for (a, b;;) ;", + "for (i = 0, j = 1; i < j; i++) ;", + "for (var i = a ? b : c; ;) ;", + "for (var i = f(1), j = new A(2); ;) ;", + "for (var i = a.b[c]; ;) ;", + "for (var i = (1, 2); ;) ;", + "for (var i = [1, ...a]; ;) ;", + "for (var i = {a: 1, ...b, [c]: 2, m() {}}; ;) ;", + "for (var i = `a${b}`; ;) ;", + "for (var i = a`x`; ;) ;", + "for (var i = a?.b; ;) ;", + "for (var i = ({a} = b); ;) ;", + "for (var i = 0, j = (1, 2); i < j; i++) ;", + ] { + assert!( + derivation(s, SourceGoal::Script) == Some(Derivation::Verified), + "{s}" + ); + } +} + +/// `import.meta` is in a `Module` only. +#[test] +fn import_meta_is_verified_in_a_module() { + for s in ["import.meta;", "import.meta.url;", "f(import.meta);"] { + assert!( + derivation(s, SourceGoal::Module) == Some(Derivation::Verified), + "{s}" + ); + assert!(derivation(s, SourceGoal::Script).is_none(), "{s}"); + } +} + /// Productions only a sloppy-mode `Script` has. #[test] fn covered_sloppy_programs_are_verified() { @@ -199,7 +265,7 @@ fn covered_sloppy_programs_are_verified() { #[test] fn other_programs_are_unsupported_not_failed() { - for s in ["for (a, b;;) ;", "a?.b;"] { + for s in ["for (var i = class {};;) ;", "for (let in o) ;"] { assert!( derivation(s, SourceGoal::Script) == Some(Derivation::Unsupported), "{s}" @@ -222,7 +288,7 @@ fn errors_are_still_errors() { fn what_the_check_costs() { let body = "(1 + 2 * 3) < 4 - 5 / 6 % 7;\n".repeat(60_000); let covered = cps(&body); - let stopped = cps(&format!("a?.b;\n{body}")); + let stopped = cps(&format!("for (var i = class {{}};;) ;\n{body}")); let time = |src: &[u32]| { let t = Instant::now(); let r = parse_checked(src, SourceGoal::Script); diff --git a/crates/clazel-js-syntax/tests/test262.rs b/crates/clazel-js-syntax/tests/test262.rs index baa87faa..8ab585b3 100644 --- a/crates/clazel-js-syntax/tests/test262.rs +++ b/crates/clazel-js-syntax/tests/test262.rs @@ -249,16 +249,17 @@ fn test262_fixtures_parse() -> Result<(), String> { Ok(()) } -/// How much of Test262 the proven derivation check ([`clazel_js_syntax::arena_d`]) -/// covers: the share of the positive tests and of the harness files whose whole arena -/// comes out `Verified`, not `Unsupported`. Printed, not asserted: it grows as the -/// check covers more of the grammar. +/// How much of Test262 the proven checks ([`clazel_js_syntax::arena_d`]) cover: the +/// share of the positive runs (scripts and modules apart) and of the harness files +/// whose whole arena comes out `Verified`, not `Unsupported`. Printed, not +/// asserted: it grows as the checks cover more of the grammar. #[test] #[cfg_attr(miri, ignore = "reads files")] fn test262_verified_share() -> Result<(), String> { use clazel_js_syntax::arena_d::Derivation; use clazel_js_syntax::exec::parse_checked; let (mut positives, mut verified) = (0usize, 0usize); + let (mut mpositives, mut mverified) = (0usize, 0usize); for case in TEST262 { if !judged(case) || case.negative.is_some() { continue; @@ -270,9 +271,13 @@ fn test262_verified_share() -> Result<(), String> { s.extend("\"use strict\";\n".chars().map(u32::from)); } s.extend(src.iter().copied()); - positives += 1; - if let Ok((_, Derivation::Verified)) = parse_checked(&s, goal) { - verified += 1; + let ok = matches!(parse_checked(&s, goal), Ok((_, Derivation::Verified))); + if goal == SourceGoal::Module { + mpositives += 1; + mverified += usize::from(ok); + } else { + positives += 1; + verified += usize::from(ok); } } } @@ -287,6 +292,81 @@ fn test262_verified_share() -> Result<(), String> { hv += 1; } } - println!("Verified: {verified} of {positives} positive runs, {hv} of {hn} harness files"); + println!( + "Verified: {verified} of {positives} script positive runs, {mverified} of {mpositives} module positive runs, {hv} of {hn} harness files" + ); + Ok(()) +} + +/// Which constructs the unverified runs contain: a histogram of the kinds the +/// check may not cover. Printed with `--nocapture`; for finding what to cover. +#[test] +#[cfg_attr(miri, ignore = "reads files")] +fn test262_unverified_kinds() -> Result<(), String> { + use clazel_js_syntax::arena_d::Derivation; + use clazel_js_syntax::ast::NodeKind as K; + use clazel_js_syntax::exec::parse_checked; + use std::collections::BTreeMap; + let mut hist: BTreeMap<&'static str, usize> = BTreeMap::new(); + let mut note = |src: &[u32], goal: SourceGoal| -> bool { + let Ok((ast, d)) = parse_checked(src, goal) else { + return false; + }; + if d == Derivation::Verified { + return false; + } + let mut seen: BTreeSet<&'static str> = BTreeSet::new(); + for n in &ast.nodes { + let l = match n.kind { + K::OptionalExpression => "optional", + K::SuperProperty => "super.x", + K::SuperCall => "super()", + K::ImportCall => "import()", + K::ImportMeta => "import.meta", + K::NewTarget => "new.target", + K::CoverInitializedName => "cover-init", + K::ImportDeclaration => "import-decl", + K::ExportDeclaration => "export-decl", + K::ForOfStatement if n.flag => "for-await", + K::ForOfStatement | K::ForInStatement => "for-in-of", + K::ForStatement => "for", + _ => continue, + }; + seen.insert(l); + } + if seen.is_empty() { + seen.insert("(none of the listed)"); + } + for l in seen { + *hist.entry(l).or_default() += 1; + } + true + }; + for case in TEST262 { + if !judged(case) || case.negative.is_some() { + continue; + } + let src = read(case)?; + for (goal, strict) in runs(case) { + let mut s: Vec = Vec::new(); + if strict { + s.extend("\"use strict\";\n".chars().map(u32::from)); + } + s.extend(src.iter().copied()); + if note(&s, goal) && std::env::var("SHOW_UNVERIFIED").is_ok() { + println!("unverified {} {:?}", case.path, goal == SourceGoal::Module); + } + } + } + let mut files = Vec::new(); + all_js(&root().join("../harness"), &mut files); + for f in &files { + let text = std::fs::read_to_string(f).map_err(|e| e.to_string())?; + let src: Vec = text.chars().map(u32::from).collect(); + if note(&src, SourceGoal::Script) { + println!("harness unverified: {}", f.display()); + } + } + println!("unverified, by construct: {hist:?}"); Ok(()) } From d2f4d1c5db32ecab9e8598b8ac4066886ff646de Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 13:33:38 +0000 Subject: [PATCH 011/195] js-syntax: cover every import and export form in the derivation check; for (let in o), await, yield and classes in [~In] heads New arena_m: ImportDeclaration, ImportClause, NameSpaceImport, NamedImports, ImportSpecifier, WithClause, ImportAttribute, all nine ExportDeclaration forms (string and identifier ModuleExportNames, export default with [+Default]), NamedExports and ExportSpecifier. The root accepts ModuleItems in a Module. check_function and check_class accept an absent name under [+Default]; classes, await and yield are checked in any context. Verus: 374 verified, 0 errors. Mutate: 6 of 6 killed. Verified: 1567/1567 script runs, 1/1 module run, 143/143 module fixtures, 41/41 harness files. Not covered: class fields under export default and in [~In] heads. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 186 ++- crates/clazel-js-syntax/src/arena_m.rs | 1556 +++++++++++++++++++ crates/clazel-js-syntax/src/lib.rs | 1 + crates/clazel-js-syntax/tests/derivation.rs | 68 +- crates/clazel-js-syntax/tests/test262.rs | 17 +- 5 files changed, 1804 insertions(+), 24 deletions(-) create mode 100644 crates/clazel-js-syntax/src/arena_m.rs diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index c441da9a..23824c6b 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -23,8 +23,9 @@ //! patterns and Annex B forms as `for` heads, `for await`, function declarations as //! statement bodies, and operands of `[~In]` heads (bracketed operands are `[+In]`: //! `cx_ok_t`, `cx_ok_init`). `CoverInitializedName` never survives the early errors; its -//! assignment-pattern reading is covered. Not covered: `await`, `yield` and class -//! expressions inside `[~In]` heads, and modules' `import` and `export`. +//! assignment-pattern reading is covered. Modules' `import` and `export` (all forms, with import +//! attributes) are in [`crate::arena_m`]. Not covered: class fields and other `[+Default]`-sensitive +//! members of an `export default class`, and class fields in `[~In]` heads. //! //! [`crate::exec::parse_checked`] runs [`check_derivation_canon`] on every arena //! the parser builds, and rejects it if a covered node is `Failed`. @@ -174,6 +175,15 @@ pub(crate) proof fn lemma_dl_cons(a: AstV, ts: Stream, bound: int, ks: Seq, { } +/// The items of a root are `StatementListItem`s (a `Script`) or `ModuleItem`s (a `Module`). +pub open spec fn root_items(a: AstV, ks: Seq, g: SourceGoal) -> bool { + if g == SourceGoal::Script { + all_items(a, ks) + } else { + forall|k: int| 0 <= k < ks.len() ==> is_module_item_kind(kd(a, #[trigger] ks[k])) + } +} + /// The `Script` or `Module` root `n` derives the whole stream. proof fn lemma_root_derives(a: AstV, ts: Stream, n: int, cx: Ctx, g: SourceGoal) requires @@ -183,7 +193,7 @@ proof fn lemma_root_derives(a: AstV, ts: Stream, n: int, cx: Ctx, g: SourceGoal) } else { NodeKind::Module }), - all_items(a, a.nodes[n].children), + root_items(a, a.nodes[n].children, g), dl(a, ts, n, a.nodes[n].children, 0, cx, 0, tn(ts)), span_ok(a, ts, n, 0, tn(ts)), ensures @@ -1606,6 +1616,12 @@ pub open spec fn item_ok_val(l: int, k: NodeKind, mode: int) -> bool { k == NodeKind::BindingProperty || k == NodeKind::BindingRestProperty } else if mode == 9 { k == NodeKind::AssignmentProperty || k == NodeKind::AssignmentRestProperty + } else if mode == 11 { + k == NodeKind::ImportSpecifier + } else if mode == 13 { + k == NodeKind::ImportAttribute + } else if mode == 15 { + k == NodeKind::ExportSpecifier } else { k == NodeKind::BindingElement || k == NodeKind::FunctionRestParameter } @@ -1630,6 +1646,12 @@ fn item_ok_exec(l: i32, k: NodeKind, mode: u8) -> (r: bool) matches!(k, NodeKind::BindingProperty | NodeKind::BindingRestProperty) } else if mode == 9 { matches!(k, NodeKind::AssignmentProperty | NodeKind::AssignmentRestProperty) + } else if mode == 11 { + matches!(k, NodeKind::ImportSpecifier) + } else if mode == 13 { + matches!(k, NodeKind::ImportAttribute) + } else if mode == 15 { + matches!(k, NodeKind::ExportSpecifier) } else { matches!(k, NodeKind::BindingElement | NodeKind::FunctionRestParameter) } @@ -1652,7 +1674,7 @@ pub struct ListSpec { /// The items of the list `ls`: separated by `,`, each an assignment expression (or a /// spread element where `spread_ok`), and ending at token `e` (after a trailing `,` /// where `trail` allows one). `spec::dsep` of the children. -fn check_list( +pub(crate) fn check_list( src: &[u32], nodes: &[Node], toks: &[DTok], @@ -4129,7 +4151,7 @@ proof fn lemma_comma_text() } /// The words that cannot start an `ExpressionStatement` (§14.5), as code points. -proof fn lemma_kw_text() +pub(crate) proof fn lemma_kw_text() ensures cps("function"@) =~= seq![0x66u32, 0x75, 0x6E, 0x63, 0x74, 0x69, 0x6F, 0x6E], cps("class"@) =~= seq![0x63u32, 0x6C, 0x61, 0x73, 0x73], @@ -5848,7 +5870,7 @@ fn check_root( cx_ok(a, done.cxs@, root as int, cx), dl(a, ts, root as int, a.nodes[root as int].children, k as int, cx, pos as int, nt as int), forall|j: int| - k <= j < len ==> is_item_kind(kd(a, #[trigger] a.nodes[root as int].children[j])), + k <= j < len ==> (if module { is_module_item_kind(kd(a, #[trigger] a.nodes[root as int].children[j])) } else { is_item_kind(kd(a, #[trigger] a.nodes[root as int].children[j])) }), decreases k, { let c = match nd.children.as_slice().get(k.saturating_sub(1)) { @@ -5874,7 +5896,7 @@ fn check_root( }, }; let item = match nodes.get(c) { - Some(x) => item_kind_exec(x.kind), + Some(x) => item_kind_exec(x.kind) || (module && matches!(x.kind, NodeKind::ImportDeclaration | NodeKind::ExportDeclaration)), None => false, }; if hi_c != pos || !item { @@ -5885,7 +5907,7 @@ fn check_root( assert(a.nodes[c as int] == nodes@[c as int]@); let ks = a.nodes[root as int].children; lemma_dl_cons(a, ts, root as int, ks, k as int - 1, cx, lo_c as int, hi_c as int, nt as int); - assert(is_item_kind(kd(a, c as int))); + assert(is_module_item_kind(kd(a, c as int))); } pos = lo_c; k = k.saturating_sub(1); @@ -5924,7 +5946,7 @@ fn check_root( lemma_env_tok(src@, nodes@, toks@, gaps@, ts, nt as int - 1); assert(span_ok(a, ts, root as int, 0, tn(ts))); } - assert(all_items(a, a.nodes[root as int].children)); + assert(root_items(a, a.nodes[root as int].children, goal_of(module))); lemma_root_derives(a, ts, root as int, cx, goal_of(module)); } true @@ -6174,6 +6196,17 @@ pub fn check_derivation( } else { check_binding(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) } + } else if matches!(nd.kind, NodeKind::ExportDeclaration) { + // The declaration of `export default` has `[+Default]`. + let dd = matches!(nd.op, Op::ExportDefaultHoistable | Op::ExportDefaultClass); + let ck = if dd { Cx5 { y: cxm.y, a: cxm.a, i: cxm.i, r: cxm.r, d: true } } else { cxm }; + if !plain || !kids_cx_g(nodes, done.cxs.as_slice(), m, &cxm, &ck) { + return Derivation::Unsupported; + } + proof { + assert(nd == &nodes@[m as int]); + } + crate::arena_m::check_export(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })) } else if matches!(nd.kind, NodeKind::ConditionalExpression) || (matches!(nd.kind, NodeKind::MemberExpression) && matches!(nd.op, Op::Bracket)) { @@ -6276,7 +6309,9 @@ pub fn check_derivation( | NodeKind::BindingRestElement | NodeKind::BindingRestProperty | NodeKind::AssignmentRestElement | NodeKind::AssignmentRestProperty | NodeKind::Elision | NodeKind::CallExpression | NodeKind::NewExpression - | NodeKind::TaggedTemplate | NodeKind::Expression + | NodeKind::TaggedTemplate | NodeKind::Expression | NodeKind::ClassDeclaration + | NodeKind::ClassExpression | NodeKind::ClassBody | NodeKind::AwaitExpression + | NodeKind::YieldExpression ); if !plain && !any_ctx { return Derivation::Unsupported; @@ -6460,6 +6495,11 @@ pub fn check_derivation( NodeKind::FunctionRestParameter => check_rest_param(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::YieldExpression => check_yield(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::AwaitExpression => check_await(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ImportDeclaration => crate::arena_m::check_import(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ImportClause => crate::arena_m::check_import_clause(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::NameSpaceImport => crate::arena_m::check_ns_import(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::NamedImports | NodeKind::NamedExports | NodeKind::WithClause => crate::arena_m::check_braced(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), + NodeKind::ImportSpecifier | NodeKind::ImportAttribute | NodeKind::ExportSpecifier => crate::arena_m::check_pair(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::NewTarget | NodeKind::ImportMeta => crate::arena_e::check_meta(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::SuperProperty => crate::arena_e::check_super_prop(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), NodeKind::SuperCall => crate::arena_e::check_super_call(src, nodes, toks, gaps, &done, m, Ghost(GCx { ts, cx })), @@ -6560,6 +6600,8 @@ fn assign_ctx(nodes: &[Node], module: bool) -> (r: Vec) matches!(nd.op, Op::Shorthand) } else if matches!(nd.kind, NodeKind::MemberExpression) { matches!(nd.op, Op::Bracket) + } else if matches!(nd.kind, NodeKind::ExportDeclaration) { + matches!(nd.op, Op::ExportDefaultHoistable | Op::ExportDefaultClass) } else { arrow && child_kind_is(nodes, nd, 0, true) }; @@ -6644,6 +6686,10 @@ fn child_cx(kind: NodeKind, k: usize, p: &Cx5, ident: bool, braced: bool) -> (r: ) { return if k == 0 { cx5_noin(p) } else { *p }; } + // `export default` declarations (`ident`) have `[+Default]`; the other forms pass their context. + if matches!(kind, NodeKind::ExportDeclaration) { + return if ident { Cx5 { y: p.y, a: p.a, i: p.i, r: p.r, d: true } } else { *p }; + } // `a[b]`: the property is `[+In]` (`ident` is the bracket form); `a ? b : c`: so is `b`. if matches!(kind, NodeKind::MemberExpression) { return if k == 1 && ident { Cx5 { y: p.y, a: p.a, i: true, r: p.r, d: false } } else { *p }; @@ -6668,7 +6714,8 @@ fn child_cx(kind: NodeKind, k: usize, p: &Cx5, ident: bool, braced: bool) -> (r: | NodeKind::BindingRestElement | NodeKind::BindingRestProperty | NodeKind::AssignmentRestElement | NodeKind::AssignmentRestProperty | NodeKind::CallExpression | NodeKind::NewExpression | NodeKind::TaggedTemplate - | NodeKind::Expression + | NodeKind::Expression | NodeKind::ClassDeclaration | NodeKind::ClassExpression + | NodeKind::ClassBody | NodeKind::AwaitExpression | NodeKind::YieldExpression ) { return *p; } @@ -6834,6 +6881,80 @@ fn kids_cx_t(nodes: &[Node], cxs: &[Cx5], m: usize, c: &Cx5, ct: &Cx5) -> (r: bo true } +/// Node `m` is checked in `c` and each of its children in `ck` (any context). +pub(crate) fn kids_cx_g(nodes: &[Node], cxs: &[Cx5], m: usize, c: &Cx5, ck: &Cx5) -> (r: bool) + requires + m < nodes.len(), + cxs.len() == nodes.len(), + ast_wf(arena_of(nodes@)), + ensures + r ==> (cx_of(cxs@[m as int]) == cx_of(*c) && kids_ok(arena_of(nodes@), cxs@, m as int, cx_of(*ck))), +{ + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return false; + }, + }; + match cxs.get(m) { + Some(x) => { + if !cx_eq(x, c) { + return false; + } + }, + None => { + return false; + }, + } + let len = nd.children.len(); + let ghost a = arena_of(nodes@); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + } + let mut k: usize = 0; + while k < len + invariant + m < nodes.len(), + nodes@.len() == nodes.len(), + a == arena_of(nodes@), + ast_wf(a), + nd == &nodes@[m as int], + len == nd.children.len(), + len == a.nodes[m as int].children.len(), + k <= len, + cxs.len() == nodes.len(), + cx_of(cxs@[m as int]) == cx_of(*c), + forall|q: int| + 0 <= q < k ==> 0 <= #[trigger] a.nodes[m as int].children[q] < cxs.len() + && cx_of(cxs@[a.nodes[m as int].children[q]]) == cx_of(*ck), + decreases len - k, + { + let ch = match nd.children.as_slice().get(k) { + Some(x) => *x as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[k as int] == ch as int); + lemma_child_before(a, m as int, k as int); + } + let cc = match cxs.get(ch) { + Some(x) => x, + None => { + return false; + }, + }; + if !cx_eq(cc, ck) { + return false; + } + k = k.saturating_add(1); + } + true +} + /// The specification's token for an executable one: the fields the check reads, and /// the lexer's other fields (`name`, `legacy`, ...) left as the empty or false /// default; the productions the check covers read none of them. @@ -9846,6 +9967,7 @@ pub open spec fn fn_cx(cx: Ctx, is_async: bool, is_gen: bool, is_expr: bool) -> /// §15.2 `function BindingIdentifier? ( FormalParameters ) { FunctionBody }` and the /// generator, `async` and `async` generator forms (`d_function`). #[verifier::spinoff_prover] +#[verifier::rlimit(300)] proof fn lemma_function_done( a: AstV, ts: Stream, @@ -9888,7 +10010,7 @@ proof fn lemma_function_done( }), !is_gen || is_p(ts, nm - 1, "*"@), if kd(a, n0) == NodeKind::Absent { - is_expr && d(a, ts, n0, fn_cx(cx, is_async, is_gen, is_expr).0, nm, nm) && mn == nm && ed(a, ts, n0, nm) == nm + (is_expr || cx.deflt) && d(a, ts, n0, fn_cx(cx, is_async, is_gen, is_expr).0, nm, nm) && mn == nm && ed(a, ts, n0, nm) == nm } else { kd(a, n0) == NodeKind::BindingIdentifier && node_done( a, @@ -10045,7 +10167,13 @@ fn check_function( let ghost cxb = fn_cx(g.cx, fs.is_async, fs.is_gen, fs.is_expr).2; let kn = kind_at(nodes, n0); let mn: usize = if matches!(kn, NodeKind::Absent) { - if !fs.is_expr || !check_absent(src, nodes, toks, gaps, n0, nm, Ghost(GCx { ts: g.ts, cx: cxn })) { + let deflt = match done.cxs.get(m) { + Some(c) => c.d, + None => { + return None; + }, + }; + if !(fs.is_expr || deflt) || !check_absent(src, nodes, toks, gaps, n0, nm, Ghost(GCx { ts: g.ts, cx: cxn })) { return None; } nm @@ -11249,7 +11377,7 @@ fn kids_cx4(nodes: &[Node], cxs: &[Cx5], m: usize, c0: &Cx5, c1: &Cx5, c2: &Cx5, } /// Token `x` is not the keyword `w` (it may not exist). -fn not_word_at( +pub(crate) fn not_word_at( src: &[u32], nodes: &[Node], toks: &[DTok], @@ -11982,6 +12110,9 @@ fn check_for_in_of( return None; }, }; + if x > usize::MAX - 8 { + return None; + } let flag = nd.flag; // `for await (`: the `await` is the second token, the head starts after the `(`. let s = if flag { x.saturating_add(3) } else { x.saturating_add(2) }; @@ -12002,8 +12133,11 @@ fn check_for_in_of( // array literal, or an assignment pattern; not `let` (`async` for `of`). let lhs_ok = matches!(kh, NodeKind::ArrayAssignmentPattern | NodeKind::ObjectAssignmentPattern) || (lv_h >= 14 && !matches!(kh, NodeKind::ObjectLiteral | NodeKind::ArrayLiteral)); - let head_ok = decl || (lhs_ok - && not_word_at(src, nodes, toks, gaps, s, &[0x6C, 0x65, 0x74], Ghost(GW { g, w: "let"@ })) + let let_strict = not_word_at(src, nodes, toks, gaps, s, &[0x6C, 0x65, 0x74], Ghost(GW { g, w: "let"@ })); + // `for (let in o)` is a sloppy-mode identifier `let`; only `let [` is excluded for `in`. + let in_next = !sh.of + && word_at(src, nodes, toks, gaps, s.saturating_add(1), &[0x69, 0x6E], Ghost(GW { g, w: "in"@ })); + let head_ok = decl || (lhs_ok && (let_strict || in_next) && (!sh.of || not_word_at(src, nodes, toks, gaps, s, &[0x61, 0x73, 0x79, 0x6E, 0x63], Ghost(GW { g, w: "async"@ })))); // Only `for (var a = 1 in x)` (Annex B.3.5) has a `VariableDeclaration` in its head. let head_first_ok = if decl { @@ -12056,6 +12190,7 @@ fn check_for_in_of( x as int + 2 })); assert(s.saturating_sub(1) as int == s as int - 1); + assert(s.saturating_add(1) as int == s as int + 1); assert(cxm == &done.cxs@[m as int]); assert(mh.saturating_add(1) as int == mh as int + 1); assert(q.saturating_add(1) as int == q as int + 1); @@ -12087,7 +12222,12 @@ fn check_for_in_of( assert(a.nodes[h as int] == nodes@[h as int]@); assert(for_head_ok(a, g.ts, h as int, s as int, sh.of, a.nodes[m as int].flag)) by { if !decl { - assert(!is_kw(g.ts, s as int, "let"@)); + if sh.of || let_strict { + assert(!is_kw(g.ts, s as int, "let"@)); + } else { + assert(is_kw(g.ts, s as int + 1, "in"@)); + assert(!is_p(g.ts, s as int + 1, "["@)); + } } } assert(sh.of ==> first_kid_kind(a, h as int) != NodeKind::VariableDeclaration) by { @@ -15484,7 +15624,6 @@ proof fn lemma_class_done( ) requires toks_wf(ts), - !cx.deflt, 0 <= m < a.nodes.len(), 0 <= k0 < m, 0 <= k1 < m, @@ -15498,7 +15637,7 @@ proof fn lemma_class_done( is_kw(ts, x, "class"@), kd(a, k2) == NodeKind::ClassBody, if kd(a, k0) == NodeKind::Absent { - is_expr && d(a, ts, k0, cx, x + 1, x + 1) && mn == x + 1 && ed(a, ts, k0, x + 1) == mn + (is_expr || cx.deflt) && d(a, ts, k0, cx, x + 1, x + 1) && mn == x + 1 && ed(a, ts, k0, x + 1) == mn } else { kd(a, k0) == NodeKind::BindingIdentifier && node_done(a, ts, k0, cx, x + 1, mn) }, @@ -15557,7 +15696,6 @@ fn check_class( ) -> (r: Option<(usize, usize, i32)>) requires sh.m < nodes.len(), - !g.cx.deflt, nodes@[sh.m as int].kind == (if sh.is_expr { NodeKind::ClassExpression } else { @@ -15623,7 +15761,13 @@ fn check_class( let x1 = x.saturating_add(1); let kn = kind_at(nodes, k0); let mn: usize = if matches!(kn, NodeKind::Absent) { - if !sh.is_expr || !check_absent(src, nodes, toks, gaps, k0, x1, Ghost(g)) { + let deflt = match done.cxs.get(m) { + Some(c) => c.d, + None => { + return None; + }, + }; + if !(sh.is_expr || deflt) || !check_absent(src, nodes, toks, gaps, k0, x1, Ghost(g)) { return None; } x1 diff --git a/crates/clazel-js-syntax/src/arena_m.rs b/crates/clazel-js-syntax/src/arena_m.rs new file mode 100644 index 00000000..e4705c89 --- /dev/null +++ b/crates/clazel-js-syntax/src/arena_m.rs @@ -0,0 +1,1556 @@ +//! Checks of [`spec::d`] for the module items of §16.2: `import` and `export` in all +//! their forms, with import attributes, `export default`, `export * as ns` and string +//! `ModuleExportName`s. Dispatched from [`crate::arena_d::check_derivation`]; each +//! `check_*` has the contract of its siblings there (`node_done` of the node, in its +//! context, only if the specification's `d_module` arm follows from what the children +//! recorded and the executable tokens). The assumptions are those of [`crate::arena_d`]. + +use crate::arena_d::*; +use crate::arena_e::*; +use crate::ast::*; +use crate::spec::*; +use vstd::prelude::*; + +verus! { + +/// The words of the module items, as code points. +pub(crate) proof fn lemma_words_m() + ensures + cps("as"@) =~= seq![0x61u32, 0x73], + cps("from"@) =~= seq![0x66u32, 0x72, 0x6F, 0x6D], + cps("with"@) =~= seq![0x77u32, 0x69, 0x74, 0x68], + cps("default"@) =~= seq![0x64u32, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74], + cps("export"@) =~= seq![0x65u32, 0x78, 0x70, 0x6F, 0x72, 0x74], + cps("*"@) =~= seq![0x2Au32], + cps("}"@) =~= seq![0x7Du32], + cps(":"@) =~= seq![0x3Au32], +{ + reveal_strlit("as"); + reveal_strlit("from"); + reveal_strlit("with"); + reveal_strlit("default"); + reveal_strlit("export"); + reveal_strlit("*"); + reveal_strlit("}"); + reveal_strlit(":"); + assert("as"@ =~= seq!['a', 's']); + assert("from"@ =~= seq!['f', 'r', 'o', 'm']); + assert("with"@ =~= seq!['w', 'i', 't', 'h']); + assert("default"@ =~= seq!['d', 'e', 'f', 'a', 'u', 'l', 't']); + assert("export"@ =~= seq!['e', 'x', 'p', 'o', 'r', 't']); + assert("*"@ =~= seq!['*']); + assert("}"@ =~= seq!['}']); + assert(":"@ =~= seq![':']); +} + +/// The executable form of `is_module_export_name_kind`. +fn name_kind(k: NodeKind) -> (r: bool) + ensures + r == is_module_export_name_kind(k), +{ + matches!(k, NodeKind::IdentifierName | NodeKind::StringLiteral) +} + +// --------------------------------------------------------------------- +// Small nodes: `* as ns`, `a as b`, `k: "v"`. +// --------------------------------------------------------------------- + +/// `NameSpaceImport : * as ImportedBinding`. +#[verifier::spinoff_prover] +proof fn lemma_ns_done(a: AstV, ts: Stream, cx: Ctx, m: int, c: int, x: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c < m, + 0 <= x, + x + 3 <= tn(ts), + a.nodes[m].kind == NodeKind::NameSpaceImport, + a.nodes[m].children =~= seq![c], + is_p(ts, x, "*"@), + is_kw(ts, x + 1, "as"@), + kd(a, c) == NodeKind::BindingIdentifier, + node_done(a, ts, c, cx, x + 2, x + 3), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[x + 2].end, + ensures + node_done(a, ts, m, cx, x, x + 3), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, x + 3)); + assert(a.nodes[m].children[0] == c); + assert(dc(a, ts, m, c, cx, x + 2, x + 3)); + assert(d_module(a, ts, m, cx, x, x + 3)); + lemma_ed_of(a, ts, m, x, x + 3); +} + +/// §16.2.2 `* as ImportedBinding`. +#[verifier::spinoff_prover] +pub(crate) fn check_ns_import( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_m(); + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::NameSpaceImport) || nd.children.len() != 1 { + return None; + } + let c = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo_c, hi_c, _) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if x > usize::MAX - 8 { + return None; + } + let x1 = x.saturating_add(1); + let x2 = x.saturating_add(2); + let x3 = x.saturating_add(3); + if !punct_at(src, nodes, toks, gaps, x, 0x2A, Ghost(GW { g, w: "*"@ })) + || !word_at(src, nodes, toks, gaps, x1, &[0x61, 0x73], Ghost(GW { g, w: "as"@ })) + || !matches!(kind_at(nodes, c), NodeKind::BindingIdentifier) || lo_c != x2 || hi_c != x3 + || !end_ok(src, nodes, toks, gaps, nd.end, x3, Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(x1 as int == x as int + 1); + assert(x2 as int == x as int + 2); + assert(x3 as int == x as int + 3); + assert(a.nodes[m as int].children =~= seq![c as int]) by { + assert(a.nodes[m as int].children.len() == 1); + } + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, 0); + lemma_ns_done(a, g.ts, g.cx, m as int, c as int, x as int); + } + Some((x, x3, -100)) +} + +/// A node of two children `name`, `x`: one token each, with the token between (`as` or `:`) or +/// nothing: `ImportSpecifier`, `ImportAttribute` and `ExportSpecifier`. +#[verifier::spinoff_prover] +proof fn lemma_pair_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + c0: int, + c1: int, + x: int, + j: int, +) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c0 < m, + 0 <= c1 < m, + 0 <= x, + x < j <= tn(ts), + a.nodes[m].children =~= seq![c0, c1], + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + match a.nodes[m].kind { + NodeKind::ImportSpecifier => kd(a, c1) == NodeKind::BindingIdentifier && (if kd(a, c0) + == NodeKind::Absent { + j == x + 1 && d(a, ts, c0, cx, x, x) && node_done(a, ts, c1, cx, x, j) + } else { + is_module_export_name_kind(kd(a, c0)) && is_kw(ts, x + 1, "as"@) && j == x + 3 + && node_done(a, ts, c0, cx, x, x + 1) && node_done(a, ts, c1, cx, x + 2, j) + }), + NodeKind::ImportAttribute => is_module_export_name_kind(kd(a, c0)) && kd(a, c1) + == NodeKind::StringLiteral && is_p(ts, x + 1, ":"@) && j == x + 3 && node_done( + a, + ts, + c0, + cx, + x, + x + 1, + ) && node_done(a, ts, c1, cx, x + 2, j), + NodeKind::ExportSpecifier => is_module_export_name_kind(kd(a, c0)) && node_done( + a, + ts, + c0, + cx, + x, + x + 1, + ) && (if kd(a, c1) == NodeKind::Absent { + j == x + 1 && d(a, ts, c1, cx, x + 1, x + 1) + } else { + is_module_export_name_kind(kd(a, c1)) && is_kw(ts, x + 1, "as"@) && j == x + 3 + && node_done(a, ts, c1, cx, x + 2, j) + }), + _ => false, + }, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c0); + assert(a.nodes[m].children[1] == c1); + match a.nodes[m].kind { + NodeKind::ImportSpecifier => { + if kd(a, c0) == NodeKind::Absent { + assert(dc(a, ts, m, c0, cx, x, x)); + assert(dc(a, ts, m, c1, cx, x, j)); + } else { + assert(dc(a, ts, m, c0, cx, x, x + 1)); + assert(dc(a, ts, m, c1, cx, x + 2, j)); + } + }, + NodeKind::ImportAttribute => { + assert(dc(a, ts, m, c0, cx, x, x + 1)); + assert(dc(a, ts, m, c1, cx, x + 2, j)); + }, + _ => { + assert(dc(a, ts, m, c0, cx, x, x + 1)); + if kd(a, c1) == NodeKind::Absent { + assert(dc(a, ts, m, c1, cx, x + 1, x + 1)); + } else { + assert(dc(a, ts, m, c1, cx, x + 2, j)); + } + }, + } + assert(d_module(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §16.2.2 `ImportSpecifier`, `ImportAttribute`; §16.2.3 `ExportSpecifier`. +#[verifier::spinoff_prover] +pub(crate) fn check_pair( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_m(); + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let kind = nd.kind; + if !matches!(kind, NodeKind::ImportSpecifier | NodeKind::ImportAttribute | NodeKind::ExportSpecifier) + || nd.children.len() != 2 { + return None; + } + let c0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let c1 = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if x > usize::MAX - 8 { + return None; + } + let x1 = x.saturating_add(1); + let x2 = x.saturating_add(2); + let x3 = x.saturating_add(3); + let k0 = kind_at(nodes, c0); + let k1 = kind_at(nodes, c1); + let a0 = matches!(k0, NodeKind::Absent); + let a1 = matches!(k1, NodeKind::Absent); + let j: usize; + match kind { + NodeKind::ImportSpecifier => { + if !matches!(k1, NodeKind::BindingIdentifier) { + return None; + } + let (lo1, hi1, _) = match done_at(done, c1) { + Some(r) => r, + None => { + return None; + }, + }; + if a0 { + if !check_absent(src, nodes, toks, gaps, c0, x, Ghost(g)) || lo1 != x || hi1 != x1 { + return None; + } + j = x1; + } else { + let (lo0, hi0, _) = match done_at(done, c0) { + Some(r) => r, + None => { + return None; + }, + }; + if !name_kind(k0) || lo0 != x || hi0 != x1 || lo1 != x2 || hi1 != x3 + || !word_at(src, nodes, toks, gaps, x1, &[0x61, 0x73], Ghost(GW { g, w: "as"@ })) { + return None; + } + j = x3; + } + }, + NodeKind::ImportAttribute => { + let (lo0, hi0, _) = match done_at(done, c0) { + Some(r) => r, + None => { + return None; + }, + }; + let (lo1, hi1, _) = match done_at(done, c1) { + Some(r) => r, + None => { + return None; + }, + }; + if !name_kind(k0) || !matches!(k1, NodeKind::StringLiteral) || lo0 != x || hi0 != x1 + || lo1 != x2 || hi1 != x3 + || !punct_at(src, nodes, toks, gaps, x1, 0x3A, Ghost(GW { g, w: ":"@ })) { + return None; + } + j = x3; + }, + _ => { + let (lo0, hi0, _) = match done_at(done, c0) { + Some(r) => r, + None => { + return None; + }, + }; + if !name_kind(k0) || lo0 != x || hi0 != x1 { + return None; + } + if a1 { + if !check_absent(src, nodes, toks, gaps, c1, x1, Ghost(g)) { + return None; + } + j = x1; + } else { + let (lo1, hi1, _) = match done_at(done, c1) { + Some(r) => r, + None => { + return None; + }, + }; + if !name_kind(k1) || lo1 != x2 || hi1 != x3 + || !word_at(src, nodes, toks, gaps, x1, &[0x61, 0x73], Ghost(GW { g, w: "as"@ })) { + return None; + } + j = x3; + } + }, + } + if !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(x1 as int == x as int + 1); + assert(x2 as int == x as int + 2); + assert(x3 as int == x as int + 3); + assert(a.nodes[m as int].children =~= seq![c0 as int, c1 as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + assert(kd(a, c0 as int) == k0); + assert(kd(a, c1 as int) == k1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c0 as int, g.cx, 0); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c1 as int, g.cx, 1); + lemma_pair_done(a, g.ts, g.cx, m as int, c0 as int, c1 as int, x as int, j as int); + } + Some((x, j, -100)) +} + +// --------------------------------------------------------------------- +// Braced lists: `{ a, b as c }`, `with { type: "json" }`. +// --------------------------------------------------------------------- + +/// `NamedImports`, `NamedExports`: `{ list }`; `WithClause`: `with { list }`. +#[verifier::spinoff_prover] +proof fn lemma_braced_done(a: AstV, ts: Stream, cx: Ctx, m: int, x: int, s: int, e: int) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= x, + s == (if a.nodes[m].kind == NodeKind::WithClause { + x + 2 + } else { + x + 1 + }), + s <= e < tn(ts), + a.nodes[m].kind == NodeKind::NamedImports || a.nodes[m].kind == NodeKind::NamedExports + || a.nodes[m].kind == NodeKind::WithClause, + dsep(a, ts, m, a.nodes[m].children, 0, cx, s, e, true), + forall|k: int| + 0 <= k < a.nodes[m].children.len() ==> list_item_ok( + a, + #[trigger] a.nodes[m].children[k], + if a.nodes[m].kind == NodeKind::NamedImports { + 11int + } else if a.nodes[m].kind == NodeKind::NamedExports { + 15int + } else { + 13int + }, + ), + a.nodes[m].kind == NodeKind::WithClause ==> (is_kw(ts, x, "with"@) && is_p(ts, x + 1, "{"@)), + a.nodes[m].kind != NodeKind::WithClause ==> is_p(ts, x, "{"@), + is_p(ts, e, "}"@), + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[e].end, + ensures + node_done(a, ts, m, cx, x, e + 1), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, e + 1)); + let kk = a.nodes[m].kind; + assert forall|k: int| 0 <= k < a.nodes[m].children.len() implies kd( + a, + #[trigger] a.nodes[m].children[k], + ) == (if kk == NodeKind::NamedImports { + NodeKind::ImportSpecifier + } else if kk == NodeKind::NamedExports { + NodeKind::ExportSpecifier + } else { + NodeKind::ImportAttribute + }) by { + assert(list_item_ok(a, a.nodes[m].children[k], if kk == NodeKind::NamedImports { + 11int + } else if kk == NodeKind::NamedExports { + 15int + } else { + 13int + })); + } + assert(all_kind2(a, a.nodes[m].children, 0, NodeKind::ImportSpecifier, NodeKind::ImportSpecifier) + || kk != NodeKind::NamedImports); + assert(d_module(a, ts, m, cx, x, e + 1)); + lemma_ed_of(a, ts, m, x, e + 1); +} + +/// §16.2.2 `NamedImports`, `WithClause`; §16.2.3 `NamedExports`. +#[verifier::spinoff_prover] +pub(crate) fn check_braced( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_m(); + lemma_punct_text(); + lemma_brace_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let kind = nd.kind; + let with = matches!(kind, NodeKind::WithClause); + if !(with || matches!(kind, NodeKind::NamedImports | NodeKind::NamedExports)) { + return None; + } + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if x > usize::MAX - 8 { + return None; + } + let x1 = x.saturating_add(1); + let x2 = x.saturating_add(2); + let s: usize = if with { x2 } else { x1 }; + if with { + if !word_at(src, nodes, toks, gaps, x, &[0x77, 0x69, 0x74, 0x68], Ghost(GW { g, w: "with"@ })) + || !punct_at(src, nodes, toks, gaps, x1, 0x7B, Ghost(GW { g, w: "{"@ })) { + return None; + } + } else if !punct_at(src, nodes, toks, gaps, x, 0x7B, Ghost(GW { g, w: "{"@ })) { + return None; + } + let mode: u8 = if matches!(kind, NodeKind::NamedImports) { + 11 + } else if matches!(kind, NodeKind::NamedExports) { + 15 + } else { + 13 + }; + let ls = ListSpec { m, start: s, mode, trail: true }; + let e = match check_list(src, nodes, toks, gaps, done, &ls, Ghost(g)) { + Some(e) => e, + None => { + return None; + }, + }; + let e1 = e.saturating_add(1); + if !punct_at(src, nodes, toks, gaps, e, 0x7D, Ghost(GW { g, w: "}"@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, e1, Ghost(g)) { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(x1 as int == x as int + 1); + assert(x2 as int == x as int + 2); + assert(e1 as int == e as int + 1); + assert(a.nodes[m as int].kind == kind); + assert(s as int == (if a.nodes[m as int].kind == NodeKind::WithClause { + x as int + 2 + } else { + x as int + 1 + })); + assert(mode as int == (if a.nodes[m as int].kind == NodeKind::NamedImports { + 11int + } else if a.nodes[m as int].kind == NodeKind::NamedExports { + 15int + } else { + 13int + })); + lemma_braced_done(a, g.ts, g.cx, m as int, x as int, s as int, e as int); + } + Some((x, e1, -100)) +} + +// --------------------------------------------------------------------- +// `import` declarations. +// --------------------------------------------------------------------- + +/// Where [`check_with_semi`] looks: child `k` of node `m`, from token `s`, the node ending at `end`. +pub struct WsSpec { + /// The node. + pub m: usize, + /// The index of the child that is the optional `WithClause`. + pub k: usize, + /// The token the clause would start at. + pub s: usize, + /// Where the node's last token ends. + pub end: usize, +} + +/// Child `k` of node `m` is an optional `WithClause` starting at token `s`, then the `;` +/// (`spec::d_with_semi`); `end` is where the node's last token ends. +#[verifier::spinoff_prover] +pub(crate) fn check_with_semi( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + ws: &WsSpec, + Ghost(g): Ghost, +) -> (r: Option) + requires + ws.m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, ws.m as int), + kids_ok(arena_of(nodes@), done.cxs@, ws.m as int, g.cx), + ensures + match r { + Some(j) => ws.k < arena_of(nodes@).nodes[ws.m as int].children.len() && d_with_semi( + arena_of(nodes@), + g.ts, + ws.m as int, + arena_of(nodes@).nodes[ws.m as int].children[ws.k as int], + g.cx, + ws.s as int, + j as int, + ) && 1 <= j && j <= toks.len() && g.ts.toks[j as int - 1].end == ws.end as int, + None => true, + }, +{ + let (m, k, s, end) = (ws.m, ws.k, ws.s, ws.end); + proof { + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + } + let c = match kid_of(nodes, m, k) { + Some(c) => c, + None => { + return None; + }, + }; + let kc = kind_at(nodes, c); + let r: usize = if matches!(kc, NodeKind::Absent) { + if !check_absent(src, nodes, toks, gaps, c, s, Ghost(g)) { + return None; + } + s + } else if matches!(kc, NodeKind::WithClause) { + let (lo, hi, _) = match done_at(done, c) { + Some(r) => r, + None => { + return None; + }, + }; + if lo != s { + return None; + } + hi + } else { + return None; + }; + let j = match find_semi(src, nodes, toks, gaps, r, end, Ghost(g)) { + Some(j) => j, + None => { + return None; + }, + }; + proof { + let a = arena_of(nodes@); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c as int, g.cx, k as int); + assert(a.nodes[m as int].children[k as int] == c as int); + assert(kd(a, c as int) == kc); + if kc == NodeKind::WithClause { + assert(node_done(a, g.ts, c as int, g.cx, s as int, r as int)); + } + assert(d_with_semi(a, g.ts, m as int, c as int, g.cx, s as int, j as int)); + } + Some(j) +} + +/// `ImportClause`. +#[verifier::spinoff_prover] +proof fn lemma_import_clause_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + c0: int, + c1: int, + x: int, + j: int, +) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c0 < m, + 0 <= c1 < m, + 0 <= x, + x < j <= tn(ts), + a.nodes[m].kind == NodeKind::ImportClause, + a.nodes[m].children =~= seq![c0, c1], + kd(a, c0) == NodeKind::BindingIdentifier || kd(a, c0) == NodeKind::Absent, + kd(a, c1) == NodeKind::NameSpaceImport || kd(a, c1) == NodeKind::NamedImports || kd(a, c1) + == NodeKind::Absent, + if kd(a, c1) == NodeKind::Absent { + kd(a, c0) == NodeKind::BindingIdentifier && j == x + 1 && node_done( + a, + ts, + c0, + cx, + x, + x + 1, + ) && d(a, ts, c1, cx, j, j) + } else if kd(a, c0) == NodeKind::Absent { + d(a, ts, c0, cx, x, x) && node_done(a, ts, c1, cx, x, j) + } else { + node_done(a, ts, c0, cx, x, x + 1) && is_p(ts, x + 1, ","@) && node_done( + a, + ts, + c1, + cx, + x + 2, + j, + ) + }, + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c0); + assert(a.nodes[m].children[1] == c1); + if kd(a, c1) == NodeKind::Absent { + assert(dc(a, ts, m, c0, cx, x, j)); + assert(dc(a, ts, m, c1, cx, j, j)); + } else if kd(a, c0) == NodeKind::Absent { + assert(dc(a, ts, m, c0, cx, x, x)); + assert(dc(a, ts, m, c1, cx, x, j)); + } else { + assert(dc(a, ts, m, c0, cx, x, x + 1)); + assert(dc(a, ts, m, c1, cx, x + 2, j)); + } + assert(d_module(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §16.2.2 `ImportClause`. +#[verifier::spinoff_prover] +pub(crate) fn check_import_clause( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_e(); + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ImportClause) || nd.children.len() != 2 { + return None; + } + let c0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let c1 = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if x > usize::MAX - 8 { + return None; + } + let x1 = x.saturating_add(1); + let x2 = x.saturating_add(2); + let k0 = kind_at(nodes, c0); + let k1 = kind_at(nodes, c1); + if !(matches!(k0, NodeKind::BindingIdentifier | NodeKind::Absent) + && matches!(k1, NodeKind::NameSpaceImport | NodeKind::NamedImports | NodeKind::Absent)) { + return None; + } + let j: usize = if matches!(k1, NodeKind::Absent) { + let (lo0, hi0, _) = match done_at(done, c0) { + Some(r) => r, + None => { + return None; + }, + }; + if !matches!(k0, NodeKind::BindingIdentifier) || lo0 != x || hi0 != x1 + || !check_absent(src, nodes, toks, gaps, c1, x1, Ghost(g)) { + return None; + } + x1 + } else if matches!(k0, NodeKind::Absent) { + let (lo1, hi1, _) = match done_at(done, c1) { + Some(r) => r, + None => { + return None; + }, + }; + if !check_absent(src, nodes, toks, gaps, c0, x, Ghost(g)) || lo1 != x { + return None; + } + hi1 + } else { + let (lo0, hi0, _) = match done_at(done, c0) { + Some(r) => r, + None => { + return None; + }, + }; + let (lo1, hi1, _) = match done_at(done, c1) { + Some(r) => r, + None => { + return None; + }, + }; + if lo0 != x || hi0 != x1 || lo1 != x2 + || !punct_n_at(src, nodes, toks, gaps, x1, &[0x2C], Ghost(GW { g, w: ","@ })) { + return None; + } + hi1 + }; + if !end_ok(src, nodes, toks, gaps, nd.end, j, Ghost(g)) || j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(x1 as int == x as int + 1); + assert(x2 as int == x as int + 2); + assert(a.nodes[m as int].children =~= seq![c0 as int, c1 as int]) by { + assert(a.nodes[m as int].children.len() == 2); + } + assert(kd(a, c0 as int) == k0); + assert(kd(a, c1 as int) == k1); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c0 as int, g.cx, 0); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c1 as int, g.cx, 1); + lemma_import_clause_done(a, g.ts, g.cx, m as int, c0 as int, c1 as int, x as int, j as int); + } + Some((x, j, -100)) +} + +/// `ImportDeclaration`. +#[verifier::spinoff_prover] +proof fn lemma_import_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + c0: int, + c1: int, + c2: int, + x: int, + mm: int, + j: int, +) + requires + toks_wf(ts), + 0 <= m < a.nodes.len(), + 0 <= c0 < m, + 0 <= c1 < m, + 0 <= c2 < m, + 0 <= x, + x < j <= tn(ts), + a.nodes[m].kind == NodeKind::ImportDeclaration, + a.nodes[m].children =~= seq![c0, c1, c2], + is_kw(ts, x, "import"@), + kd(a, c1) == NodeKind::StringLiteral, + kd(a, c0) == NodeKind::Absent || kd(a, c0) == NodeKind::ImportClause, + if kd(a, c0) == NodeKind::Absent { + mm == x + 1 && d(a, ts, c0, cx, x + 1, x + 1) && ed(a, ts, c0, x + 1) == x + 1 + && node_done(a, ts, c1, cx, mm, mm + 1) && d_with_semi(a, ts, m, c2, cx, mm + 1, j) + } else { + node_done(a, ts, c0, cx, x + 1, mm) && is_kw(ts, mm, "from"@) && node_done( + a, + ts, + c1, + cx, + mm + 1, + mm + 2, + ) && d_with_semi(a, ts, m, c2, cx, mm + 2, j) + }, + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(a.nodes[m].children[0] == c0); + assert(a.nodes[m].children[1] == c1); + assert(a.nodes[m].children[2] == c2); + assert(dc(a, ts, m, c0, cx, x + 1, mm)); + assert(dc(a, ts, m, c1, cx, mm + if kd(a, c0) == NodeKind::Absent { 0int } else { 1int }, mm + if kd( + a, + c0, + ) == NodeKind::Absent { + 1int + } else { + 2int + })); + assert(d_module(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §16.2.2 `import ImportClause from "m" with {..} ;` and `import "m" with {..} ;`. +#[verifier::spinoff_prover] +pub(crate) fn check_import( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_ok(arena_of(nodes@), done.cxs@, m as int, g.cx), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_m(); + lemma_words_e(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ImportDeclaration) || nd.children.len() != 3 { + return None; + } + let c0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let c1 = match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if x > usize::MAX - 8 { + return None; + } + let x1 = x.saturating_add(1); + let k0 = kind_at(nodes, c0); + let (lo1, hi1, _) = match done_at(done, c1) { + Some(r) => r, + None => { + return None; + }, + }; + if !word_at(src, nodes, toks, gaps, x, &[0x69, 0x6D, 0x70, 0x6F, 0x72, 0x74], Ghost(GW { g, w: "import"@ })) + || !matches!(kind_at(nodes, c1), NodeKind::StringLiteral) + || !matches!(k0, NodeKind::Absent | NodeKind::ImportClause) { + return None; + } + let mm: usize; + let s: usize; + if matches!(k0, NodeKind::Absent) { + if !check_absent(src, nodes, toks, gaps, c0, x1, Ghost(g)) || lo1 != x1 { + return None; + } + mm = x1; + s = hi1; + } else { + let (lo0, hi0, _) = match done_at(done, c0) { + Some(r) => r, + None => { + return None; + }, + }; + let h1 = hi0.saturating_add(1); + if lo0 != x1 || !word_at(src, nodes, toks, gaps, hi0, &[0x66, 0x72, 0x6F, 0x6D], Ghost(GW { g, w: "from"@ })) + || lo1 != h1 { + return None; + } + mm = hi0; + s = hi1; + } + if s != mm.saturating_add(if matches!(k0, NodeKind::Absent) { 1 } else { 2 }) || hi1 != s { + return None; + } + let j = match check_with_semi(src, nodes, toks, gaps, done, &WsSpec { m, k: 2, s, end: nd.end }, Ghost(g)) { + Some(j) => j, + None => { + return None; + }, + }; + if j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(x1 as int == x as int + 1); + let c2g: int = a.nodes[m as int].children[2]; + lemma_child_before(a, m as int, 2); + assert(a.nodes[m as int].children =~= seq![c0 as int, c1 as int, c2g]) by { + assert(a.nodes[m as int].children.len() == 3); + } + assert(kd(a, c0 as int) == k0); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c0 as int, g.cx, 0); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c1 as int, g.cx, 1); + assert(a.nodes[m as int].children[2] == c2g); + if k0 == NodeKind::Absent { + assert(mm as int == x as int + 1); + assert(s as int == mm as int + 1); + } else { + assert(mm.saturating_add(2) as int == mm as int + 2); + assert(s as int == mm as int + 2); + } + lemma_import_done( + a, + g.ts, + g.cx, + m as int, + c0 as int, + c1 as int, + c2g, + x as int, + mm as int, + j as int, + ); + } + Some((x, j, -100)) +} + +// --------------------------------------------------------------------- +// `export` declarations. +// --------------------------------------------------------------------- + +/// The context of `export default` declarations: `[+Default]`. +pub open spec fn cx_default(cx: Ctx) -> Ctx { + Ctx { yield_: cx.yield_, await_: cx.await_, in_: cx.in_, return_: cx.return_, deflt: true } +} + +/// `ExportDeclaration`: `c0`, `c1`, `c2` are the children there are; `mm` is where `c0` ends. +#[verifier::spinoff_prover] +#[verifier::rlimit(200)] +proof fn lemma_export_done( + a: AstV, + ts: Stream, + cx: Ctx, + m: int, + c0: int, + c1: int, + c2: int, + x: int, + mm: int, + j: int, +) + requires + toks_wf(ts), + cx_in(cx, true) == cx, + 0 <= m < a.nodes.len(), + 0 <= c0 < m, + 0 <= c1 < m, + 0 <= c2 < m, + 0 <= x, + x < j <= tn(ts), + a.nodes[m].kind == NodeKind::ExportDeclaration, + a.nodes[m].children.len() == (match a.nodes[m].op { + Op::ExportAll => 2int, + Op::ExportAllAs | Op::ExportFrom => 3int, + _ => 1int, + }), + a.nodes[m].children[0] == c0, + a.nodes[m].children.len() >= 2 ==> a.nodes[m].children[1] == c1, + a.nodes[m].children.len() >= 3 ==> a.nodes[m].children[2] == c2, + is_kw(ts, x, "export"@), + match a.nodes[m].op { + Op::ExportAll => is_p(ts, x + 1, "*"@) && is_kw(ts, x + 2, "from"@) && kd(a, c0) + == NodeKind::StringLiteral && node_done(a, ts, c0, cx, x + 3, x + 4) + && d_with_semi(a, ts, m, c1, cx, x + 4, j), + Op::ExportAllAs => is_p(ts, x + 1, "*"@) && is_kw(ts, x + 2, "as"@) + && is_module_export_name_kind(kd(a, c0)) && node_done(a, ts, c0, cx, x + 3, x + 4) + && is_kw(ts, x + 4, "from"@) && kd(a, c1) == NodeKind::StringLiteral && node_done( + a, + ts, + c1, + cx, + x + 5, + x + 6, + ) && d_with_semi(a, ts, m, c2, cx, x + 6, j), + Op::ExportFrom => kd(a, c0) == NodeKind::NamedExports && kd(a, c1) + == NodeKind::StringLiteral && node_done(a, ts, c0, cx, x + 1, mm) && is_kw( + ts, + mm, + "from"@, + ) && node_done(a, ts, c1, cx, mm + 1, mm + 2) && d_with_semi(a, ts, m, c2, cx, mm + 2, j), + Op::ExportNamed => kd(a, c0) == NodeKind::NamedExports && node_done( + a, + ts, + c0, + cx, + x + 1, + mm, + ) && semi(ts, mm, j, false), + Op::ExportVar => kd(a, c0) == NodeKind::VariableStatement && node_done( + a, + ts, + c0, + cx, + x + 1, + j, + ), + Op::ExportDecl => is_declaration_kind(kd(a, c0)) && node_done(a, ts, c0, cx, x + 1, j), + Op::ExportDefaultHoistable => is_kw(ts, x + 1, "default"@) && is_hoistable_kind(kd(a, c0)) + && node_done(a, ts, c0, cx_default(cx), x + 2, j), + Op::ExportDefaultClass => is_kw(ts, x + 1, "default"@) && kd(a, c0) + == NodeKind::ClassDeclaration && node_done(a, ts, c0, cx_default(cx), x + 2, j), + Op::ExportDefaultExpression => is_kw(ts, x + 1, "default"@) && !is_kw( + ts, + x + 2, + "function"@, + ) && !is_kw(ts, x + 2, "async"@) && !is_kw(ts, x + 2, "class"@) && lvl(a, c0) >= 0 + && node_done(a, ts, c0, cx, x + 2, mm) && semi(ts, mm, j, false), + _ => false, + }, + a.nodes[m].start == ts.toks[x].start, + a.nodes[m].end == ts.toks[j - 1].end, + ensures + node_done(a, ts, m, cx, x, j), + lvl(a, m) == -100, +{ + assert(span_ok(a, ts, m, x, j)); + assert(cx_default(cx) == Ctx { + yield_: cx.yield_, + await_: cx.await_, + in_: cx.in_, + return_: cx.return_, + deflt: true, + }); + match a.nodes[m].op { + Op::ExportAll => { + assert(dc(a, ts, m, c0, cx, x + 3, x + 4)); + }, + Op::ExportAllAs => { + assert(dc(a, ts, m, c0, cx, x + 3, x + 4)); + assert(dc(a, ts, m, c1, cx, x + 5, x + 6)); + }, + Op::ExportFrom => { + assert(dc(a, ts, m, c0, cx, x + 1, mm)); + assert(dc(a, ts, m, c1, cx, mm + 1, mm + 2)); + }, + Op::ExportNamed => { + assert(dc(a, ts, m, c0, cx, x + 1, mm)); + }, + Op::ExportVar | Op::ExportDecl => { + assert(dc(a, ts, m, c0, cx, x + 1, j)); + }, + Op::ExportDefaultHoistable | Op::ExportDefaultClass => { + assert(dc(a, ts, m, c0, cx_default(cx), x + 2, j)); + }, + _ => { + assert(is_assign_expr(a, c0)); + assert(dc(a, ts, m, c0, cx_in(cx, true), x + 2, mm)); + }, + } + assert(d_module(a, ts, m, cx, x, j)); + lemma_ed_of(a, ts, m, x, j); +} + +/// §16.2.3 `ExportDeclaration`, in all its forms. +#[verifier::spinoff_prover] +#[verifier::rlimit(300)] +pub(crate) fn check_export( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + done: &Done, + m: usize, + Ghost(g): Ghost, +) -> (r: Option<(usize, usize, i32)>) + requires + m < nodes.len(), + cx_in(g.cx, true) == g.cx, + env_ok(src@, nodes@, toks@, gaps@, g.ts), + inv(arena_of(nodes@), g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int), + cx_of(done.cxs@[m as int]) == g.cx, + kids_ok( + arena_of(nodes@), + done.cxs@, + m as int, + if nodes@[m as int].op == Op::ExportDefaultHoistable || nodes@[m as int].op + == Op::ExportDefaultClass { + cx_default(g.cx) + } else { + g.cx + }, + ), + ensures + match r { + Some((l0, h0, l)) => node_done( + arena_of(nodes@), + g.ts, + m as int, + g.cx, + l0 as int, + h0 as int, + ) && l as int == lvl(arena_of(nodes@), m as int), + None => true, + }, +{ + proof { + lemma_words_m(); + lemma_words_e(); + lemma_kw_text(); + lemma_punct_text(); + lemma_env_toks_wf(src@, nodes@, toks@, gaps@, g.ts); + lemma_node_view(nodes@, m as int); + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + if !matches!(nd.kind, NodeKind::ExportDeclaration) { + return None; + } + let op = nd.op; + let want: usize = match op { + Op::ExportAll => 2, + Op::ExportAllAs | Op::ExportFrom => 3, + Op::ExportNamed | Op::ExportVar | Op::ExportDecl | Op::ExportDefaultHoistable + | Op::ExportDefaultClass | Op::ExportDefaultExpression => 1, + _ => { + return None; + }, + }; + if nd.children.len() != want { + return None; + } + let c0 = match kid_of(nodes, m, 0) { + Some(c) => c, + None => { + return None; + }, + }; + let (lo0, hi0, lv0) = match done_at(done, c0) { + Some(r) => r, + None => { + return None; + }, + }; + let x = match start_tok(src, nodes, toks, gaps, done, m, Ghost(g)) { + Some(x) => x, + None => { + return None; + }, + }; + if x > usize::MAX - 16 || !word_at(src, nodes, toks, gaps, x, &[0x65, 0x78, 0x70, 0x6F, 0x72, 0x74], Ghost(GW { g, w: "export"@ })) { + return None; + } + let x1 = x.saturating_add(1); + let x2 = x.saturating_add(2); + let x3 = x.saturating_add(3); + let x4 = x.saturating_add(4); + let k0 = kind_at(nodes, c0); + // `c1` is the second child where there is one (`c0` stands in otherwise). + let c1 = if want >= 2 { + match kid_of(nodes, m, 1) { + Some(c) => c, + None => { + return None; + }, + } + } else { + c0 + }; + let j: usize; + match op { + Op::ExportAll | Op::ExportAllAs => { + let all_as = matches!(op, Op::ExportAllAs); + if !punct_at(src, nodes, toks, gaps, x1, 0x2A, Ghost(GW { g, w: "*"@ })) { + return None; + } + if all_as { + if !word_at(src, nodes, toks, gaps, x2, &[0x61, 0x73], Ghost(GW { g, w: "as"@ })) + || !name_kind(k0) { + return None; + } + } else if !word_at(src, nodes, toks, gaps, x2, &[0x66, 0x72, 0x6F, 0x6D], Ghost(GW { g, w: "from"@ })) + || !matches!(k0, NodeKind::StringLiteral) { + return None; + } + if lo0 != x3 || hi0 != x4 { + return None; + } + if all_as { + let (lo1, hi1, _) = match done_at(done, c1) { + Some(r) => r, + None => { + return None; + }, + }; + let x5 = x.saturating_add(5); + let x6 = x.saturating_add(6); + if !word_at(src, nodes, toks, gaps, x4, &[0x66, 0x72, 0x6F, 0x6D], Ghost(GW { g, w: "from"@ })) + || !matches!(kind_at(nodes, c1), NodeKind::StringLiteral) || lo1 != x5 || hi1 != x6 { + return None; + } + j = match check_with_semi(src, nodes, toks, gaps, done, &WsSpec { m, k: 2, s: x6, end: nd.end }, Ghost(g)) { + Some(j) => j, + None => { + return None; + }, + }; + } else { + j = match check_with_semi(src, nodes, toks, gaps, done, &WsSpec { m, k: 1, s: x4, end: nd.end }, Ghost(g)) { + Some(j) => j, + None => { + return None; + }, + }; + } + }, + Op::ExportFrom => { + if !matches!(k0, NodeKind::NamedExports) || lo0 != x1 + || !word_at(src, nodes, toks, gaps, hi0, &[0x66, 0x72, 0x6F, 0x6D], Ghost(GW { g, w: "from"@ })) { + return None; + } + let (lo1, hi1, _) = match done_at(done, c1) { + Some(r) => r, + None => { + return None; + }, + }; + let h1 = hi0.saturating_add(1); + let h2 = hi0.saturating_add(2); + if !matches!(kind_at(nodes, c1), NodeKind::StringLiteral) || lo1 != h1 || hi1 != h2 { + return None; + } + j = match check_with_semi(src, nodes, toks, gaps, done, &WsSpec { m, k: 2, s: h2, end: nd.end }, Ghost(g)) { + Some(j) => j, + None => { + return None; + }, + }; + }, + Op::ExportNamed => { + if !matches!(k0, NodeKind::NamedExports) || lo0 != x1 { + return None; + } + j = match find_semi(src, nodes, toks, gaps, hi0, nd.end, Ghost(g)) { + Some(j) => j, + None => { + return None; + }, + }; + }, + Op::ExportVar | Op::ExportDecl => { + let kind_ok = if matches!(op, Op::ExportVar) { + matches!(k0, NodeKind::VariableStatement) + } else { + matches!( + k0, + NodeKind::FunctionDeclaration | NodeKind::GeneratorDeclaration + | NodeKind::AsyncFunctionDeclaration | NodeKind::AsyncGeneratorDeclaration + | NodeKind::ClassDeclaration | NodeKind::LexicalDeclaration + ) + }; + if !kind_ok || lo0 != x1 || !end_ok(src, nodes, toks, gaps, nd.end, hi0, Ghost(g)) { + return None; + } + j = hi0; + }, + Op::ExportDefaultHoistable | Op::ExportDefaultClass => { + let kind_ok = if matches!(op, Op::ExportDefaultClass) { + matches!(k0, NodeKind::ClassDeclaration) + } else { + matches!( + k0, + NodeKind::FunctionDeclaration | NodeKind::GeneratorDeclaration + | NodeKind::AsyncFunctionDeclaration | NodeKind::AsyncGeneratorDeclaration + ) + }; + if !kind_ok || lo0 != x2 + || !word_at(src, nodes, toks, gaps, x1, &[0x64, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74], Ghost(GW { g, w: "default"@ })) + || !end_ok(src, nodes, toks, gaps, nd.end, hi0, Ghost(g)) { + return None; + } + j = hi0; + }, + _ => { + if lv0 < 0 || lo0 != x2 + || !word_at(src, nodes, toks, gaps, x1, &[0x64, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74], Ghost(GW { g, w: "default"@ })) + || !not_word_at(src, nodes, toks, gaps, x2, &[0x66, 0x75, 0x6E, 0x63, 0x74, 0x69, 0x6F, 0x6E], Ghost(GW { g, w: "function"@ })) + || !not_word_at(src, nodes, toks, gaps, x2, &[0x61, 0x73, 0x79, 0x6E, 0x63], Ghost(GW { g, w: "async"@ })) + || !not_word_at(src, nodes, toks, gaps, x2, &[0x63, 0x6C, 0x61, 0x73, 0x73], Ghost(GW { g, w: "class"@ })) { + return None; + } + j = match find_semi(src, nodes, toks, gaps, hi0, nd.end, Ghost(g)) { + Some(j) => j, + None => { + return None; + }, + }; + }, + } + if j <= x { + return None; + } + proof { + let a = arena_of(nodes@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].op == op); + assert(x1 as int == x as int + 1); + assert(x2 as int == x as int + 2); + assert(x3 as int == x as int + 3); + assert(x4 as int == x as int + 4); + let dd = op == Op::ExportDefaultHoistable || op == Op::ExportDefaultClass; + let ck = if dd { cx_default(g.cx) } else { g.cx }; + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c0 as int, ck, 0); + assert(a.nodes[m as int].children[0] == c0 as int); + if a.nodes[m as int].children.len() >= 2 { + assert(a.nodes[m as int].children[1] == c1 as int); + lemma_inv_get(a, g.ts, done.cxs@, done.lo@, done.hi@, done.lv@, m as int, c1 as int, ck, 1); + } + let c2g: int = if a.nodes[m as int].children.len() >= 3 { a.nodes[m as int].children[2] } else { c0 as int }; + if a.nodes[m as int].children.len() >= 3 { + lemma_child_before(a, m as int, 2); + assert(a.nodes[m as int].children[2] == c2g); + } + assert(kd(a, c0 as int) == k0); + match op { + Op::ExportAllAs => { + assert(x.saturating_add(5) as int == x as int + 5); + assert(x.saturating_add(6) as int == x as int + 6); + }, + Op::ExportFrom => { + assert(hi0.saturating_add(1) as int == hi0 as int + 1); + assert(hi0.saturating_add(2) as int == hi0 as int + 2); + }, + _ => {}, + } + assert(g.cx.in_ || !g.cx.in_); + lemma_export_done( + a, + g.ts, + g.cx, + m as int, + c0 as int, + c1 as int, + c2g, + x as int, + hi0 as int, + j as int, + ); + } + Some((x, j, -100)) +} + +} // verus! diff --git a/crates/clazel-js-syntax/src/lib.rs b/crates/clazel-js-syntax/src/lib.rs index 97b78f93..0b486106 100644 --- a/crates/clazel-js-syntax/src/lib.rs +++ b/crates/clazel-js-syntax/src/lib.rs @@ -57,6 +57,7 @@ pub mod api; pub mod arena_d; pub mod arena_e; +pub mod arena_m; pub mod ast; pub mod check; pub mod contract; diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index 8f16fb3a..47e64a25 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -246,6 +246,70 @@ fn import_meta_is_verified_in_a_module() { } } +/// Every form of `import` and `export` (§16.2). +#[test] +fn module_items_are_verified() { + for s in [ + "import a from 'b';", + "import 'b';", + "import * as ns from 'b';", + "import a, * as ns from 'b';", + "import a, { b, c as d } from 'b';", + "import { } from 'b';", + "import { a, } from 'b'\nx", + "import { \"str\" as s } from 'b';", + "import { default as x } from 'b';", + "import a from 'b' with { type: 'json' };", + "import 'b' with { };", + "import a from 'b' with { 'type': 'json', };", + "export default 1;", + "export default function () {}", + "export default function f() {}", + "export default async function () {}", + "export default function* () {}", + "export default class {}", + "export default class A { m() {} static s() {} }", + "export default a + b", + "export { };", + "var a; export { a as \"b\", a as c, };", + "export { a } from 'b';", + "export { a as b } from 'b' with { type: 'json' };", + "export * from 'b';", + "export * as ns from 'b';", + "export * as \"x y\" from 'b' with { a: 'b' };", + "export const x = 1, y = 2;", + "export let z;", + "export var v;", + "export function f() {}", + "export async function f() {}", + "export class A {}", + "import.meta; await 1; export default await 1;", + ] { + assert!( + derivation(s, SourceGoal::Module) == Some(Derivation::Verified), + "{s}" + ); + } +} + +/// The last gaps of the script grammar: `let` as an identifier head, and `await`, `yield` +/// and classes in `[~In]` heads. +#[test] +fn leftover_script_gaps_are_verified() { + for s in [ + "for (let in o) ;", + "for (var i = class {}; ;) ;", + "for (var i = class A extends B { m() {} }; ;) ;", + "async function f() { for (var i = await x; ;) ; }", + "function* g() { for (var i = yield x; ;) ; }", + ] { + assert!( + derivation(s, SourceGoal::Script) == Some(Derivation::Verified), + "{s}" + ); + } +} + /// Productions only a sloppy-mode `Script` has. #[test] fn covered_sloppy_programs_are_verified() { @@ -265,7 +329,7 @@ fn covered_sloppy_programs_are_verified() { #[test] fn other_programs_are_unsupported_not_failed() { - for s in ["for (var i = class {};;) ;", "for (let in o) ;"] { + for s in ["for (var i = class { x = 1 };;) ;", "for (var i = class { #p; };;) ;"] { assert!( derivation(s, SourceGoal::Script) == Some(Derivation::Unsupported), "{s}" @@ -288,7 +352,7 @@ fn errors_are_still_errors() { fn what_the_check_costs() { let body = "(1 + 2 * 3) < 4 - 5 / 6 % 7;\n".repeat(60_000); let covered = cps(&body); - let stopped = cps(&format!("for (var i = class {{}};;) ;\n{body}")); + let stopped = cps(&format!("for (var i = class {{ x = 1 }};;) ;\n{body}")); let time = |src: &[u32]| { let t = Instant::now(); let r = parse_checked(src, SourceGoal::Script); diff --git a/crates/clazel-js-syntax/tests/test262.rs b/crates/clazel-js-syntax/tests/test262.rs index 8ab585b3..9ea6b155 100644 --- a/crates/clazel-js-syntax/tests/test262.rs +++ b/crates/clazel-js-syntax/tests/test262.rs @@ -292,8 +292,23 @@ fn test262_verified_share() -> Result<(), String> { hv += 1; } } + // The `_FIXTURE.js` modules the tests import. + let mut fixtures = Vec::new(); + all_js(&root(), &mut fixtures); + let (mut fv, mut fnn) = (0usize, 0usize); + for f in fixtures + .iter() + .filter(|f| f.to_string_lossy().ends_with("_FIXTURE.js")) + { + let text = std::fs::read_to_string(f).map_err(|e| e.to_string())?; + let src: Vec = text.chars().map(u32::from).collect(); + if let Ok((_, d)) = parse_checked(&src, SourceGoal::Module) { + fnn += 1; + fv += usize::from(d == Derivation::Verified); + } + } println!( - "Verified: {verified} of {positives} script positive runs, {mverified} of {mpositives} module positive runs, {hv} of {hn} harness files" + "Verified: {verified} of {positives} script positive runs, {mverified} of {mpositives} module positive runs, {fv} of {fnn} module fixtures, {hv} of {hn} harness files" ); Ok(()) } From 3c73133ea7e4369db7b99868ea34e6eff2124eb5 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 13:56:49 +0000 Subject: [PATCH 012/195] clazel-js-heap: the contract of element storage (spec, invariants, fallback rule) Stated before the implementation (CLAUDE.md rule 3): the abstract array, refinement, representation well-formedness, the dense-to-sparse rule and the memory bound. Co-Authored-By: Claude Opus 5.5 --- .../clazel-js-heap/src/elements/contract.rs | 301 ++++++++++++++++++ crates/clazel-js-heap/src/elements/mod.rs | 6 + crates/clazel-js-heap/src/lib.rs | 1 + 3 files changed, 308 insertions(+) create mode 100644 crates/clazel-js-heap/src/elements/contract.rs create mode 100644 crates/clazel-js-heap/src/elements/mod.rs diff --git a/crates/clazel-js-heap/src/elements/contract.rs b/crates/clazel-js-heap/src/elements/contract.rs new file mode 100644 index 00000000..158ad495 --- /dev/null +++ b/crates/clazel-js-heap/src/elements/contract.rs @@ -0,0 +1,301 @@ +//! The contract of element storage (phase-7.md item 7.5, "Elements"), stated +//! before the implementation (CLAUDE.md rule 3). +//! +//! # What is modelled +//! +//! The indexed properties of an Array exotic object, ECMA-262 §10.4.2: a +//! `length` (a `u32`, §10.4.2.1) and, for some array indices below it, a +//! value. This is [`Spec`]. The implementation ([`super::Elements`]) must +//! behave exactly as `Spec` does, whichever representation it holds. +//! +//! Modelling choices (SPEC-STYLE.md): +//! +//! - **Values are `u64` bit patterns.** A value is a NaN-boxed +//! [`crate::value::Value`]; this module does not look inside, except that +//! [`HOLE_BITS`] means "no element here". +//! - **Every element is a plain data property** with all three attributes +//! true. Elements with other attributes, accessors, and a non-writable +//! `length` are a later slice (they need a place for the attributes); an +//! array that needs one will leave this storage. +//! - **A hole is the absence of an element.** [`Spec`] stores no hole; +//! a [`Spec::set`] of the hole value is refused rather than treated as a +//! delete, so a caller cannot make an element that reads as absent while +//! being present. +//! - **Prototype lookups are not here.** `get` of a hole is `None`; reading +//! up the prototype chain is the caller's job (§10.1.8.1 OrdinaryGet). +//! - **Failure is a result, not a throw.** A `RangeError` for an invalid +//! length (§10.4.2.4 ArraySetLength) is the caller's job; here every +//! `u32` is a valid length. +//! - **Step numbers** below are those of ECMA-262 as the author remembers +//! them; no copy of the standard is vendored, so they have not been +//! checked against the text in this session. +//! +//! # The spec +//! +//! [`Spec`] is a length and a map from array index to value. +//! +//! - **S1.** Every key is below the length. +//! - **S2.** No stored value is [`HOLE_BITS`]. +//! - **[`Spec::set`]**, §10.4.2.1 \[\[DefineOwnProperty\]\] step 3 (P is an +//! array index), sub-step g: the element is stored, and if +//! `index >= length` the length becomes `index + 1`. +//! `u32::MAX` is not an array index (§6.1.7 "array index": an integer +//! index whose numeric value is below 2^32 - 1), so it is refused. +//! - **[`Spec::delete`]**, §10.1.10.1 OrdinaryDelete as reached from +//! §10.4.2: the element is removed; the length does not change. +//! - **[`Spec::set_length`]**, §10.4.2.4 ArraySetLength, the loop that +//! deletes elements from the end (step 17): every element at or above the +//! new length is gone, and the length is the new one. Growing the length +//! adds holes only. +//! - **[`Spec::get`]**: the element, or `None` for a hole or an index at or +//! above the length. +//! +//! # What the implementation must meet +//! +//! - **E1. Refinement.** After every operation, [`Repr::to_spec`] of the +//! storage equals the `Spec` that the same operations produce from +//! [`Spec::new`], and every operation returns what the `Spec`'s does. +//! - **E2. Well-formed representation** ([`repr_well_formed`]). Dense: the +//! vector is no longer than the length and no longer than [`MAX_DENSE`]. +//! Sparse: every key is below the length and no stored value is a hole. +//! - **E3. The fallback rule** ([`choose`]). A `set` at `index` on dense +//! storage of `n` slots stays dense unless `index >= n` and either +//! `index >= MAX_DENSE` or `index - n > MAX_GAP`, in which case the +//! storage becomes sparse. Nothing else changes the representation: +//! in particular sparse storage never becomes dense again (so an array +//! that went sparse once stays sparse, a stated and measurable cost), and +//! `set_length` and `delete` never switch it. +//! - **E4. Bounded dense memory.** Dense storage never holds more than +//! [`MAX_DENSE`] slots, and `set_length` never allocates: growing a +//! length costs nothing, so `new Array(4294967295)` is one `u32`. + +use std::collections::BTreeMap; + +/// The bit pattern of [`crate::value::Value::HOLE`]: no element. +pub const HOLE_BITS: u64 = 0xFFFA_0000_0000_0004; + +/// The most slots dense storage may hold: 2^24, which is 128 MiB of `u64`. +pub const MAX_DENSE: u32 = 1 << 24; + +/// The most holes a single `set` may add to dense storage by writing past +/// its end. A write further out makes the storage sparse. +pub const MAX_GAP: u32 = 1024; + +/// An array index is below this (§6.1.7). +pub const INDEX_LIMIT: u32 = u32::MAX; + +/// Why an element operation was refused. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum Error { + /// `u32::MAX`, which is not an array index. + NotAnIndex, + /// The value is the hole; use `delete`. + HoleValue, + /// Memory for the storage could not be reserved. + OutOfMemory, +} + +/// The abstract array (see the module header). +#[derive(Clone, PartialEq, Eq, Debug, Default)] +pub struct Spec { + /// The array's `length`. + pub length: u32, + /// The elements that exist. + pub entries: BTreeMap, +} + +impl Spec { + /// An empty array with the given length: all holes. + #[must_use] + pub fn new(length: u32) -> Self { + Self { + length, + entries: BTreeMap::new(), + } + } + + /// S1 and S2. + #[must_use] + pub fn well_formed(&self) -> bool { + self.entries + .iter() + .all(|(&k, &v)| k < self.length && v != HOLE_BITS) + } + + /// The element at `index`, or `None` for a hole. + #[must_use] + pub fn get(&self, index: u32) -> Option { + self.entries.get(&index).copied() + } + + /// §10.4.2.1 \[\[DefineOwnProperty\]\], array-index case. + /// + /// # Errors + /// [`Error::NotAnIndex`] for `u32::MAX`; [`Error::HoleValue`] for the + /// hole. Nothing changes on error. + pub fn set(&mut self, index: u32, value: u64) -> Result<(), Error> { + if index == INDEX_LIMIT { + return Err(Error::NotAnIndex); + } + if value == HOLE_BITS { + return Err(Error::HoleValue); + } + self.entries.insert(index, value); + // 3.g "If index >= length, then ... Set lengthDesc.[[Value]] to + // index + 1" (no overflow: index < u32::MAX). + if index >= self.length { + self.length = index.saturating_add(1); + } + Ok(()) + } + + /// Remove the element at `index`; the length stays. Returns whether an + /// element was there. + pub fn delete(&mut self, index: u32) -> bool { + self.entries.remove(&index).is_some() + } + + /// §10.4.2.4 ArraySetLength, deleting from the end (step 17). + pub fn set_length(&mut self, new_length: u32) { + self.entries.retain(|&k, _| k < new_length); + self.length = new_length; + } +} + +/// Which representation an element store holds. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum Mode { + /// A vector indexed by element index, holes stored as [`HOLE_BITS`]. + Dense, + /// An ordered map of the elements that exist. + Sparse, +} + +/// A representation's contents, as the contract sees them. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum Repr { + /// Dense: the slots. + Dense(Vec), + /// Sparse: the elements. + Sparse(BTreeMap), +} + +impl Repr { + /// The abstract array this representation stands for, with the given + /// `length` (E1). + #[must_use] + pub fn to_spec(&self, length: u32) -> Spec { + let entries = match self { + Self::Dense(v) => v + .iter() + .enumerate() + .filter(|&(_, &x)| x != HOLE_BITS) + .filter_map(|(i, &x)| u32::try_from(i).ok().map(|i| (i, x))) + .collect(), + Self::Sparse(m) => m.clone(), + }; + Spec { length, entries } + } +} + +/// E2. +#[must_use] +pub fn repr_well_formed(repr: &Repr, length: u32) -> bool { + match repr { + Repr::Dense(v) => { + let n = u32::try_from(v.len()).ok(); + n.is_some_and(|n| n <= length && n <= MAX_DENSE) + } + Repr::Sparse(m) => m.iter().all(|(&k, &v)| k < length && v != HOLE_BITS), + } +} + +/// E3: the representation after a `set` at `index`, given the one before +/// and, for dense storage, its slot count `slots`. +#[must_use] +pub fn choose(mode: Mode, slots: u32, index: u32) -> Mode { + match mode { + Mode::Sparse => Mode::Sparse, + Mode::Dense => { + if index < slots { + Mode::Dense + } else if index >= MAX_DENSE || index.saturating_sub(slots) > MAX_GAP { + Mode::Sparse + } else { + Mode::Dense + } + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn spec_set_grows_length() { + let mut s = Spec::new(0); + assert_eq!(s.set(5, 7), Ok(())); + assert_eq!(s.length, 6); + assert_eq!(s.get(5), Some(7)); + assert_eq!(s.get(0), None); + assert!(s.well_formed()); + assert_eq!(s.set(2, 1), Ok(())); + assert_eq!(s.length, 6); + } + + #[test] + fn spec_refuses() { + let mut s = Spec::new(3); + assert_eq!(s.set(u32::MAX, 1), Err(Error::NotAnIndex)); + assert_eq!(s.set(0, HOLE_BITS), Err(Error::HoleValue)); + assert_eq!(s, Spec::new(3)); + assert_eq!(s.set(u32::MAX - 1, 1), Ok(())); + assert_eq!(s.length, u32::MAX); + } + + #[test] + fn spec_set_length_truncates() { + let mut s = Spec::new(0); + for i in 0..10 { + let _ = s.set(i, u64::from(i)); + } + s.set_length(4); + assert_eq!(s.length, 4); + assert_eq!(s.get(3), Some(3)); + assert_eq!(s.get(4), None); + s.set_length(100); + assert_eq!(s.get(4), None, "growing adds holes only"); + assert!(s.well_formed()); + assert!(s.delete(1)); + assert!(!s.delete(1)); + assert_eq!(s.length, 100); + } + + #[test] + fn choose_rule() { + assert_eq!(choose(Mode::Dense, 0, 0), Mode::Dense); + assert_eq!(choose(Mode::Dense, 0, MAX_GAP), Mode::Dense); + assert_eq!(choose(Mode::Dense, 0, MAX_GAP + 1), Mode::Sparse); + assert_eq!(choose(Mode::Dense, 10, 3), Mode::Dense); + assert_eq!(choose(Mode::Dense, MAX_DENSE - 1, MAX_DENSE), Mode::Sparse); + assert_eq!( + choose(Mode::Dense, MAX_DENSE - 1, MAX_DENSE - 1), + Mode::Dense + ); + assert_eq!(choose(Mode::Sparse, 0, 0), Mode::Sparse); + } + + #[test] + fn repr_view() { + let r = Repr::Dense(vec![1, HOLE_BITS, 3]); + let s = r.to_spec(5); + assert_eq!(s.entries.len(), 2); + assert!(repr_well_formed(&r, 5)); + assert!(!repr_well_formed(&r, 2)); + assert!(!repr_well_formed( + &Repr::Sparse(BTreeMap::from([(7, 1)])), + 7 + )); + } +} diff --git a/crates/clazel-js-heap/src/elements/mod.rs b/crates/clazel-js-heap/src/elements/mod.rs new file mode 100644 index 00000000..5c8e9de6 --- /dev/null +++ b/crates/clazel-js-heap/src/elements/mod.rs @@ -0,0 +1,6 @@ +//! Elements: the indexed properties of an array (phase-7.md item 7.5). +//! +//! [`contract`] states what element storage must do and when it falls back +//! from dense to sparse. The implementation follows it. + +pub mod contract; diff --git a/crates/clazel-js-heap/src/lib.rs b/crates/clazel-js-heap/src/lib.rs index 32053015..7bea3921 100644 --- a/crates/clazel-js-heap/src/lib.rs +++ b/crates/clazel-js-heap/src/lib.rs @@ -18,6 +18,7 @@ //! `docs/VERIFICATION.md`. pub mod arena; +pub mod elements; pub mod shape; pub mod string; pub mod value; From 8a3bc1b3026ff65aaa6c63e7a4dca5fddb0a1fea Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 13:57:55 +0000 Subject: [PATCH 013/195] clazel-js-heap: elements, dense with a sparse fallback Implements the contract of the previous commit; unit tests include random operation sequences checked against the abstract array. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-heap/src/elements/mod.rs | 421 +++++++++++++++++++++- 1 file changed, 419 insertions(+), 2 deletions(-) diff --git a/crates/clazel-js-heap/src/elements/mod.rs b/crates/clazel-js-heap/src/elements/mod.rs index 5c8e9de6..d75693a6 100644 --- a/crates/clazel-js-heap/src/elements/mod.rs +++ b/crates/clazel-js-heap/src/elements/mod.rs @@ -1,6 +1,423 @@ //! Elements: the indexed properties of an array (phase-7.md item 7.5). //! -//! [`contract`] states what element storage must do and when it falls back -//! from dense to sparse. The implementation follows it. +//! [`contract`] states what element storage must do (E1 to E4) and when it +//! falls back from dense to sparse (E3). [`Elements`] follows it: +//! +//! - **Dense:** a `Vec` of NaN-boxed values indexed by element index, +//! with [`Value::HOLE`] in the slots that have no element. Reads and +//! writes within it are one bounds-checked access, which is the shape the +//! interpreter's element ops and the JIT's templates want. +//! - **Sparse:** a `BTreeMap` of the elements that exist. +//! +//! The `length` is a separate `u32`, so growing it (`new Array(n)`) costs +//! nothing and a sparse array of length 2^32 - 1 is a few words. +//! +//! The collector (7.6) will need to enumerate the values: [`Elements::values`] +//! does, in index order, for either representation. pub mod contract; + +use crate::value::Value; +use contract::{Error, MAX_DENSE, Mode, Repr, Spec, choose, repr_well_formed}; +use std::collections::BTreeMap; + +pub use contract::{INDEX_LIMIT, MAX_GAP}; + +/// The elements of one array. +#[derive(Clone, Debug)] +pub struct Elements { + length: u32, + repr: Repr, +} + +impl Default for Elements { + fn default() -> Self { + Self::new() + } +} + +impl Elements { + /// An empty array of length 0, dense. + #[must_use] + pub const fn new() -> Self { + Self { + length: 0, + repr: Repr::Dense(Vec::new()), + } + } + + /// An array of the given length with no elements (all holes), `new + /// Array(length)`. Dense and empty: nothing is allocated for the holes + /// (E4). + #[must_use] + pub const fn with_length(length: u32) -> Self { + Self { + length, + repr: Repr::Dense(Vec::new()), + } + } + + /// The array's `length`. + #[must_use] + pub const fn len(&self) -> u32 { + self.length + } + + /// Whether `length` is 0. + #[must_use] + pub const fn is_empty(&self) -> bool { + self.length == 0 + } + + /// Which representation is in use (E3). + #[must_use] + pub const fn mode(&self) -> Mode { + match self.repr { + Repr::Dense(_) => Mode::Dense, + Repr::Sparse(_) => Mode::Sparse, + } + } + + /// The element at `index`; `None` for a hole or an index at or past the + /// length (the caller then goes up the prototype chain). + #[must_use] + pub fn get(&self, index: u32) -> Option { + let bits = match &self.repr { + Repr::Dense(v) => { + let i = usize::try_from(index).ok()?; + *v.get(i)? + } + Repr::Sparse(m) => *m.get(&index)?, + }; + if bits == contract::HOLE_BITS { + return None; + } + Value::from_bits(bits) + } + + /// Whether an element exists at `index`. + #[must_use] + pub fn has(&self, index: u32) -> bool { + self.get(index).is_some() + } + + /// Store `value` at `index`, growing the length if `index >= length` + /// (contract: `Spec::set`). May turn dense storage sparse (E3). + /// + /// # Errors + /// [`Error::NotAnIndex`] for `u32::MAX`; [`Error::HoleValue`] for + /// [`Value::HOLE`]; [`Error::OutOfMemory`] if dense storage could not + /// grow. Nothing changes on error. + pub fn set(&mut self, index: u32, value: Value) -> Result<(), Error> { + if index == INDEX_LIMIT { + return Err(Error::NotAnIndex); + } + if value == Value::HOLE { + return Err(Error::HoleValue); + } + let bits = value.bits(); + let slots = match &self.repr { + Repr::Dense(v) => u32::try_from(v.len()).unwrap_or(u32::MAX), + Repr::Sparse(_) => 0, + }; + let before = self.mode(); + if choose(before, slots, index) == Mode::Sparse && before == Mode::Dense { + self.make_sparse(); + } + match &mut self.repr { + Repr::Dense(v) => { + let i = usize::try_from(index).map_err(|_| Error::NotAnIndex)?; + if let Some(slot) = v.get_mut(i) { + *slot = bits; + } else { + // `choose` kept it dense: the gap is at most MAX_GAP and + // `index < MAX_DENSE`, so this reserves at most MAX_DENSE + // slots in all (E4). + let need = i.saturating_add(1).saturating_sub(v.len()); + v.try_reserve(need).map_err(|_| Error::OutOfMemory)?; + v.resize(i, contract::HOLE_BITS); + v.push(bits); + } + } + Repr::Sparse(m) => { + m.insert(index, bits); + } + } + if index >= self.length { + self.length = index.saturating_add(1); + } + Ok(()) + } + + /// Remove the element at `index`, leaving a hole; the length stays. + /// Returns whether an element was there. + pub fn delete(&mut self, index: u32) -> bool { + match &mut self.repr { + Repr::Dense(v) => { + let Some(slot) = usize::try_from(index).ok().and_then(|i| v.get_mut(i)) else { + return false; + }; + let was = *slot != contract::HOLE_BITS; + *slot = contract::HOLE_BITS; + was + } + Repr::Sparse(m) => m.remove(&index).is_some(), + } + } + + /// Set `length`, dropping every element at or past it (contract: + /// `Spec::set_length`). Never allocates, and never changes the + /// representation (E3, E4). + pub fn set_length(&mut self, new_length: u32) { + match &mut self.repr { + Repr::Dense(v) => { + let keep = usize::try_from(new_length).unwrap_or(usize::MAX); + v.truncate(keep); + } + Repr::Sparse(m) => { + // `split_off` keeps keys below the bound in `m`. + drop(m.split_off(&new_length)); + } + } + self.length = new_length; + } + + /// The existing elements as `(index, value)`, in index order. + pub fn entries(&self) -> Box + '_> { + match &self.repr { + Repr::Dense(v) => Box::new(v.iter().enumerate().filter_map(|(i, &b)| { + let i = u32::try_from(i).ok()?; + (b != contract::HOLE_BITS) + .then(|| Value::from_bits(b)) + .flatten() + .map(|x| (i, x)) + })), + Repr::Sparse(m) => Box::new( + m.iter() + .filter_map(|(&i, &b)| Value::from_bits(b).map(|x| (i, x))), + ), + } + } + + /// The existing values, in index order: what the collector scans. + pub fn values(&self) -> impl Iterator + '_ { + self.entries().map(|(_, v)| v) + } + + /// The abstract array this storage stands for (E1). + #[must_use] + pub fn to_spec(&self) -> Spec { + self.repr.to_spec(self.length) + } + + /// E2 for the current state. + #[must_use] + pub fn is_well_formed(&self) -> bool { + repr_well_formed(&self.repr, self.length) + } + + fn make_sparse(&mut self) { + if let Repr::Dense(v) = &self.repr { + let m: BTreeMap = v + .iter() + .enumerate() + .filter(|&(_, &b)| b != contract::HOLE_BITS) + .filter_map(|(i, &b)| u32::try_from(i).ok().map(|i| (i, b))) + .collect(); + self.repr = Repr::Sparse(m); + } + } + + /// The most slots dense storage may hold (E4). + pub const DENSE_LIMIT: u32 = MAX_DENSE; +} + +#[cfg(test)] +mod tests { + use super::*; + + fn n(i: i32) -> Value { + Value::int32(i) + } + + fn put(e: &mut Elements, index: u32, v: Value) { + assert_eq!(e.set(index, v), Ok(())); + } + + #[test] + fn push_get_length() { + let mut e = Elements::new(); + assert!(e.is_empty()); + for i in 0..5u32 { + assert_eq!(e.set(i, n(i32::try_from(i).unwrap_or(0))), Ok(())); + } + assert_eq!(e.len(), 5); + assert_eq!(e.get(3), Some(n(3))); + assert_eq!(e.get(5), None); + assert_eq!(e.mode(), Mode::Dense); + assert!(e.is_well_formed()); + } + + #[test] + fn holes_in_dense() { + let mut e = Elements::new(); + put(&mut e, 0, n(1)); + put(&mut e, 10, n(2)); + assert_eq!(e.mode(), Mode::Dense); + assert_eq!(e.len(), 11); + assert!(!e.has(5)); + assert!(e.has(10)); + assert!(e.delete(10)); + assert!(!e.delete(10)); + assert_eq!(e.len(), 11, "delete leaves the length"); + assert_eq!(e.entries().count(), 1); + } + + #[test] + fn falls_back_past_the_gap() { + let mut e = Elements::new(); + put(&mut e, 0, n(1)); + put(&mut e, MAX_GAP + 1, n(2)); + assert_eq!(e.mode(), Mode::Dense, "slots is 1, so the gap is MAX_GAP"); + put(&mut e, MAX_GAP + 1 + MAX_GAP + 2, n(3)); + assert_eq!(e.mode(), Mode::Sparse); + assert_eq!(e.get(0), Some(n(1))); + assert_eq!(e.get(MAX_GAP + 1), Some(n(2))); + assert_eq!(e.entries().count(), 3); + assert!(e.is_well_formed()); + } + + #[test] + fn sparse_stays_sparse() { + let mut e = Elements::new(); + put(&mut e, 1_000_000, n(1)); + assert_eq!(e.mode(), Mode::Sparse); + e.set_length(0); + assert_eq!(e.mode(), Mode::Sparse); + put(&mut e, 0, n(2)); + assert_eq!(e.mode(), Mode::Sparse); + assert_eq!(e.len(), 1); + } + + #[test] + fn huge_length_costs_nothing() { + let mut e = Elements::with_length(u32::MAX); + assert_eq!(e.len(), u32::MAX); + assert_eq!(e.mode(), Mode::Dense); + assert_eq!(e.get(7), None); + assert_eq!(e.set(u32::MAX, n(1)), Err(Error::NotAnIndex)); + assert_eq!(e.set(u32::MAX - 1, n(1)), Ok(())); + assert_eq!(e.mode(), Mode::Sparse); + assert_eq!(e.len(), u32::MAX); + assert!(e.is_well_formed()); + } + + #[test] + fn dense_limit_makes_sparse() { + let mut e = Elements::new(); + // Reaching MAX_DENSE by index, with every set in range of the gap + // rule, is not feasible to do slot by slot in a test; jump instead. + put(&mut e, MAX_DENSE, n(1)); + assert_eq!(e.mode(), Mode::Sparse); + } + + #[test] + fn refuses_hole_value_and_changes_nothing() { + let mut e = Elements::new(); + put(&mut e, 0, n(1)); + let before = e.to_spec(); + assert_eq!(e.set(1, Value::HOLE), Err(Error::HoleValue)); + assert_eq!(e.set(u32::MAX, n(1)), Err(Error::NotAnIndex)); + assert_eq!(e.to_spec(), before); + assert_eq!(e.len(), 1); + } + + #[test] + fn set_length_truncates_both() { + for sparse in [false, true] { + let mut e = Elements::new(); + if sparse { + put(&mut e, 100_000, n(9)); + e.delete(100_000); + } + for i in 0..10u32 { + put(&mut e, i, n(i32::try_from(i).unwrap_or(0))); + } + assert_eq!(e.mode() == Mode::Sparse, sparse); + e.set_length(4); + assert_eq!(e.len(), 4); + assert_eq!(e.get(3), Some(n(3))); + assert_eq!(e.get(4), None); + e.set_length(50); + assert_eq!(e.get(4), None); + assert_eq!(e.values().count(), 4); + assert!(e.is_well_formed()); + } + } + + /// A small deterministic generator, so the test needs no dependency. + struct Lcg(u64); + impl Lcg { + fn next(&mut self) -> u64 { + self.0 = self + .0 + .wrapping_mul(6_364_136_223_846_793_005) + .wrapping_add(1_442_695_040_888_963_407); + self.0 >> 33 + } + } + + /// E1, E2 and E3 over random operation sequences against `Spec`. + #[test] + fn matches_the_spec_on_random_sequences() { + let mut rng = Lcg(0x5EED); + for _ in 0..300 { + let mut e = Elements::new(); + let mut s = Spec::new(0); + for _ in 0..200 { + let op = rng.next() % 8; + // Mostly small indices, some far, some at the edge. + let index = match rng.next() % 10 { + 0 => u32::try_from(rng.next() % 5000).unwrap_or(0) + 2000, + 1 => u32::MAX - u32::try_from(rng.next() % 3).unwrap_or(0), + _ => u32::try_from(rng.next() % 40).unwrap_or(0), + }; + let before = ( + e.mode(), + match &e.repr { + Repr::Dense(v) => u32::try_from(v.len()).unwrap_or(0), + Repr::Sparse(_) => 0, + }, + ); + match op { + 0..=3 => { + let v = if rng.next().is_multiple_of(9) { + Value::HOLE + } else { + n(i32::try_from(rng.next() % 1000).unwrap_or(0)) + }; + let got = e.set(index, v); + let want = s.set(index, v.bits()); + assert_eq!(got, want); + if got.is_ok() { + assert_eq!(e.mode(), choose(before.0, before.1, index)); + } + } + 4 | 5 => assert_eq!(e.delete(index), s.delete(index)), + 6 => { + let l = u32::try_from(rng.next() % 60).unwrap_or(0); + let mode = e.mode(); + e.set_length(l); + s.set_length(l); + assert_eq!(e.mode(), mode); + } + _ => assert_eq!(e.get(index).map(Value::bits), s.get(index)), + } + assert!(e.is_well_formed()); + assert!(s.well_formed()); + assert_eq!(e.to_spec(), s); + assert_eq!(e.len(), s.length); + } + } + } +} From eb56b34a342bea17e92a1411d008b86dc3c7714a Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 13:58:44 +0000 Subject: [PATCH 014/195] clazel-js-heap: the contract of symbols and property keys Well-known symbols as fixed ids, unique never-reused ids, immutable descriptions, and a collision-free encoding of string and symbol keys. Stated before the implementation (CLAUDE.md rule 3). Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-heap/src/lib.rs | 1 + crates/clazel-js-heap/src/symbol/contract.rs | 187 +++++++++++++++++++ crates/clazel-js-heap/src/symbol/mod.rs | 6 + 3 files changed, 194 insertions(+) create mode 100644 crates/clazel-js-heap/src/symbol/contract.rs create mode 100644 crates/clazel-js-heap/src/symbol/mod.rs diff --git a/crates/clazel-js-heap/src/lib.rs b/crates/clazel-js-heap/src/lib.rs index 7bea3921..f4b330e3 100644 --- a/crates/clazel-js-heap/src/lib.rs +++ b/crates/clazel-js-heap/src/lib.rs @@ -21,6 +21,7 @@ pub mod arena; pub mod elements; pub mod shape; pub mod string; +pub mod symbol; pub mod value; #[cfg(kani)] diff --git a/crates/clazel-js-heap/src/symbol/contract.rs b/crates/clazel-js-heap/src/symbol/contract.rs new file mode 100644 index 00000000..d58e782c --- /dev/null +++ b/crates/clazel-js-heap/src/symbol/contract.rs @@ -0,0 +1,187 @@ +//! The contract of symbols and property keys (phase-7.md item 7.5, "The +//! rest"), stated before the implementation (CLAUDE.md rule 3). +//! +//! # What is modelled +//! +//! ECMA-262 §6.1.5, The Symbol Type: a Symbol is a primitive value that is +//! unique and immutable, and may hold a *description* (a String or +//! `undefined`); and §6.1.7, property keys: a property key is a String or a +//! Symbol. +//! +//! Modelling choices (SPEC-STYLE.md): +//! +//! - **A symbol is its id.** [`SymbolId`] is a `u32` into a table; two +//! symbols are the same value exactly when their ids are equal, however +//! their descriptions compare (§6.1.5: "each Symbol value immutably holds +//! an associated value called [[Description]]"; identity is not the +//! description). +//! - **Symbols are never freed in this slice.** Reclaiming one needs the +//! collector (7.6); until then a table only grows, so an id is never +//! reused (Y2). +//! - **The global symbol registry** (`Symbol.for`, §20.4.2.2 and the +//! GlobalSymbolRegistry of §20.4.2) is a built-in's state, not the +//! heap's, and is absent here. +//! - **A symbol as a value** (its NaN-boxed form, a heap reference or a +//! tagged id) is not decided here; this slice is the table and the key. +//! - **Step numbers** are not cited: the clauses used have none to quote. +//! +//! # Well-known symbols (§6.1.5.1, Table 1) +//! +//! The standard's thirteen well-known symbols are the **fixed ids 0 to +//! 12**, in the order of [`WELL_KNOWN`], and exist in every table from the +//! start. Their description is `"Symbol."` followed by the name, as the +//! standard gives them (`@@iterator` is described `Symbol.iterator`). +//! +//! # Invariants +//! +//! - **Y1. Fixed ids.** In every table, the symbol with id `i < 13` is the +//! well-known symbol `WELL_KNOWN[i]`, with that description. Created +//! symbols have ids from 13 up, in creation order. +//! - **Y2. Unique and never reused.** Creating a symbol returns the id equal +//! to the table's length before, so no created symbol has the id of any +//! earlier one, and the table's length grows by exactly one. +//! - **Y3. Immutable description.** A symbol's description (a string, or +//! none) is what it was created with, in every later state. A symbol +//! created with the empty-string description is distinct from one with no +//! description: [`Description`] has two cases, not an `Option` collapsed +//! to empty. +//! - **Y4. Keys do not collide.** [`encode`] maps a [`PropertyKey`] to the +//! shapes' [`Key`], a `u32`, as follows: a string key `k` with `k < 2^31` +//! to itself; a symbol `s` with `s < 2^31` to `s | 2^31`. It is +//! injective, so a string and a symbol never share a key, and [`decode`] +//! is its inverse: `decode(encode(p)) == p` for every `p` it accepts, and +//! `encode(decode(k)) == Some(k)` for every key. +//! - **Y5. Capacity.** Strings interned as keys and symbols created are +//! each limited to `2^31` by Y4's encoding; one more is an error, never a +//! wrapped id. + +use crate::string::Key; + +/// A symbol: an index into a symbol table. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)] +pub struct SymbolId(pub u32); + +/// A property key: a String (interned) or a Symbol (§6.1.7). +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub enum PropertyKey { + /// An interned string. + String(Key), + /// A symbol. + Symbol(SymbolId), +} + +/// A symbol's `[[Description]]` (§6.1.5): `undefined`, or a String. The +/// empty string and `undefined` differ (Y3). +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum Description { + /// `undefined`. + Undefined, + /// A String. + Text(S), +} + +/// The bit that marks a symbol's key (Y4); string keys are below it. +pub const SYMBOL_BIT: u32 = 1 << 31; + +/// §6.1.5.1 Table 1, in id order (Y1): the names of `Symbol.`. +pub const WELL_KNOWN: [&str; 13] = [ + "asyncIterator", + "hasInstance", + "isConcatSpreadable", + "iterator", + "match", + "matchAll", + "replace", + "search", + "species", + "split", + "toPrimitive", + "toStringTag", + "unscopables", +]; + +/// How many well-known symbols there are. +pub const WELL_KNOWN_COUNT: u32 = 13; + +/// Y4: the key for a property key, or `None` if its number is too large +/// for the encoding (Y5). +#[must_use] +pub const fn encode(p: PropertyKey) -> Option { + match p { + PropertyKey::String(k) => { + if k.0 < SYMBOL_BIT { + Some(k) + } else { + None + } + } + PropertyKey::Symbol(s) => { + if s.0 < SYMBOL_BIT { + Some(Key(s.0 | SYMBOL_BIT)) + } else { + None + } + } + } +} + +/// Y4: the property key a key stands for. +#[must_use] +pub const fn decode(k: Key) -> PropertyKey { + if k.0 & SYMBOL_BIT == 0 { + PropertyKey::String(k) + } else { + PropertyKey::Symbol(SymbolId(k.0 & !SYMBOL_BIT)) + } +} + +/// Y1: the description text of the well-known symbol `id`, or `None` if +/// `id` is not one. +#[must_use] +pub fn well_known_description(id: SymbolId) -> Option { + let i = usize::try_from(id.0).ok()?; + WELL_KNOWN.get(i).map(|n| format!("Symbol.{n}")) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn table_is_thirteen_distinct_names() { + assert_eq!(WELL_KNOWN.len(), 13); + assert_eq!(usize::try_from(WELL_KNOWN_COUNT), Ok(WELL_KNOWN.len())); + for (i, a) in WELL_KNOWN.iter().enumerate() { + for b in WELL_KNOWN.iter().skip(i.saturating_add(1)) { + assert_ne!(a, b); + } + } + } + + #[test] + fn descriptions() { + assert_eq!( + well_known_description(SymbolId(3)).as_deref(), + Some("Symbol.iterator") + ); + assert_eq!(well_known_description(SymbolId(13)), None); + } + + #[test] + fn encoding_edges() { + let s = PropertyKey::String(Key(SYMBOL_BIT - 1)); + let y = PropertyKey::Symbol(SymbolId(0)); + assert_eq!(encode(s), Some(Key(SYMBOL_BIT - 1))); + assert_eq!(encode(y), Some(Key(SYMBOL_BIT))); + assert_eq!(encode(PropertyKey::String(Key(SYMBOL_BIT))), None); + assert_eq!(encode(PropertyKey::Symbol(SymbolId(SYMBOL_BIT))), None); + assert_eq!(decode(Key(SYMBOL_BIT)), y); + assert_eq!( + decode(Key(u32::MAX)), + PropertyKey::Symbol(SymbolId(SYMBOL_BIT - 1)) + ); + for p in [s, y, PropertyKey::String(Key(0))] { + assert_eq!(encode(p).map(decode), Some(p)); + } + } +} diff --git a/crates/clazel-js-heap/src/symbol/mod.rs b/crates/clazel-js-heap/src/symbol/mod.rs new file mode 100644 index 00000000..61781003 --- /dev/null +++ b/crates/clazel-js-heap/src/symbol/mod.rs @@ -0,0 +1,6 @@ +//! Symbols and property keys (phase-7.md item 7.5). +//! +//! [`contract`] states what the symbol table and the key encoding must do +//! (Y1 to Y5). The implementation follows it. + +pub mod contract; From 0a02b41b3157088fd986143342a8caec5a378ce3 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 13:59:36 +0000 Subject: [PATCH 015/195] clazel-js-heap: symbols, well-known symbols and symbol property keys Implements the contract of the previous commit. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-heap/src/symbol/mod.rs | 298 +++++++++++++++++++++++- 1 file changed, 297 insertions(+), 1 deletion(-) diff --git a/crates/clazel-js-heap/src/symbol/mod.rs b/crates/clazel-js-heap/src/symbol/mod.rs index 61781003..3f21bd48 100644 --- a/crates/clazel-js-heap/src/symbol/mod.rs +++ b/crates/clazel-js-heap/src/symbol/mod.rs @@ -1,6 +1,302 @@ //! Symbols and property keys (phase-7.md item 7.5). //! //! [`contract`] states what the symbol table and the key encoding must do -//! (Y1 to Y5). The implementation follows it. +//! (Y1 to Y5). [`Symbols`] is the table; [`PropertyKeys`] pairs it with the +//! string [`Interner`] so that strings and symbols are both property keys +//! with one [`Key`] type, which is what [`crate::shape::Shapes`] takes. pub mod contract; + +use crate::string::{Interner, JsString, Key, TooLong}; +use contract::{ + Description, PropertyKey, SYMBOL_BIT, WELL_KNOWN, WELL_KNOWN_COUNT, decode, encode, +}; + +pub use contract::SymbolId; + +/// Why a symbol or key operation failed. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum Error { + /// A table is full (Y5): 2^31 strings or 2^31 symbols. + TooMany, + /// A string past the length limit. + TooLong, + /// The key or id names nothing in the table. + Unknown, +} + +impl From for Error { + fn from(_: TooLong) -> Self { + Self::TooLong + } +} + +macro_rules! well_known { + ($($name:ident = $id:expr, $js:expr;)*) => { + $( + #[doc = concat!("`Symbol.", $js, "` (§6.1.5.1, Table 1).")] + pub const $name: SymbolId = SymbolId($id); + )* + }; +} + +well_known! { + ASYNC_ITERATOR = 0, "asyncIterator"; + HAS_INSTANCE = 1, "hasInstance"; + IS_CONCAT_SPREADABLE = 2, "isConcatSpreadable"; + ITERATOR = 3, "iterator"; + MATCH = 4, "match"; + MATCH_ALL = 5, "matchAll"; + REPLACE = 6, "replace"; + SEARCH = 7, "search"; + SPECIES = 8, "species"; + SPLIT = 9, "split"; + TO_PRIMITIVE = 10, "toPrimitive"; + TO_STRING_TAG = 11, "toStringTag"; + UNSCOPABLES = 12, "unscopables"; +} + +/// The symbol table. +#[derive(Debug)] +pub struct Symbols { + descriptions: Vec>, +} + +impl Default for Symbols { + fn default() -> Self { + Self::new() + } +} + +impl Symbols { + /// A table holding the thirteen well-known symbols at ids 0 to 12 (Y1). + #[must_use] + pub fn new() -> Self { + let descriptions = WELL_KNOWN + .iter() + .map(|n| { + // The names are short ASCII: far under the string limit. + match JsString::from_rust_str(&format!("Symbol.{n}")) { + Ok(s) => Description::Text(s), + Err(_) => Description::Undefined, + } + }) + .collect(); + Self { descriptions } + } + + /// A new symbol, distinct from every other (Y2), with the description + /// it is given (Y3). + /// + /// # Errors + /// [`Error::TooMany`] when 2^31 symbols exist (Y5). + pub fn create(&mut self, description: Description) -> Result { + let id = u32::try_from(self.descriptions.len()).map_err(|_| Error::TooMany)?; + if id >= SYMBOL_BIT { + return Err(Error::TooMany); + } + self.descriptions.push(description); + Ok(SymbolId(id)) + } + + /// The symbol's description (`Symbol.prototype.description`'s source). + #[must_use] + pub fn description(&self, id: SymbolId) -> Option<&Description> { + usize::try_from(id.0) + .ok() + .and_then(|i| self.descriptions.get(i)) + } + + /// Whether `id` is one of the thirteen well-known symbols. + #[must_use] + pub const fn is_well_known(id: SymbolId) -> bool { + id.0 < WELL_KNOWN_COUNT + } + + /// The number of symbols, well-known ones included. + #[must_use] + pub fn len(&self) -> usize { + self.descriptions.len() + } + + /// Always false: the well-known symbols are there from the start. + #[must_use] + pub fn is_empty(&self) -> bool { + self.descriptions.is_empty() + } +} + +/// Strings and symbols as property keys. +#[derive(Debug, Default)] +pub struct PropertyKeys { + strings: Interner, + symbols: Symbols, +} + +impl PropertyKeys { + /// Empty string table; the symbol table has the well-known symbols. + #[must_use] + pub fn new() -> Self { + Self::default() + } + + /// The key for a string, interning it (equal strings, one key). + /// + /// # Errors + /// [`Error::TooMany`] when 2^31 strings are interned and `s` is new + /// (Y5); [`Error::TooLong`]. + pub fn string_key(&mut self, s: &JsString) -> Result { + if let Some(k) = self.strings.find(s) { + return Ok(k); + } + if self.strings.len() >= usize::try_from(SYMBOL_BIT).unwrap_or(usize::MAX) { + return Err(Error::TooMany); + } + let k = self.strings.intern(s)?; + encode(PropertyKey::String(k)).ok_or(Error::TooMany) + } + + /// The key for a symbol. + /// + /// # Errors + /// [`Error::Unknown`] if the id names no symbol of this table. + pub fn symbol_key(&self, id: SymbolId) -> Result { + self.symbols.description(id).ok_or(Error::Unknown)?; + encode(PropertyKey::Symbol(id)).ok_or(Error::Unknown) + } + + /// A new symbol and its key. + /// + /// # Errors + /// As [`Symbols::create`]. + pub fn new_symbol( + &mut self, + description: Description, + ) -> Result<(SymbolId, Key), Error> { + let id = self.symbols.create(description)?; + let key = encode(PropertyKey::Symbol(id)).ok_or(Error::TooMany)?; + Ok((id, key)) + } + + /// What a key is: a string (resolved) or a symbol (Y4). + #[must_use] + pub fn classify(&self, key: Key) -> Option { + let p = decode(key); + match p { + PropertyKey::String(k) => self.strings.resolve(k).map(|_| p), + PropertyKey::Symbol(s) => self.symbols.description(s).map(|_| p), + } + } + + /// The string a key stands for, if it is a string key. + #[must_use] + pub fn string(&self, key: Key) -> Option<&JsString> { + match decode(key) { + PropertyKey::String(k) => self.strings.resolve(k), + PropertyKey::Symbol(_) => None, + } + } + + /// The symbol table. + #[must_use] + pub const fn symbols(&self) -> &Symbols { + &self.symbols + } + + /// The string table. + #[must_use] + pub const fn strings(&self) -> &Interner { + &self.strings + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::shape::{Attrs, ROOT, Shapes}; + + fn js(s: &str) -> JsString { + JsString::from_rust_str(s).unwrap_or_else(|_| JsString::empty()) + } + + #[test] + fn well_known_ids_are_fixed() { + let t = Symbols::new(); + assert_eq!(t.len(), 13); + assert_eq!(ITERATOR, SymbolId(3)); + assert_eq!(UNSCOPABLES, SymbolId(12)); + for (i, name) in WELL_KNOWN.iter().enumerate() { + let id = SymbolId(u32::try_from(i).unwrap_or(u32::MAX)); + assert!(Symbols::is_well_known(id)); + assert_eq!( + t.description(id), + Some(&Description::Text(js(&format!("Symbol.{name}")))) + ); + } + assert!(!Symbols::is_well_known(SymbolId(13))); + assert_eq!( + t.description(TO_PRIMITIVE), + Some(&Description::Text(js("Symbol.toPrimitive"))) + ); + } + + #[test] + fn created_symbols_are_unique() { + let mut t = Symbols::new(); + let a = t.create(Description::Text(js("x"))); + let b = t.create(Description::Text(js("x"))); + let c = t.create(Description::Undefined); + let d = t.create(Description::Text(JsString::empty())); + assert_eq!(a, Ok(SymbolId(13))); + assert_eq!(b, Ok(SymbolId(14))); + assert_eq!(c, Ok(SymbolId(15))); + assert_eq!(d, Ok(SymbolId(16))); + assert_ne!(a, b, "same description, different symbols"); + assert_eq!(t.description(SymbolId(15)), Some(&Description::Undefined)); + assert_ne!( + t.description(SymbolId(15)), + t.description(SymbolId(16)), + "undefined is not the empty string" + ); + assert_eq!(t.description(SymbolId(17)), None); + assert_eq!(t.len(), 17); + } + + #[test] + fn strings_and_symbols_never_share_a_key() { + let mut k = PropertyKeys::new(); + let s = k.string_key(&js("iterator")); + let again = k.string_key(&js("iterator")); + assert_eq!(s, again); + let sym = k.symbol_key(ITERATOR); + assert_ne!(s, sym, "the string \"iterator\" is not Symbol.iterator"); + let (id, key) = k + .new_symbol(Description::Text(js("iterator"))) + .unwrap_or((SymbolId(0), Key(0))); + assert_ne!(Ok(key), sym); + assert_ne!(Ok(key), s); + assert_eq!(k.classify(key), Some(PropertyKey::Symbol(id))); + assert_eq!(k.string(key), None); + let sk = s.unwrap_or(Key(0)); + assert_eq!(k.string(sk).map(JsString::len), Some(8)); + assert_eq!(k.classify(Key(sk.0 + 100)), None); + assert_eq!(k.symbol_key(SymbolId(99)), Err(Error::Unknown)); + } + + #[test] + fn symbol_keys_work_in_shapes() { + let mut k = PropertyKeys::new(); + let mut shapes = Shapes::new(); + let s = k.string_key(&js("a")).unwrap_or(Key(0)); + let y = k.symbol_key(ITERATOR).unwrap_or(Key(0)); + let s1 = shapes.add_property(ROOT, s, Attrs::ALL); + let s1 = s1.map(|(id, _)| id).unwrap_or(ROOT); + let s2 = shapes.add_property(s1, y, Attrs::ALL); + let s2 = s2.map(|(id, _)| id).unwrap_or(ROOT); + assert_eq!(shapes.lookup(s2, s), Some((0, Attrs::ALL))); + assert_eq!(shapes.lookup(s2, y), Some((1, Attrs::ALL))); + // The same order on another object reaches the same shape. + let t1 = shapes.add_property(ROOT, s, Attrs::ALL).map(|(i, _)| i); + assert_eq!(t1, Ok(s1)); + } +} From 70bd3d6695c05ea6dc1e4e6452f7786dd97b6be8 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 14:24:13 +0000 Subject: [PATCH 016/195] clazel-js-heap: Kani harnesses for elements and symbols Dense operations split out as free functions so they can be proven without BTreeMap; the fallback rule and key encoding proven over all u32. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-heap/src/elements/mod.rs | 81 ++++++++----- crates/clazel-js-heap/src/lib.rs | 5 + crates/clazel-js-heap/src/proofs.rs | 140 ++++++++++++++++++++++ 3 files changed, 196 insertions(+), 30 deletions(-) diff --git a/crates/clazel-js-heap/src/elements/mod.rs b/crates/clazel-js-heap/src/elements/mod.rs index d75693a6..5e8a2986 100644 --- a/crates/clazel-js-heap/src/elements/mod.rs +++ b/crates/clazel-js-heap/src/elements/mod.rs @@ -23,6 +23,50 @@ use std::collections::BTreeMap; pub use contract::{INDEX_LIMIT, MAX_GAP}; +/// The dense representation's operations, free functions over the slots so +/// that the Kani harnesses can prove them without the sparse map (CBMC does +/// not finish with `BTreeMap` in the model). +pub(crate) mod dense { + use super::contract::{Error, HOLE_BITS}; + + /// The slot's bits, which may be [`HOLE_BITS`]; `None` past the slots. + pub(crate) fn get(v: &[u64], index: u32) -> Option { + let i = usize::try_from(index).ok()?; + v.get(i).copied() + } + + /// Write `bits` at `index`, padding with holes. The caller has checked + /// the fallback rule (contract `choose`), so the gap is small. + pub(crate) fn set(v: &mut Vec, index: u32, bits: u64) -> Result<(), Error> { + let i = usize::try_from(index).map_err(|_| Error::NotAnIndex)?; + if let Some(slot) = v.get_mut(i) { + *slot = bits; + } else { + let need = i.saturating_add(1).saturating_sub(v.len()); + v.try_reserve(need).map_err(|_| Error::OutOfMemory)?; + v.resize(i, HOLE_BITS); + v.push(bits); + } + Ok(()) + } + + /// Make the slot a hole; whether it held an element. + pub(crate) fn delete(v: &mut [u64], index: u32) -> bool { + let Some(slot) = usize::try_from(index).ok().and_then(|i| v.get_mut(i)) else { + return false; + }; + let was = *slot != HOLE_BITS; + *slot = HOLE_BITS; + was + } + + /// Drop the slots at or past `new_length`. + pub(crate) fn truncate(v: &mut Vec, new_length: u32) { + let keep = usize::try_from(new_length).unwrap_or(usize::MAX); + v.truncate(keep); + } +} + /// The elements of one array. #[derive(Clone, Debug)] pub struct Elements { @@ -83,10 +127,7 @@ impl Elements { #[must_use] pub fn get(&self, index: u32) -> Option { let bits = match &self.repr { - Repr::Dense(v) => { - let i = usize::try_from(index).ok()?; - *v.get(i)? - } + Repr::Dense(v) => dense::get(v, index)?, Repr::Sparse(m) => *m.get(&index)?, }; if bits == contract::HOLE_BITS { @@ -125,20 +166,10 @@ impl Elements { self.make_sparse(); } match &mut self.repr { - Repr::Dense(v) => { - let i = usize::try_from(index).map_err(|_| Error::NotAnIndex)?; - if let Some(slot) = v.get_mut(i) { - *slot = bits; - } else { - // `choose` kept it dense: the gap is at most MAX_GAP and - // `index < MAX_DENSE`, so this reserves at most MAX_DENSE - // slots in all (E4). - let need = i.saturating_add(1).saturating_sub(v.len()); - v.try_reserve(need).map_err(|_| Error::OutOfMemory)?; - v.resize(i, contract::HOLE_BITS); - v.push(bits); - } - } + // `choose` kept it dense: the gap is at most MAX_GAP and + // `index < MAX_DENSE`, so dense storage holds at most MAX_DENSE + // slots in all (E4). + Repr::Dense(v) => dense::set(v, index, bits)?, Repr::Sparse(m) => { m.insert(index, bits); } @@ -153,14 +184,7 @@ impl Elements { /// Returns whether an element was there. pub fn delete(&mut self, index: u32) -> bool { match &mut self.repr { - Repr::Dense(v) => { - let Some(slot) = usize::try_from(index).ok().and_then(|i| v.get_mut(i)) else { - return false; - }; - let was = *slot != contract::HOLE_BITS; - *slot = contract::HOLE_BITS; - was - } + Repr::Dense(v) => dense::delete(v, index), Repr::Sparse(m) => m.remove(&index).is_some(), } } @@ -170,10 +194,7 @@ impl Elements { /// representation (E3, E4). pub fn set_length(&mut self, new_length: u32) { match &mut self.repr { - Repr::Dense(v) => { - let keep = usize::try_from(new_length).unwrap_or(usize::MAX); - v.truncate(keep); - } + Repr::Dense(v) => dense::truncate(v, new_length), Repr::Sparse(m) => { // `split_off` keeps keys below the bound in `m`. drop(m.split_off(&new_length)); diff --git a/crates/clazel-js-heap/src/lib.rs b/crates/clazel-js-heap/src/lib.rs index f4b330e3..21e2b507 100644 --- a/crates/clazel-js-heap/src/lib.rs +++ b/crates/clazel-js-heap/src/lib.rs @@ -11,6 +11,11 @@ //! is under 256, and an interner for property keys. //! - [`shape`]: hidden classes with transitions and a dictionary-mode cutoff. //! +//! - [`elements`]: an array's indexed properties, dense with a stated +//! fallback to sparse; [`elements::contract`] is the spec. +//! - [`symbol`]: symbols (well-known ones at fixed ids) and the property key +//! that is a string or a symbol; [`symbol::contract`] is the spec. +//! //! The collector (item 7.6) is not here. The arena leaves room for it: it //! can enumerate live slots, and freeing is one call. //! diff --git a/crates/clazel-js-heap/src/proofs.rs b/crates/clazel-js-heap/src/proofs.rs index 1e04573b..e42da50b 100644 --- a/crates/clazel-js-heap/src/proofs.rs +++ b/crates/clazel-js-heap/src/proofs.rs @@ -178,3 +178,143 @@ fn value_roundtrip_any() { None => assert!(p > 0xFFFF_FFFF_FFFF), } } + +// ---- Second slice: elements and symbols ------------------------------- +// +// Bounds, stated. The dense operations (`elements::dense`) are proven for +// one operation on a three-slot vector with indices below 5 (`dense_one_op`) +// and two sets from empty with indices below 6 (`dense_set_pair`). The fallback rule (E3) is +// proven for every `u32` index as the pure function `choose`. NOT proven: +// the sparse representation, the switch from dense to sparse, and +// `Elements` as a whole. Harnesses through `Elements::set` (which reaches +// `BTreeMap`) ran for over eight minutes without finishing and were +// dropped; those paths are covered by unit tests, including random +// sequences against the abstract array (`elements::contract::Spec`), which +// is a test, not a proof. Symbol harnesses cover the key encoding (Y4) for +// all `u32`; the table's construction (Y1 to Y3) formats strings and is +// covered by unit tests only. + +use crate::elements::Elements; +use crate::elements::contract::{HOLE_BITS, MAX_DENSE, MAX_GAP, Mode, choose}; +use crate::elements::dense; +use crate::string::Key; +use crate::symbol::contract::{PropertyKey, SYMBOL_BIT, SymbolId, decode, encode}; + +/// E3's rule is total and keeps dense storage within E4's bound. +#[kani::proof] +fn elements_choose_any() { + let slots: u32 = kani::any(); + let index: u32 = kani::any(); + kani::assume(slots <= MAX_DENSE); + let m = choose(Mode::Dense, slots, index); + if m == Mode::Dense { + // Either in range of the slots, or a write of at most MAX_GAP holes + // below MAX_DENSE: the slot count after is at most MAX_DENSE. + assert!(index < slots || (index < MAX_DENSE && index.saturating_sub(slots) <= MAX_GAP)); + assert!(index < MAX_DENSE); + } else { + assert!(index >= slots); + } + assert_eq!(choose(Mode::Sparse, slots, index), Mode::Sparse); +} + +/// One operation (set, delete or truncate) on a dense vector of three +/// slots holding any bit patterns, against a three-cell model: reads, the +/// slot count's bound by the length (E2) and by `MAX_DENSE` (E4). +#[kani::proof] +#[kani::unwind(6)] +fn dense_one_op() { + let a: u64 = kani::any(); + let b: u64 = kani::any(); + let c: u64 = kani::any(); + let mut v: Vec = vec![a, b, c]; + let mut cells = [a, b, c]; + let i: u32 = kani::any(); + kani::assume(i < 5); + let mut length: u32 = 3; + match kani::any::() % 3 { + 0 => { + let x: u64 = kani::any(); + kani::assume(x != HOLE_BITS); + assert!(dense::set(&mut v, i, x).is_ok()); + if let Some(cell) = usize::try_from(i).ok().and_then(|i| cells.get_mut(i)) { + *cell = x; + } + length = length.max(i.saturating_add(1)); + } + 1 => { + let idx = usize::try_from(i).ok(); + let had = idx + .and_then(|i| cells.get(i)) + .is_some_and(|&x| x != HOLE_BITS); + assert_eq!(dense::delete(&mut v, i), had); + if let Some(cell) = idx.and_then(|i| cells.get_mut(i)) { + *cell = HOLE_BITS; + } + } + _ => { + dense::truncate(&mut v, i); + length = i; + } + } + assert!(u32::try_from(v.len()).is_ok_and(|n| n <= length && n <= MAX_DENSE)); + // Slots the model has (those below the vector's length) read back. + for k in 0..3u32 { + let kept = usize::try_from(k).ok().is_some_and(|k| k < v.len()); + let want = cells.get(usize::try_from(k).unwrap_or(0)).copied(); + if kept { + assert_eq!(dense::get(&v, k), want); + } else { + assert_eq!(dense::get(&v, k), None); + } + } +} + +/// `dense::set` at any index of the small range, after one set at 0: +/// both elements read back, nothing else appears (E1 for the dense case). +#[kani::proof] +#[kani::unwind(8)] +fn dense_set_pair() { + let mut v: Vec = Vec::new(); + assert!(dense::set(&mut v, 0, 1).is_ok()); + let index: u32 = kani::any(); + kani::assume(index < 6); + assert!(dense::set(&mut v, index, 2).is_ok()); + assert_eq!(dense::get(&v, index), Some(2)); + if index != 0 { + assert_eq!(dense::get(&v, 0), Some(1)); + } + let want_len = index.saturating_add(1).max(1); + assert_eq!(u32::try_from(v.len()), Ok(want_len)); + assert_eq!(dense::get(&v, want_len), None); +} + +/// An empty array has no element at any index. +#[kani::proof] +fn elements_empty_get_any() { + let e = Elements::new(); + let i: u32 = kani::any(); + assert_eq!(e.get(i), None); + assert_eq!(e.len(), 0); +} + +/// Y4: for every `u32` key, decoding then encoding gives it back, and a +/// string and a symbol with the same number never share a key. +#[kani::proof] +fn symbol_key_encoding_any() { + let k: u32 = kani::any(); + assert_eq!(encode(decode(Key(k))), Some(Key(k))); + let n: u32 = kani::any(); + kani::assume(n < SYMBOL_BIT); + let s = encode(PropertyKey::String(Key(n))); + let y = encode(PropertyKey::Symbol(SymbolId(n))); + assert!(s.is_some() && y.is_some()); + assert_ne!(s, y); + assert_eq!(s.map(decode), Some(PropertyKey::String(Key(n)))); + assert_eq!(y.map(decode), Some(PropertyKey::Symbol(SymbolId(n)))); + // Numbers at or above 2^31 are refused, never wrapped (Y5). + let big: u32 = kani::any(); + kani::assume(big >= SYMBOL_BIT); + assert_eq!(encode(PropertyKey::String(Key(big))), None); + assert_eq!(encode(PropertyKey::Symbol(SymbolId(big))), None); +} From d7ab1b859cc21a3754078f9ac032c0044b349ea0 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 14:28:31 +0000 Subject: [PATCH 017/195] clazel-js-heap: the collector's contract (invariants GC1 to GC9, reachability spec) The invariant first: a slot reachable from the roots is never freed. Spec and unit tests of the spec only; no collector yet. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-heap/src/gc/contract.rs | 251 +++++++++++++++++++++++ crates/clazel-js-heap/src/gc/mod.rs | 4 + crates/clazel-js-heap/src/lib.rs | 1 + 3 files changed, 256 insertions(+) create mode 100644 crates/clazel-js-heap/src/gc/contract.rs create mode 100644 crates/clazel-js-heap/src/gc/mod.rs diff --git a/crates/clazel-js-heap/src/gc/contract.rs b/crates/clazel-js-heap/src/gc/contract.rs new file mode 100644 index 00000000..0eb008d7 --- /dev/null +++ b/crates/clazel-js-heap/src/gc/contract.rs @@ -0,0 +1,251 @@ +//! The collector's contract (phase-7.md items 7.0(f) and 7.6), stated before +//! the implementation (CLAUDE.md rule 3). This is the part a person reads. +//! +//! # Model +//! +//! 7.0(f) chooses G1: a stop-the-world, non-moving mark and sweep over the +//! arena. A collection starts from the **roots** and keeps what they reach. +//! The heap is abstracted here as a [`Node`] graph over arena slot indices: +//! node `i` is slot `i`. +//! +//! - A **strong edge** `i -> j` is a reference stored in object `i` that +//! keeps `j` alive: a property or element value, the prototype, a +//! `FinalizationRegistry`'s callback and held values. +//! - An **ephemeron** `(k, v)` of node `i` is one `WeakMap` entry: the +//! value `v` is kept alive only while both the map `i` and the key `k` +//! are alive (ECMA-262, "WeakMap Objects" and "Processing Model of +//! WeakRef and FinalizationRegistry Targets", whose liveness definition +//! makes a WeakMap value live only through its key). +//! - Everything else is **weak** and is not an edge at all: a `WeakSet` +//! member, a `WeakRef` target, a `FinalizationRegistry` cell's target +//! and unregister token, and the key of a `WeakMap` entry itself. +//! +//! # Reachability +//! +//! [`reachable`] is the specification: the least set of nodes that contains +//! every in-range root, contains the target of a strong edge of a member, +//! and contains the value `v` of an ephemeron `(k, v)` of a member when `k` +//! is a member. It is written as the plainest fixpoint, with no worklist +//! and no cleverness, so that reading it is checking it. +//! +//! # Invariants +//! +//! For one collection, with `roots` the references the embedder reports +//! (the value-stack region, the open handles, the objects kept alive for +//! the current job, the DOM wrappers, and the job and task queues): +//! +//! - **GC1 Safety.** A slot reachable from the roots is never freed. It +//! keeps its index and generation, so every reference the program holds +//! to it still resolves, to the same object. This is the invariant the +//! Kani harnesses prove for every heap up to their bound, and the +//! property test checks on random heaps of any size ([`safe`]). +//! - **GC2 Precision.** A slot not reachable from the roots is freed in +//! that collection, so a collection leaves exactly the reachable slots +//! ([`exact`]). Garbage is not a safety matter; this keeps the collector +//! from being "correct" by keeping everything. +//! - **GC3 No dangling references.** After a collection no live object +//! holds a reference, strong or weak, to a slot that is not live. Weak +//! references to a freed slot are removed (GC4), so none is left to +//! alias a later occupant even before the generation check ([`closed`] +//! for the strong ones). +//! - **GC4 Weak clearing.** A `WeakRef` whose target was freed reads as +//! empty. A `WeakMap` entry or `WeakSet` member whose key was freed is +//! removed. A registry cell whose target was freed is removed, and so is +//! an unregister token that was freed. Weak references to survivors are +//! unchanged. +//! - **GC5 Ephemerons.** A `WeakMap` value is kept alive only through its +//! own key: a value that refers to its key does not keep the key alive, +//! and a chain of entries (the value of one is the key of the next) is +//! followed to its end, whatever the order of the entries. +//! - **GC6 Finalization.** Each cell of a *surviving* registry whose target +//! was freed produces exactly one cleanup, for the registry's callback and +//! that cell's held value, which the collection returns for the embedder +//! to run as a task, in that registry's cell order. A freed registry +//! produces none. Both the callback and the held values are kept alive +//! by the collection, and the embedder roots them until the task runs. +//! Nothing runs during a collection. +//! - **GC7 Safe points.** A collection runs only between operations: the +//! heap refuses (`Error::InOperation`) while an operation is in +//! progress, because a handler may hold a reference that no root names. +//! With exit-based JIT code (jit.md, "Exit") that means only from Rust, +//! at the interpreter's dispatch point. +//! - **GC8 Handles.** A handle scope is closed in the order it was opened, +//! and a mismatch is an error, not a silent unrooting. +//! - **GC9 `WeakRef` liveness.** A `WeakRef`'s target read during a job is +//! kept alive until the job ends (ECMA-262 abstract operations +//! `AddToKeptObjects` and `ClearKeptObjects`; section numbers differ +//! between editions, so they are cited by name), so a program never sees +//! a target vanish within one job. +//! +//! The arena's own invariants (`crate::arena::contract`) hold throughout: +//! freeing goes through `Arena::free`, so a stale reference to a freed slot +//! is a defined error, whatever the collector does (7.0(f)). + +/// One slot of the abstract heap graph (see the module header). +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Node { + /// Slots this slot keeps alive. + pub strong: Vec, + /// `WeakMap` entries as `(key, value)` slot pairs. + pub ephemerons: Vec<(usize, usize)>, +} + +/// The nodes reachable from `roots` (module header, "Reachability"), as one +/// flag per node. A root or edge naming no node (a stale or out-of-range +/// reference) reaches nothing. +#[must_use] +pub fn reachable(graph: &[Node], roots: &[usize]) -> Vec { + let mut marked = vec![false; graph.len()]; + for &r in roots { + mark(&mut marked, r); + } + loop { + let mut changed = false; + for (i, node) in graph.iter().enumerate() { + if !marked.get(i).copied().unwrap_or(false) { + continue; + } + for &e in &node.strong { + changed |= mark(&mut marked, e); + } + for &(k, v) in &node.ephemerons { + if marked.get(k).copied().unwrap_or(false) { + changed |= mark(&mut marked, v); + } + } + } + if !changed { + return marked; + } + } +} + +/// Mark node `i`; whether that changed anything. +fn mark(marked: &mut [bool], i: usize) -> bool { + match marked.get_mut(i) { + Some(m) if !*m => { + *m = true; + true + } + _ => false, + } +} + +/// GC1: every reachable node survives. +#[must_use] +pub fn safe(graph: &[Node], roots: &[usize], survives: &[bool]) -> bool { + survives.len() == graph.len() + && reachable(graph, roots) + .iter() + .zip(survives) + .all(|(&r, &s)| !r || s) +} + +/// GC1 and GC2: exactly the reachable nodes survive. +#[must_use] +pub fn exact(graph: &[Node], roots: &[usize], survives: &[bool]) -> bool { + reachable(graph, roots) == survives +} + +/// GC3 for the survivors: every strong edge of a surviving node, and every +/// ephemeron value whose key survives, names a surviving node. An ephemeron +/// key of a surviving map may name a freed node only before GC4 clears the +/// entry, so keys are not checked here. +#[must_use] +pub fn closed(graph: &[Node], survives: &[bool]) -> bool { + let alive = |i: usize| survives.get(i).copied().unwrap_or(false); + graph + .iter() + .enumerate() + .filter(|&(i, _)| alive(i)) + .all(|(_, n)| { + n.strong.iter().all(|&e| alive(e)) + && n.ephemerons.iter().all(|&(k, v)| !alive(k) || alive(v)) + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn node(strong: &[usize], eph: &[(usize, usize)]) -> Node { + Node { + strong: strong.to_vec(), + ephemerons: eph.to_vec(), + } + } + + #[test] + fn roots_and_strong_edges_are_followed() { + // 0 -> 1 -> 2; 3 is unreachable; 4 -> 0 does not make 4 reachable. + let g = [ + node(&[1], &[]), + node(&[2], &[]), + node(&[], &[]), + node(&[], &[]), + node(&[0], &[]), + ]; + assert_eq!(reachable(&g, &[0]), [true, true, true, false, false]); + assert_eq!(reachable(&g, &[]), [false; 5]); + } + + #[test] + fn cycles_terminate_and_are_not_kept_without_a_root() { + let g = [node(&[1], &[]), node(&[0], &[])]; + assert_eq!(reachable(&g, &[0]), [true, true]); + assert_eq!(reachable(&g, &[]), [false, false]); + } + + #[test] + fn an_ephemeron_value_needs_its_map_and_its_key() { + // Node 0 is a map with entry (1 -> 2). + let g = [node(&[], &[(1, 2)]), node(&[], &[]), node(&[], &[])]; + assert_eq!(reachable(&g, &[0]), [true, false, false]); + assert_eq!(reachable(&g, &[0, 1]), [true, true, true]); + // The key alone, without the map, keeps nothing. + assert_eq!(reachable(&g, &[1]), [false, true, false]); + } + + #[test] + fn a_value_that_refers_to_its_key_does_not_keep_it_alive() { + // Map 0 has entry (1 -> 2), and 2 -> 1. + let g = [node(&[], &[(1, 2)]), node(&[], &[]), node(&[1], &[])]; + assert_eq!(reachable(&g, &[0]), [true, false, false]); + } + + #[test] + fn ephemeron_chains_are_followed_in_any_order() { + // Map 0: (3 -> 2), (2 -> 1), (1 -> 4): listed against the chain. + let g = [ + node(&[], &[(3, 2), (2, 1), (1, 4)]), + node(&[], &[]), + node(&[], &[]), + node(&[], &[]), + node(&[], &[]), + ]; + assert_eq!(reachable(&g, &[0, 3]), [true, true, true, true, true]); + assert_eq!(reachable(&g, &[0]), [true, false, false, false, false]); + } + + #[test] + fn names_of_no_node_reach_nothing() { + let g = [node(&[9], &[(9, 8)])]; + assert_eq!(reachable(&g, &[7, 0]), [true]); + } + + #[test] + fn safe_exact_and_closed_tell_the_cases_apart() { + let g = [node(&[1], &[]), node(&[], &[]), node(&[], &[])]; + assert!(safe(&g, &[0], &[true, true, false])); + assert!(exact(&g, &[0], &[true, true, false])); + // Keeping garbage is safe, not exact. + assert!(safe(&g, &[0], &[true, true, true])); + assert!(!exact(&g, &[0], &[true, true, true])); + // Freeing something reachable is neither. + assert!(!safe(&g, &[0], &[true, false, false])); + assert!(!exact(&g, &[0], &[true, false, false])); + assert!(closed(&g, &[true, true, false])); + assert!(!closed(&g, &[true, false, false])); + assert!(!safe(&g, &[0], &[true])); + } +} diff --git a/crates/clazel-js-heap/src/gc/mod.rs b/crates/clazel-js-heap/src/gc/mod.rs new file mode 100644 index 00000000..117b4011 --- /dev/null +++ b/crates/clazel-js-heap/src/gc/mod.rs @@ -0,0 +1,4 @@ +//! The collector (phase-7.md item 7.6). [`contract`] states what it must +//! satisfy (GC1 to GC9); the implementation follows it. + +pub mod contract; diff --git a/crates/clazel-js-heap/src/lib.rs b/crates/clazel-js-heap/src/lib.rs index 21e2b507..b762a57c 100644 --- a/crates/clazel-js-heap/src/lib.rs +++ b/crates/clazel-js-heap/src/lib.rs @@ -24,6 +24,7 @@ pub mod arena; pub mod elements; +pub mod gc; pub mod shape; pub mod string; pub mod symbol; From 1fc07b018bce40960f012b6fffa96b49c2d9ca1a Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 14:37:16 +0000 Subject: [PATCH 018/195] clazel-js-heap: the collector (mark and sweep, ephemerons, WeakRef, FinalizationRegistry) Implements the contract of the previous commit, with unit tests for each weak kind, the roots, handles and the safe-point guard, and a fixed-seed property test of GC1 to GC6 over random heaps checked against an independent oracle. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-heap/Cargo.toml | 2 +- crates/clazel-js-heap/src/gc/mod.rs | 502 ++++++++++++++++- crates/clazel-js-heap/src/gc/tests.rs | 783 ++++++++++++++++++++++++++ crates/clazel-js-heap/src/lib.rs | 5 +- 4 files changed, 1288 insertions(+), 4 deletions(-) create mode 100644 crates/clazel-js-heap/src/gc/tests.rs diff --git a/crates/clazel-js-heap/Cargo.toml b/crates/clazel-js-heap/Cargo.toml index 18d2bf7d..28e3897d 100644 --- a/crates/clazel-js-heap/Cargo.toml +++ b/crates/clazel-js-heap/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" edition.workspace = true license.workspace = true publish.workspace = true -description = "The JavaScript engine's heap for Clazel's Phase 7 browser (phase-7.md item 7.5): NaN-boxed values, a generational index arena, Latin-1/UTF-16 strings with interned property keys, and shapes." +description = "The JavaScript engine's heap for Clazel's Phase 7 browser (phase-7.md item 7.5): NaN-boxed values, a generational index arena, Latin-1/UTF-16 strings with interned property keys, shapes, elements, symbols, and (item 7.6) the mark-and-sweep collector with weak references." # No dependencies: the heap is ours end to end (CLAUDE.md rule 8), and it # depends on no browser crate (phase-7.md, "The engine as a library"). diff --git a/crates/clazel-js-heap/src/gc/mod.rs b/crates/clazel-js-heap/src/gc/mod.rs index 117b4011..105c14ce 100644 --- a/crates/clazel-js-heap/src/gc/mod.rs +++ b/crates/clazel-js-heap/src/gc/mod.rs @@ -1,4 +1,504 @@ //! The collector (phase-7.md item 7.6). [`contract`] states what it must -//! satisfy (GC1 to GC9); the implementation follows it. +//! satisfy (GC1 to GC9); this is the implementation, and `src/proofs.rs` +//! holds the Kani harnesses for it. +//! +//! 7.0(f) G1: stop-the-world mark and sweep, non-moving. A collection: +//! +//! 1. refuses to run during an operation (GC7); +//! 2. builds the abstract graph of the live objects ([`Heap::graph`]) and +//! the root slots, from the caller's roots, the open handle scopes and +//! the objects kept alive for the job (GC9); +//! 3. marks ([`mark`], which is proven equal to [`contract::reachable`]); +//! 4. clears weak references to unmarked slots and takes the finalization +//! cleanups (GC4, GC6); +//! 5. frees every unmarked slot through [`Arena::free`], which bumps its +//! generation (GC2; the arena's invariant 3). +//! +//! # What an embedder reports +//! +//! 7.0(f) names the roots: the value-stack region, the handles that +//! bindings and built-ins hold, every DOM node's wrapper, and the job and +//! task queues. The heap knows its own handle stack and kept-alive list; +//! the rest the embedder passes to [`Heap::collect`] as `roots` (the +//! engine's `Host` tracing method makes the DOM wrappers and task queues +//! part of that list). The cleanups a collection returns are tasks; their +//! callback and held values are alive after the collection, and the +//! embedder must report them as roots until it has run them. +//! +//! # What is not here +//! +//! Strings in the property-key interner and shapes live outside the arena +//! and are not collected in this slice; neither holds a reference into it. pub mod contract; + +use crate::arena::{self, Arena, Ref}; +use crate::elements::Elements; +use crate::value::Value; +use contract::Node; + +/// What a heap object is, beyond its ordinary properties. +#[derive(Clone, Debug)] +pub enum Kind { + /// An object with only strong properties. + Ordinary, + /// `WeakMap`: `(key, value)` entries; the key is weak, and the value is + /// kept alive by the key (an ephemeron). + WeakMap(Vec<(Ref, Value)>), + /// `WeakSet`: weakly held members. + WeakSet(Vec), + /// `WeakRef`: a weakly held target, `None` once cleared. + WeakRef(Option), + /// `FinalizationRegistry`. + Registry(Registry), +} + +/// A `FinalizationRegistry`'s state. +#[derive(Clone, Debug)] +pub struct Registry { + /// The cleanup callback, held strongly. + pub callback: Value, + /// Registered targets. + pub cells: Vec, +} + +/// One `FinalizationRegistry.prototype.register` call. +#[derive(Clone, Copy, Debug)] +pub struct Cell { + /// The weakly held target. + pub target: Ref, + /// The value passed to the callback, held strongly. + pub held: Value, + /// The weakly held unregister token, if any. + pub token: Option, +} + +/// A heap object: a prototype, property slots, indexed elements and a kind. +#[derive(Clone, Debug)] +pub struct Object { + /// The prototype, a strong reference. + pub proto: Option, + /// Property values (a shape maps keys to these indices), all strong. + pub slots: Vec, + /// Indexed properties, all strong. + pub elements: Elements, + /// What kind of object this is. + pub kind: Kind, +} + +impl Object { + /// An ordinary object with no properties and no prototype. + #[must_use] + pub const fn ordinary() -> Self { + Self::of(Kind::Ordinary) + } + + /// An object of the given kind with no properties and no prototype. + #[must_use] + pub const fn of(kind: Kind) -> Self { + Self { + proto: None, + slots: Vec::new(), + elements: Elements::new(), + kind, + } + } +} + +/// One finalization callback to run: the embedder queues it as a task +/// (GC6). Nothing runs during a collection. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct Cleanup { + /// The registry's callback. + pub callback: Value, + /// The held value of the cell whose target was freed. + pub held: Value, +} + +/// What one collection did. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Collection { + /// Slots freed. + pub freed: usize, + /// Slots that survived. + pub survivors: usize, + /// Cleanups for the embedder to run as tasks. + pub cleanups: Vec, +} + +/// Why a heap operation failed. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Error { + /// The arena refused ([`arena::Error`]). + Arena(arena::Error), + /// A collection was requested during an operation (GC7). + InOperation, + /// `exit_op` without a matching `enter_op`. + NotInOperation, + /// A handle was made with no scope open. + NoScope, + /// A scope was closed out of order (GC8). + ScopeMismatch, + /// The reference does not name a live `WeakRef`. + NotAWeakRef, +} + +impl From for Error { + fn from(e: arena::Error) -> Self { + Self::Arena(e) + } +} + +/// An open handle scope; closing it unroots the handles made in it. +#[derive(Debug)] +pub struct Scope { + depth: usize, +} + +/// The heap: the arena of objects, the handle stack, the objects kept +/// alive for the current job and the operation guard. +#[derive(Debug)] +pub struct Heap { + arena: Arena, + handles: Vec, + scope_marks: Vec, + kept: Vec, + op_depth: u32, +} + +impl Default for Heap { + fn default() -> Self { + Self::new() + } +} + +/// Which slots are alive after marking: the generation of each live slot +/// (before the sweep) and its mark. Owned, so the sweep can mutate the +/// arena while asking it. +struct Liveness { + generation: Vec>, + marked: Vec, +} + +impl Liveness { + /// Whether `r` names an object that survives this collection. + fn survives(&self, r: Ref) -> bool { + let Some(i) = usize::try_from(r.index).ok() else { + return false; + }; + self.generation.get(i).copied().flatten() == Some(r.generation) + && self.marked.get(i).copied().unwrap_or(false) + } +} + +impl Heap { + /// An empty heap that may grow to [`arena::MAX_SLOTS`] objects. + #[must_use] + pub fn new() -> Self { + Self::with_limit(arena::MAX_SLOTS) + } + + /// An empty heap of at most `limit` objects: the memory limit, and the + /// harnesses' bound. + #[must_use] + pub fn with_limit(limit: usize) -> Self { + Self { + arena: Arena::with_limit(limit), + handles: Vec::new(), + scope_marks: Vec::new(), + kept: Vec::new(), + op_depth: 0, + } + } + + /// Store an object. Never collects: a full heap is reported, and the + /// embedder collects at its next safe point. + /// + /// # Errors + /// [`arena::Error::Full`] as [`Error::Arena`]. + pub fn alloc(&mut self, object: Object) -> Result { + Ok(self.arena.alloc(object)?) + } + + /// The object `r` names. + /// + /// # Errors + /// [`Error::Arena`]: out of range, or stale. + pub fn get(&self, r: Ref) -> Result<&Object, Error> { + Ok(self.arena.get(r)?) + } + + /// The object `r` names, mutably. + /// + /// # Errors + /// As [`Heap::get`]. + pub fn get_mut(&mut self, r: Ref) -> Result<&mut Object, Error> { + Ok(self.arena.get_mut(r)?) + } + + /// Whether `r` names a live object. + #[must_use] + pub fn is_live(&self, r: Ref) -> bool { + self.arena.is_live(r) + } + + /// The number of live objects. + #[must_use] + pub const fn live(&self) -> usize { + self.arena.live() + } + + /// The arena, for its invariants' checks. + #[must_use] + pub const fn arena(&self) -> &Arena { + &self.arena + } + + /// An operation begins: no collection may run until it ends (GC7). + pub fn enter_op(&mut self) { + self.op_depth = self.op_depth.saturating_add(1); + } + + /// The operation ends. + /// + /// # Errors + /// [`Error::NotInOperation`] if none was begun. + pub fn exit_op(&mut self) -> Result<(), Error> { + self.op_depth = self.op_depth.checked_sub(1).ok_or(Error::NotInOperation)?; + Ok(()) + } + + /// Open a handle scope (GC8). + pub fn open_scope(&mut self) -> Scope { + self.scope_marks.push(self.handles.len()); + Scope { + depth: self.scope_marks.len(), + } + } + + /// Root `v` until the innermost scope closes; returns it. + /// + /// # Errors + /// [`Error::NoScope`] if no scope is open. + pub fn root(&mut self, v: Value) -> Result { + if self.scope_marks.is_empty() { + return Err(Error::NoScope); + } + self.handles.push(v); + Ok(v) + } + + /// Close `scope`, unrooting its handles. + /// + /// # Errors + /// [`Error::ScopeMismatch`] if it is not the innermost open scope; the + /// handles stay rooted then. + pub fn close_scope(&mut self, scope: Scope) -> Result<(), Error> { + if scope.depth != self.scope_marks.len() { + return Err(Error::ScopeMismatch); + } + let to = self.scope_marks.pop().ok_or(Error::ScopeMismatch)?; + self.handles.truncate(to); + Ok(()) + } + + /// `WeakRef.prototype.deref` (ECMA-262 `AddToKeptObjects`): the target, + /// or `None` if it was collected. A live target is kept alive until + /// [`Heap::end_job`] (GC9). + /// + /// # Errors + /// [`Error::NotAWeakRef`] if `weak` is not a live `WeakRef`. + pub fn deref_weak(&mut self, weak: Ref) -> Result, Error> { + let Kind::WeakRef(target) = self.arena.get(weak)?.kind else { + return Err(Error::NotAWeakRef); + }; + let Some(t) = target.filter(|&t| self.arena.is_live(t)) else { + return Ok(None); + }; + self.kept.push(t); + Ok(Some(t)) + } + + /// The job ends (ECMA-262 `ClearKeptObjects`): the targets read by + /// `deref_weak` are no longer kept alive. + pub fn end_job(&mut self) { + self.kept.clear(); + } + + /// The abstract graph of the heap: one node per arena slot, the empty + /// node for a slot that is not live. A reference to a slot that is not + /// live, or is a different generation, is no edge. + #[must_use] + pub fn graph(&self) -> Vec { + let mut nodes = vec![Node::default(); self.arena.slots()]; + let idx = |r: Ref| -> Option { + self.arena + .is_live(r) + .then(|| usize::try_from(r.index).ok()) + .flatten() + }; + let val = |v: Value| v.as_ref().and_then(idx); + for (r, o) in self.arena.iter() { + let Some(node) = usize::try_from(r.index).ok().and_then(|i| nodes.get_mut(i)) else { + continue; + }; + node.strong.extend(o.proto.and_then(idx)); + node.strong.extend(o.slots.iter().copied().filter_map(val)); + node.strong.extend(o.elements.values().filter_map(val)); + match &o.kind { + Kind::Ordinary | Kind::WeakSet(_) | Kind::WeakRef(_) => {} + Kind::WeakMap(entries) => { + for &(k, v) in entries { + if let (Some(k), Some(v)) = (idx(k), val(v)) { + node.ephemerons.push((k, v)); + } + } + } + Kind::Registry(reg) => { + node.strong.extend(val(reg.callback)); + node.strong + .extend(reg.cells.iter().filter_map(|c| val(c.held))); + } + } + } + nodes + } + + /// The slot indices of the live objects among `roots`, the open + /// handles and the kept-alive targets. + #[must_use] + pub fn root_indices(&self, roots: &[Value]) -> Vec { + let from_refs = self.kept.iter().copied(); + let from_values = roots + .iter() + .chain(self.handles.iter()) + .filter_map(|v| v.as_ref()); + from_refs + .chain(from_values) + .filter(|&r| self.arena.is_live(r)) + .filter_map(|r| usize::try_from(r.index).ok()) + .collect() + } + + /// Collect garbage (module header). `roots` are the embedder's: + /// the value stack, DOM wrappers, task queues and pending cleanups. + /// + /// # Errors + /// [`Error::InOperation`] during an operation (GC7); nothing changes. + /// [`Error::Arena`] if the arena reports corruption while freeing + /// (unreachable by construction). + pub fn collect(&mut self, roots: &[Value]) -> Result { + if self.op_depth != 0 { + return Err(Error::InOperation); + } + let graph = self.graph(); + let marked = mark(&graph, &self.root_indices(roots)); + let mut generation = vec![None; self.arena.slots()]; + let live: Vec = self.arena.iter().map(|(r, _)| r).collect(); + for r in &live { + if let Some(g) = usize::try_from(r.index) + .ok() + .and_then(|i| generation.get_mut(i)) + { + *g = Some(r.generation); + } + } + let liveness = Liveness { generation, marked }; + let mut out = Collection::default(); + for &r in &live { + if liveness.survives(r) { + out.survivors = out.survivors.saturating_add(1); + if let Ok(o) = self.arena.get_mut(r) { + clear_weak(o, &liveness, &mut out.cleanups); + } + } else { + self.arena.free(r)?; + out.freed = out.freed.saturating_add(1); + } + } + Ok(out) + } +} + +/// GC4 and GC6 for one surviving object: remove weak references to freed +/// slots, and take the cleanups of a registry's dead cells. +fn clear_weak(o: &mut Object, live: &Liveness, cleanups: &mut Vec) { + match &mut o.kind { + Kind::Ordinary => {} + Kind::WeakMap(entries) => entries.retain(|&(k, _)| live.survives(k)), + Kind::WeakSet(members) => members.retain(|&m| live.survives(m)), + Kind::WeakRef(target) => { + if target.is_some_and(|t| !live.survives(t)) { + *target = None; + } + } + Kind::Registry(reg) => { + let callback = reg.callback; + reg.cells.retain_mut(|cell| { + if live.survives(cell.target) { + if cell.token.is_some_and(|t| !live.survives(t)) { + cell.token = None; + } + true + } else { + cleanups.push(Cleanup { + callback, + held: cell.held, + }); + false + } + }); + } + } +} + +/// Mark the nodes reachable from `roots`: a worklist for the strong edges, +/// and passes over the ephemerons until none marks anything new. +/// [`contract::reachable`] is its specification, and the Kani harnesses +/// prove them equal on every graph of their bound. +#[must_use] +pub fn mark(graph: &[Node], roots: &[usize]) -> Vec { + let mut marked = vec![false; graph.len()]; + let mut work: Vec = Vec::new(); + for &r in roots { + visit(&mut marked, &mut work, r); + } + loop { + while let Some(i) = work.pop() { + if let Some(node) = graph.get(i) { + for &e in &node.strong { + visit(&mut marked, &mut work, e); + } + } + } + let mut progressed = false; + for (i, node) in graph.iter().enumerate() { + if !marked.get(i).copied().unwrap_or(false) { + continue; + } + for &(k, v) in &node.ephemerons { + if marked.get(k).copied().unwrap_or(false) { + progressed |= visit(&mut marked, &mut work, v); + } + } + } + if !progressed { + return marked; + } + } +} + +/// Mark `i` and queue it, if it names a node not yet marked. +fn visit(marked: &mut [bool], work: &mut Vec, i: usize) -> bool { + match marked.get_mut(i) { + Some(m) if !*m => { + *m = true; + work.push(i); + true + } + _ => false, + } +} + +#[cfg(test)] +mod tests; diff --git a/crates/clazel-js-heap/src/gc/tests.rs b/crates/clazel-js-heap/src/gc/tests.rs new file mode 100644 index 00000000..b229de7e --- /dev/null +++ b/crates/clazel-js-heap/src/gc/tests.rs @@ -0,0 +1,783 @@ +//! Unit tests for each weak kind and for the roots, and the property test of +//! GC1 to GC6 over random heaps of any size, from a fixed-seed generator. + +use super::contract::{self, Node}; +use super::*; +use crate::arena::Error as ArenaError; +use std::collections::HashSet; + +type R = Result; + +fn obj(h: &mut Heap) -> R { + h.alloc(Object::ordinary()) +} + +fn val(r: Ref) -> Value { + Value::heap_ref(r) +} + +fn int(i: i32) -> Value { + Value::int32(i) +} + +fn kind_of(h: &mut Heap, kind: Kind) -> R { + h.alloc(Object::of(kind)) +} + +fn stale(h: &Heap, r: Ref) -> bool { + h.get(r).err() == Some(Error::Arena(ArenaError::Stale)) +} + +fn add_slot(h: &mut Heap, to: Ref, v: Value) -> R<()> { + h.get_mut(to)?.slots.push(v); + Ok(()) +} + +// ---- Roots and tracing ------------------------------------------------ + +#[test] +fn what_the_roots_reach_survives_and_the_rest_is_freed() -> R<()> { + let mut h = Heap::new(); + let a = obj(&mut h)?; + let b = obj(&mut h)?; + let c = obj(&mut h)?; + let garbage = obj(&mut h)?; + add_slot(&mut h, a, val(b))?; + add_slot(&mut h, b, val(c))?; + add_slot(&mut h, garbage, val(a))?; + // Prototype and element edges count too. + let d = obj(&mut h)?; + h.get_mut(c)?.proto = Some(d); + let e = obj(&mut h)?; + assert_eq!(h.get_mut(d)?.elements.set(3, val(e)), Ok(())); + let out = h.collect(&[val(a)])?; + assert_eq!((out.freed, out.survivors), (1, 5)); + for r in [a, b, c, d, e] { + assert!(h.is_live(r)); + } + assert!(stale(&h, garbage)); + assert!(h.arena().is_well_formed()); + Ok(()) +} + +#[test] +fn cycles_without_a_root_are_freed() -> R<()> { + let mut h = Heap::new(); + let a = obj(&mut h)?; + let b = obj(&mut h)?; + add_slot(&mut h, a, val(b))?; + add_slot(&mut h, b, val(a))?; + let out = h.collect(&[int(7), Value::UNDEFINED])?; + assert_eq!((out.freed, h.live()), (2, 0)); + Ok(()) +} + +#[test] +fn a_freed_slot_is_reused_with_a_new_generation_so_old_references_stay_stale() -> R<()> { + let mut h = Heap::new(); + let old = obj(&mut h)?; + h.collect(&[])?; + let new = obj(&mut h)?; + assert_eq!(new.index, old.index); + assert_ne!(new.generation, old.generation); + assert!(stale(&h, old)); + // A stale root reaches nothing, and does not keep the new occupant. + h.collect(&[val(old)])?; + assert!(stale(&h, new) || !h.is_live(new)); + Ok(()) +} + +#[test] +fn a_long_chain_does_not_recurse() -> R<()> { + let mut h = Heap::new(); + let head = obj(&mut h)?; + let mut tail = head; + for _ in 0..100_000 { + let n = obj(&mut h)?; + add_slot(&mut h, tail, val(n))?; + tail = n; + } + let out = h.collect(&[val(head)])?; + assert_eq!((out.freed, out.survivors), (0, 100_001)); + let out = h.collect(&[])?; + assert_eq!(out.freed, 100_001); + Ok(()) +} + +#[test] +fn the_value_stack_handles_and_kept_objects_are_roots() -> R<()> { + let mut h = Heap::new(); + let on_stack = obj(&mut h)?; + let handled = obj(&mut h)?; + let nested = obj(&mut h)?; + let garbage = obj(&mut h)?; + let scope = h.open_scope(); + h.root(val(handled))?; + let inner = h.open_scope(); + h.root(val(nested))?; + h.collect(&[val(on_stack)])?; + assert!(h.is_live(on_stack) && h.is_live(handled) && h.is_live(nested)); + assert!(stale(&h, garbage)); + h.close_scope(inner)?; + h.collect(&[])?; + assert!(h.is_live(handled) && !h.is_live(nested) && !h.is_live(on_stack)); + h.close_scope(scope)?; + h.collect(&[])?; + assert_eq!(h.live(), 0); + Ok(()) +} + +#[test] +fn scopes_close_in_order_and_handles_need_a_scope() -> R<()> { + let mut h = Heap::new(); + let a = obj(&mut h)?; + assert_eq!(h.root(val(a)), Err(Error::NoScope)); + let outer = h.open_scope(); + let inner = h.open_scope(); + assert_eq!(h.close_scope(outer), Err(Error::ScopeMismatch)); + h.close_scope(inner)?; + h.close_scope(Scope { depth: 1 })?; + // The mismatch above did not unroot anything. + let s = h.open_scope(); + h.root(val(a))?; + let t = h.open_scope(); + assert_eq!(h.close_scope(s), Err(Error::ScopeMismatch)); + h.collect(&[])?; + assert!(h.is_live(a)); + h.close_scope(t)?; + Ok(()) +} + +#[test] +fn a_collection_is_refused_during_an_operation() -> R<()> { + let mut h = Heap::new(); + let a = obj(&mut h)?; + assert_eq!(h.exit_op(), Err(Error::NotInOperation)); + h.enter_op(); + h.enter_op(); + assert_eq!(h.collect(&[]).err(), Some(Error::InOperation)); + h.exit_op()?; + assert_eq!(h.collect(&[]).err(), Some(Error::InOperation)); + h.exit_op()?; + assert!(h.is_live(a), "the refused collection freed nothing"); + assert_eq!(h.collect(&[])?.freed, 1); + Ok(()) +} + +// ---- WeakMap and WeakSet ---------------------------------------------- + +fn weak_map(h: &mut Heap, entries: &[(Ref, Value)]) -> R { + kind_of(h, Kind::WeakMap(entries.to_vec())) +} + +fn map_entries(h: &Heap, m: Ref) -> R> { + match &h.get(m)?.kind { + Kind::WeakMap(e) => Ok(e.clone()), + _ => Err(Error::NotAWeakRef), + } +} + +#[test] +fn a_weakmap_entry_lives_while_its_key_does() -> R<()> { + let mut h = Heap::new(); + let key = obj(&mut h)?; + let dead_key = obj(&mut h)?; + let value = obj(&mut h)?; + let dead_value = obj(&mut h)?; + let m = weak_map( + &mut h, + &[ + (key, val(value)), + (dead_key, val(dead_value)), + (key, int(1)), + ], + )?; + let out = h.collect(&[val(m), val(key)])?; + assert_eq!(out.freed, 2); + assert!(h.is_live(value) && stale(&h, dead_value) && stale(&h, dead_key)); + assert_eq!(map_entries(&h, m)?, [(key, val(value)), (key, int(1))]); + // Drop the key: the entries go, and so does the value. + h.collect(&[val(m)])?; + assert_eq!(map_entries(&h, m)?, []); + assert!(stale(&h, value) && stale(&h, key)); + Ok(()) +} + +#[test] +fn a_weakmap_does_not_keep_its_keys_and_an_unreachable_map_is_freed() -> R<()> { + let mut h = Heap::new(); + let key = obj(&mut h)?; + let value = obj(&mut h)?; + // The value refers to its key: still not enough to keep the key. + add_slot(&mut h, value, val(key))?; + let m = weak_map(&mut h, &[(key, val(value))])?; + h.collect(&[val(m)])?; + assert_eq!(h.live(), 1); + // Without the map, a rooted key keeps nothing of the map's. + let k2 = obj(&mut h)?; + let v2 = obj(&mut h)?; + let m2 = weak_map(&mut h, &[(k2, val(v2))])?; + h.collect(&[val(k2)])?; + assert!(h.is_live(k2) && stale(&h, v2) && stale(&h, m2) && stale(&h, m)); + Ok(()) +} + +#[test] +fn ephemeron_chains_resolve_in_any_entry_order() -> R<()> { + // Entries (k[i] -> k[i+1]) listed from the end of the chain to the start. + let mut h = Heap::new(); + let ks: Vec = (0..2000).map(|_| obj(&mut h)).collect::>()?; + let entries: Vec<(Ref, Value)> = ks + .windows(2) + .rev() + .filter_map(|w| Some((*w.first()?, val(*w.get(1)?)))) + .collect(); + let m = weak_map(&mut h, &entries)?; + let first = *ks.first().ok_or(Error::NoScope)?; + h.collect(&[val(m), val(first)])?; + assert_eq!(h.live(), 2001, "the whole chain, and the map"); + h.collect(&[val(m)])?; + assert_eq!(h.live(), 1, "the map alone"); + Ok(()) +} + +#[test] +fn a_weakset_drops_dead_members_and_keeps_none_alive() -> R<()> { + let mut h = Heap::new(); + let live = obj(&mut h)?; + let dead = obj(&mut h)?; + let s = kind_of(&mut h, Kind::WeakSet(vec![live, dead, live]))?; + h.collect(&[val(s), val(live)])?; + assert!(matches!(&h.get(s)?.kind, Kind::WeakSet(m) if *m == [live, live])); + assert!(stale(&h, dead)); + h.collect(&[val(s)])?; + assert!(matches!(&h.get(s)?.kind, Kind::WeakSet(m) if m.is_empty())); + Ok(()) +} + +// ---- WeakRef ---------------------------------------------------------- + +#[test] +fn a_weakref_is_cleared_when_its_target_is_freed() -> R<()> { + let mut h = Heap::new(); + let target = obj(&mut h)?; + let w = kind_of(&mut h, Kind::WeakRef(Some(target)))?; + let w2 = kind_of(&mut h, Kind::WeakRef(Some(target)))?; + // Rooted target: both stay set. + h.collect(&[val(w), val(w2), val(target)])?; + assert_eq!(h.deref_weak(w)?, Some(target)); + h.end_job(); + // Unrooted: cleared, the target freed, and a clear WeakRef stays clear. + h.collect(&[val(w)])?; + assert_eq!(h.deref_weak(w)?, None); + assert!(stale(&h, target) && stale(&h, w2)); + h.collect(&[val(w)])?; + assert_eq!(h.deref_weak(w)?, None); + Ok(()) +} + +#[test] +fn a_target_read_in_a_job_is_kept_until_the_job_ends() -> R<()> { + let mut h = Heap::new(); + let target = obj(&mut h)?; + let w = kind_of(&mut h, Kind::WeakRef(Some(target)))?; + assert_eq!(h.deref_weak(w)?, Some(target)); + h.collect(&[val(w)])?; + assert!(h.is_live(target), "GC9: kept for the job"); + assert_eq!(h.deref_weak(w)?, Some(target)); + h.end_job(); + h.collect(&[val(w)])?; + assert!(stale(&h, target)); + assert_eq!(h.deref_weak(w)?, None); + Ok(()) +} + +#[test] +fn deref_of_something_that_is_not_a_weakref_is_an_error() -> R<()> { + let mut h = Heap::new(); + let o = obj(&mut h)?; + assert_eq!(h.deref_weak(o), Err(Error::NotAWeakRef)); + h.collect(&[])?; + assert_eq!(h.deref_weak(o), Err(Error::Arena(ArenaError::Stale))); + Ok(()) +} + +// ---- FinalizationRegistry --------------------------------------------- + +fn registry(h: &mut Heap, callback: Value, cells: Vec) -> R { + kind_of(h, Kind::Registry(Registry { callback, cells })) +} + +fn cell(target: Ref, held: Value, token: Option) -> Cell { + Cell { + target, + held, + token, + } +} + +fn cells_of(h: &Heap, r: Ref) -> R> { + match &h.get(r)?.kind { + Kind::Registry(reg) => Ok(reg.cells.clone()), + _ => Err(Error::NotAWeakRef), + } +} + +#[test] +fn a_dead_target_queues_one_cleanup_and_its_cell_goes() -> R<()> { + let mut h = Heap::new(); + let callback = obj(&mut h)?; + let held = obj(&mut h)?; + let alive = obj(&mut h)?; + let dies = obj(&mut h)?; + let dies_too = obj(&mut h)?; + let reg = registry( + &mut h, + val(callback), + vec![ + cell(dies, val(held), None), + cell(alive, int(5), None), + cell(dies_too, int(6), None), + ], + )?; + let out = h.collect(&[val(reg), val(alive)])?; + assert_eq!( + out.cleanups, + [ + Cleanup { + callback: val(callback), + held: val(held) + }, + Cleanup { + callback: val(callback), + held: int(6) + }, + ] + ); + // The callback and the held value outlive the collection (GC6). + assert!(h.is_live(callback) && h.is_live(held)); + assert!(stale(&h, dies) && stale(&h, dies_too)); + let left = cells_of(&h, reg)?; + assert_eq!(left.len(), 1); + assert_eq!(left.first().map(|c| c.target), Some(alive)); + // No cleanup is repeated. + assert_eq!(h.collect(&[val(reg), val(alive)])?.cleanups, []); + // When the target goes later, it is queued then. + let out = h.collect(&[val(reg)])?; + assert_eq!(out.cleanups.len(), 1); + Ok(()) +} + +#[test] +fn an_unreachable_registry_queues_nothing() -> R<()> { + let mut h = Heap::new(); + let target = obj(&mut h)?; + let reg = registry(&mut h, int(0), vec![cell(target, int(1), None)])?; + let out = h.collect(&[])?; + assert_eq!((out.freed, out.cleanups.len()), (2, 0)); + assert!(stale(&h, reg)); + Ok(()) +} + +#[test] +fn a_dead_unregister_token_is_cleared_and_a_live_one_kept() -> R<()> { + let mut h = Heap::new(); + let target = obj(&mut h)?; + let tok_live = obj(&mut h)?; + let tok_dead = obj(&mut h)?; + let reg = registry( + &mut h, + int(0), + vec![ + cell(target, int(1), Some(tok_live)), + cell(target, int(2), Some(tok_dead)), + ], + )?; + let out = h.collect(&[val(reg), val(target), val(tok_live)])?; + assert!(out.cleanups.is_empty()); + let cells = cells_of(&h, reg)?; + assert_eq!( + cells.iter().map(|c| c.token).collect::>(), + [Some(tok_live), None] + ); + assert!(stale(&h, tok_dead)); + Ok(()) +} + +#[test] +fn held_values_are_strong_so_a_held_value_naming_its_target_keeps_it() -> R<()> { + // The standard says so: the registry holds `held` strongly. + let mut h = Heap::new(); + let target = obj(&mut h)?; + let reg = registry(&mut h, int(0), vec![cell(target, val(target), None)])?; + let out = h.collect(&[val(reg)])?; + assert!(out.cleanups.is_empty() && h.is_live(target)); + Ok(()) +} + +// ---- The property test ------------------------------------------------ + +/// A small deterministic generator, so the test needs no dependency. +struct Lcg(u64); + +impl Lcg { + fn next(&mut self) -> u64 { + self.0 = self + .0 + .wrapping_mul(6_364_136_223_846_793_005) + .wrapping_add(1_442_695_040_888_963_407); + self.0 >> 33 + } + + /// A number below `n` (which is not zero). + fn below(&mut self, n: usize) -> usize { + let n = u64::try_from(n.max(1)).unwrap_or(1); + usize::try_from(self.next().checked_rem(n).unwrap_or(0)).unwrap_or(0) + } + + fn chance(&mut self, percent: usize) -> bool { + self.below(100) < percent + } + + fn pick(&mut self, live: &[Ref]) -> Option { + live.get(self.below(live.len())).copied() + } + + /// A reference to a live object about nine times in ten, else an int. + fn value(&mut self, live: &[Ref]) -> Value { + match self.pick(live) { + Some(r) if !self.chance(10) => val(r), + _ => int(i32::try_from(self.next() % 1000).unwrap_or(0)), + } + } +} + +/// Everything a collection may change about an object, as plain data. +#[derive(Clone, Debug, PartialEq)] +struct Snap { + proto: Option, + slots: Vec, + elements: Vec, + entries: Vec<(Ref, Value)>, + members: Vec, + target: Option, + callback: Option, + cells: Vec<(Ref, Value, Option)>, +} + +fn snap(o: &Object) -> Snap { + let mut s = Snap { + proto: o.proto, + slots: o.slots.clone(), + elements: o.elements.values().collect(), + entries: vec![], + members: vec![], + target: None, + callback: None, + cells: vec![], + }; + match &o.kind { + Kind::Ordinary => {} + Kind::WeakMap(e) => s.entries.clone_from(e), + Kind::WeakSet(m) => s.members.clone_from(m), + Kind::WeakRef(t) => s.target = *t, + Kind::Registry(r) => { + s.callback = Some(r.callback); + s.cells = r + .cells + .iter() + .map(|c| (c.target, c.held, c.token)) + .collect(); + } + } + s +} + +fn snapshot(h: &Heap) -> Vec<(Ref, Snap)> { + h.arena().iter().map(|(r, o)| (r, snap(o))).collect() +} + +fn random_object(rng: &mut Lcg) -> Object { + Object::of(match rng.below(10) { + 0 | 1 => Kind::WeakMap(vec![]), + 2 => Kind::WeakSet(vec![]), + 3 => Kind::WeakRef(None), + 4 => Kind::Registry(Registry { + callback: int(0), + cells: vec![], + }), + _ => Kind::Ordinary, + }) +} + +/// Add random edges, all to live objects, from the live objects. +fn wire(h: &mut Heap, rng: &mut Lcg, live: &[Ref], density: usize) -> R<()> { + for &r in live { + if !rng.chance(density) { + continue; + } + let proto = if rng.chance(30) { rng.pick(live) } else { None }; + let slots: Vec = (0..rng.below(4)).map(|_| rng.value(live)).collect(); + let elems: Vec = (0..rng.below(3)).map(|_| rng.value(live)).collect(); + let (t, k, v) = (rng.pick(live), rng.pick(live), rng.value(live)); + let (t2, k2) = (rng.pick(live), rng.pick(live)); + let o = h.get_mut(r)?; + if proto.is_some() { + o.proto = proto; + } + o.slots.extend(slots); + for (i, e) in elems.into_iter().enumerate() { + let _ = o.elements.set(u32::try_from(i).unwrap_or(0), e); + } + match &mut o.kind { + Kind::Ordinary => {} + Kind::WeakMap(es) => es.extend(k.map(|k| (k, v))), + Kind::WeakSet(ms) => ms.extend(t), + Kind::WeakRef(target) => *target = t, + Kind::Registry(reg) => { + reg.callback = v; + reg.cells.extend(t.map(|t| cell(t, Value::int32(1), k))); + reg.cells.extend(t2.map(|t| cell(t, v, k2))); + } + } + } + Ok(()) +} + +fn survived(before: &Ref, h: &Heap) -> bool { + h.get(*before).is_ok() +} + +/// The objects reachable from `roots`, by a second, independent walk over +/// the snapshot of the heap's public data: it shares nothing with +/// `Heap::graph` (whose omissions it would otherwise share), so the test +/// does not trust the extraction it checks. +fn oracle(before: &[(Ref, Snap)], roots: &[Ref]) -> HashSet { + let all: HashSet = before.iter().map(|(r, _)| *r).collect(); + let mut seen: HashSet = roots.iter().copied().filter(|r| all.contains(r)).collect(); + loop { + let mut add: Vec = vec![]; + for (r, s) in before { + if !seen.contains(r) { + continue; + } + add.extend(s.proto); + add.extend(s.slots.iter().chain(&s.elements).filter_map(|v| v.as_ref())); + add.extend(s.callback.and_then(|v| v.as_ref())); + add.extend(s.cells.iter().filter_map(|c| c.1.as_ref())); + add.extend( + s.entries + .iter() + .filter(|(k, _)| seen.contains(k)) + .filter_map(|(_, v)| v.as_ref()), + ); + } + let n = seen.len(); + seen.extend(add.into_iter().filter(|r| all.contains(r))); + if seen.len() == n { + return seen; + } + } +} + +/// GC1 to GC6, checked for one collection of `h` against the world before. +/// `held` are the references the caller made roots other than through +/// `roots`: its open handles and the targets it kept for the job. +fn collect_and_check(h: &mut Heap, roots: &[Value], held: &[Ref]) -> R<()> { + let graph = h.graph(); + let root_idx = h.root_indices(roots); + let before = snapshot(h); + let all_roots: Vec = roots + .iter() + .filter_map(|v| v.as_ref()) + .chain(held.iter().copied()) + .collect(); + let want = oracle(&before, &all_roots); + let out = h.collect(roots)?; + for (r, _) in &before { + assert_eq!( + want.contains(r), + h.get(*r).is_ok(), + "the oracle's reachability" + ); + } + + // Which slots survived, by (index, generation) as before. + let mut survives = vec![false; graph.len()]; + for (r, _) in &before { + let slot = usize::try_from(r.index) + .ok() + .and_then(|i| survives.get_mut(i)); + if let (true, Some(s)) = (survived(r, h), slot) { + *s = true; + } + } + // GC1 and GC2, against the specification's reachability. + assert!(contract::safe(&graph, &root_idx, &survives), "GC1"); + assert!(contract::exact(&graph, &root_idx, &survives), "GC2"); + assert_eq!(out.survivors, survives.iter().filter(|&&s| s).count()); + assert_eq!(out.freed.checked_add(out.survivors), Some(before.len())); + assert_eq!(h.live(), out.survivors); + // Every freed slot's old reference is a defined error (arena). + for (r, _) in &before { + if !survived(r, h) { + assert!(stale(h, *r)); + } + } + // GC3: the survivors' graph is closed, and no weak reference dangles. + let after = h.graph(); + assert!(contract::closed(&after, &survives), "GC3"); + let alive = |r: &Ref| h.is_live(*r); + for (r, s) in snapshot(h) { + assert!(s.entries.iter().all(|(k, _)| alive(k)), "GC3 map key"); + assert!(s.members.iter().all(alive), "GC3 set member"); + assert!(s.target.iter().all(alive), "GC3 weakref"); + assert!( + s.cells + .iter() + .all(|(t, _, k)| alive(t) && k.iter().all(alive)) + ); + // GC4: weak references to survivors are unchanged, the rest removed, + // and nothing else about a survivor changed. + let was = before + .iter() + .find(|(b, _)| *b == r) + .map(|(_, s)| s.clone()) + .ok_or(Error::NoScope)?; + let keep = |x: &Ref| survived(x, h); + let want = Snap { + entries: was + .entries + .iter() + .copied() + .filter(|(k, _)| keep(k)) + .collect(), + members: was.members.iter().copied().filter(keep).collect(), + target: was.target.filter(keep), + cells: was + .cells + .iter() + .filter(|(t, _, _)| keep(t)) + .map(|&(t, hv, k)| (t, hv, k.filter(keep))) + .collect(), + ..was + }; + assert_eq!(s, want, "GC4"); + } + // GC6: one cleanup per dead cell of a surviving registry, in order. + let mut cleanups = vec![]; + for (r, s) in &before { + if let (true, Some(callback)) = (survived(r, h), s.callback) { + for (t, held, _) in &s.cells { + if !survived(t, h) { + cleanups.push(Cleanup { + callback, + held: *held, + }); + } + } + } + } + assert_eq!(out.cleanups, cleanups, "GC6"); + // Their callbacks and held values are alive. + for c in &out.cleanups { + for v in [c.callback, c.held] { + assert!(v.as_ref().is_none_or(|r| h.is_live(r))); + } + } + assert!(h.arena().is_well_formed()); + Ok(()) +} + +fn live_refs(h: &Heap) -> Vec { + h.arena().iter().map(|(r, _)| r).collect() +} + +#[test] +fn random_heaps_of_any_size_keep_what_the_roots_reach() -> R<()> { + let mut rng = Lcg(0x005E_ED6C); + let mut cases = 0; + for case in 0..240usize { + // Mostly small heaps, a few large ones. + let n = match case % 20 { + 0 => 1500 + rng.below(1500), + 1..=4 => 50 + rng.below(250), + _ => rng.below(30), + }; + let mut h = Heap::new(); + let mut live = Vec::new(); + for _ in 0..n { + live.push(h.alloc(random_object(&mut rng))?); + } + let density = 20 + rng.below(80); + wire(&mut h, &mut rng, &live, density)?; + // Several rounds: collect with random roots, then mutate the + // survivors, reuse freed slots, and collect again. + for _ in 0..4 { + let live = live_refs(&h); + let mut roots: Vec = (0..rng.below(1 + live.len() / 4)) + .map(|_| rng.value(&live)) + .collect(); + // Some roots are handles; some targets are kept for the job. + if rng.chance(50) { + let scope = h.open_scope(); + let mut held: Vec = vec![]; + for v in roots.drain(..roots.len() / 2) { + h.root(v)?; + held.extend(v.as_ref()); + } + for &r in &live { + if rng.chance(3) { + held.extend(h.deref_weak(r).ok().flatten()); + } + } + collect_and_check(&mut h, &roots, &held)?; + h.close_scope(scope)?; + } else { + collect_and_check(&mut h, &roots, &[])?; + } + h.end_job(); + cases += 1; + let survivors = live_refs(&h); + for _ in 0..rng.below(20) { + h.alloc(random_object(&mut rng))?; + } + let all = live_refs(&h); + let some: Vec = survivors + .iter() + .copied() + .filter(|_| rng.chance(50)) + .collect(); + let fresh: Vec = all + .iter() + .copied() + .filter(|r| !survivors.contains(r)) + .collect(); + wire(&mut h, &mut rng, &some, 60)?; + wire(&mut h, &mut rng, &fresh, 100)?; + } + } + assert_eq!(cases, 960); + Ok(()) +} + +/// The marker agrees with the specification on random graphs, including +/// ones with wild edges (no such node) that a heap's graph never has. +#[test] +fn mark_equals_the_specification_on_random_graphs() { + let mut rng = Lcg(0xA11CE); + for _ in 0..2000 { + let n = rng.below(12); + let name = |rng: &mut Lcg| rng.below(n + 2); + let graph: Vec = (0..n) + .map(|_| Node { + strong: (0..rng.below(3)).map(|_| name(&mut rng)).collect(), + ephemerons: (0..rng.below(3)) + .map(|_| (name(&mut rng), name(&mut rng))) + .collect(), + }) + .collect(); + let roots: Vec = (0..rng.below(4)).map(|_| name(&mut rng)).collect(); + assert_eq!(mark(&graph, &roots), contract::reachable(&graph, &roots)); + } +} diff --git a/crates/clazel-js-heap/src/lib.rs b/crates/clazel-js-heap/src/lib.rs index b762a57c..c76b6677 100644 --- a/crates/clazel-js-heap/src/lib.rs +++ b/crates/clazel-js-heap/src/lib.rs @@ -16,8 +16,9 @@ //! - [`symbol`]: symbols (well-known ones at fixed ids) and the property key //! that is a string or a symbol; [`symbol::contract`] is the spec. //! -//! The collector (item 7.6) is not here. The arena leaves room for it: it -//! can enumerate live slots, and freeing is one call. +//! - [`gc`]: the collector (item 7.6): stop-the-world mark and sweep over +//! the arena, with ephemerons, `WeakRef` and `FinalizationRegistry`; +//! [`gc::contract`] is the spec. //! //! Tier: see `[package.metadata.clazel]` in `Cargo.toml` and //! `docs/VERIFICATION.md`. From 5044970b39f79ce1b17c94d618092712d291eb9e Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 15:10:05 +0000 Subject: [PATCH 019/195] js-syntax: a proven early-error check over the arena, wired into parse_checked_early arena_early carries an EEnv per node through a checked mirror of child_env and checks early_local at each node, bottom-up; Verified implies spec::early_errors_ok. DTok gains legacy, invalid_escape and name (added to dtok_matches and canon_tok). Covered: every kind with no rule, numeric and string literals, identifiers, template elements, super/new.target/import.meta, yield and await, member, optional chain, relational, unary, update and assignment with a simple target or pattern, if/while/do-while/with, for without a lexical declaration, unlabelled break/continue, statement lists of blocks and scripts that declare nothing lexically. Unsupported: functions, classes, labels, lexical declarations, for-in/of, switch, try, regexps, private names, modules. Verus: 409 verified, 0 errors. Mutate: 6 of 6 killed. 507 of 1567 script positive runs are early-verified. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_d.rs | 27 +- crates/clazel-js-syntax/src/arena_early.rs | 1416 +++++++++++++++++++ crates/clazel-js-syntax/src/exec.rs | 19 +- crates/clazel-js-syntax/src/lib.rs | 6 + crates/clazel-js-syntax/src/token.rs | 3 + crates/clazel-js-syntax/tests/derivation.rs | 57 + crates/clazel-js-syntax/tests/test262.rs | 15 +- 7 files changed, 1530 insertions(+), 13 deletions(-) create mode 100644 crates/clazel-js-syntax/src/arena_early.rs diff --git a/crates/clazel-js-syntax/src/arena_d.rs b/crates/clazel-js-syntax/src/arena_d.rs index 23824c6b..78370b6a 100644 --- a/crates/clazel-js-syntax/src/arena_d.rs +++ b/crates/clazel-js-syntax/src/arena_d.rs @@ -55,13 +55,21 @@ pub struct DTok { pub nl: bool, /// Written with a `UnicodeEscapeSequence`. pub escaped: bool, + /// A numeric literal that is legacy octal or non-octal decimal, or a string literal with a + /// legacy escape sequence (what `early_local` reads for strict mode code). + pub legacy: bool, + /// A template component with an undefined TV. + pub invalid_escape: bool, + /// The StringValue of an identifier name, escapes resolved. + pub name: Vec, } /// The executable token `e` is the specification's token `t` of the source `src`. pub open spec fn dtok_matches(src: Seq, e: DTok, t: Tok) -> bool { e.kind == t.kind && e.start as int == t.start && e.end as int == t.end && e.start <= e.end && e.end <= src.len() && t.text =~= src.subrange(e.start as int, e.end as int) - && e.escaped == t.escaped && e.nl == t.nl_before + && e.escaped == t.escaped && e.nl == t.nl_before && e.legacy == t.legacy + && e.invalid_escape == t.invalid_escape && e.name@ =~= t.name } /// The executable tokens and gaps are the specification's stream `ts`. @@ -1203,7 +1211,7 @@ pub open spec fn reserved_chars(w: int) -> Seq { } /// The table of reserved words has the 38 words of the specification, in its order. -proof fn lemma_reserved_chars(w: int) +pub(crate) proof fn lemma_reserved_chars(w: int) requires 0 <= w < 38, ensures @@ -1291,7 +1299,7 @@ proof fn lemma_reserved_chars(w: int) } /// The `w`th reserved word, as code points. -fn reserved_slice(w: usize) -> (r: &'static [u32]) +pub(crate) fn reserved_slice(w: usize) -> (r: &'static [u32]) requires w < 38, ensures @@ -6956,20 +6964,20 @@ pub(crate) fn kids_cx_g(nodes: &[Node], cxs: &[Cx5], m: usize, c: &Cx5, ck: &Cx5 } /// The specification's token for an executable one: the fields the check reads, and -/// the lexer's other fields (`name`, `legacy`, ...) left as the empty or false -/// default; the productions the check covers read none of them. +/// `bigint` and `regexp_valid` left false (the executable lexer does not compute +/// `regexp_valid`; no check reads them). pub open spec fn canon_tok(src: Seq, e: DTok) -> Tok { Tok { kind: e.kind, start: e.start as int, end: e.end as int, text: src.subrange(e.start as int, e.end as int), - name: Seq::empty(), + name: e.name@, escaped: e.escaped, nl_before: e.nl, - legacy: false, + legacy: e.legacy, bigint: false, - invalid_escape: false, + invalid_escape: e.invalid_escape, regexp_valid: false, } } @@ -10069,7 +10077,8 @@ pub struct FuncShape { } /// §15.2 and §15.5, §15.8 and §15.6: a function, generator, `async` function or -/// `async` generator, declaration or expression. +#[verifier::spinoff_prover] +#[verifier::rlimit(300)] #[verifier::spinoff_prover] fn check_function( src: &[u32], diff --git a/crates/clazel-js-syntax/src/arena_early.rs b/crates/clazel-js-syntax/src/arena_early.rs new file mode 100644 index 00000000..64d4239c --- /dev/null +++ b/crates/clazel-js-syntax/src/arena_early.rs @@ -0,0 +1,1416 @@ +//! A proven check of the early errors over a whole arena (item 7.3): [`check_early`] +//! carries an [`EEnv`] per node (the executable form of `spec::EarlyEnv`), checks that +//! each node's is the one `spec::child_env` gives it from its parent's, and that +//! `spec::early_local` holds at each node, bottom-up. It returns `Verified` only if +//! `spec::early_errors_ok` holds. +//! +//! **Covered.** The environment: every node kind whose `child_env` arm is the default +//! (`[~Tagged]`) or one of the loop, `switch`, object literal, tagged template and +//! template arms; the `labels` and `privates` of the environment are empty, so a labelled +//! statement, a class, a function or an arrow function (whose `child_env` arms need +//! `has_use_strict`, `env_fn` and class bodies) makes the result `Unsupported`. +//! The rules of `early_local`: every kind with no rule (the `_ => true` arm); +//! `NumericLiteral` and `StringLiteral` (strict mode legacy forms); the three identifier +//! kinds (§13.1.1: strict reserved words, `eval`, `arguments`, `yield`, `await`, the +//! reserved words, `arguments` in field initializers); `TemplateElement`; +//! `SuperProperty`, `SuperCall`, `NewTarget`, `ImportMeta`; `YieldExpression` and +//! `AwaitExpression`; `MemberExpression` (not `.#x`), `OptionalChain` (not `?.#x` or a +//! template), `RelationalExpression` (not `#x in`), `UnaryExpression` (not `delete`); +//! `UpdateExpression` and `AssignmentExpression` with a `~simple~` target (members, +//! `super` properties, identifiers other than strict `eval` and `arguments`, through +//! parentheses) or an assignment pattern; `if`, `while`, `do`-`while`, `with` (no labelled +//! function as the body; no `with`, no function body of an `if` in strict mode); `for ( ; ; )` +//! without a lexical declaration; unlabelled `break` and `continue`; the statement lists +//! of a block and a script whose items declare nothing lexically (so +//! `LexicallyDeclaredNames` is empty). +//! +//! **Not covered** (the result is `Unsupported`): everything else, notably function +//! and class code, labels, lexical declarations, `for`-`in`/`of`, `switch`, `try` +//! (`catch` parameters), regular expression literals (`regexp_valid` is item 7.10's), +//! private names, a Use Strict Directive in a script, and `Module` roots. +//! +//! **Assumptions**, those of [`crate::arena_d`]: the executable tokens are the +//! specification's (`dtok_matches`, which now also covers `legacy`, `invalid_escape` +//! and `name`, the lexer's contract of item 7.2). + +use crate::arena_d::*; +use crate::ast::*; +use crate::spec::*; +use vstd::prelude::*; + +verus! { + +/// The executable tokens are the specification's stream `ts`. +pub open spec fn toks_match(src: Seq, toks: Seq, ts: Stream) -> bool { + toks.len() == ts.toks.len() && (forall|k: int| + 0 <= k < toks.len() ==> dtok_matches(src, toks[k], #[trigger] ts.toks[k])) +} + +/// The tokens start at increasing positions, so a start names one token. +pub open spec fn starts_inc(ts: Stream) -> bool { + forall|x: int, y: int| + 0 <= x < y < tn(ts) ==> (#[trigger] ts.toks[x]).start < (#[trigger] ts.toks[y]).start +} + +/// The first token of node `n` is `ts.toks[x]`. +proof fn lemma_node_tok_at(a: AstV, ts: Stream, n: int, x: int) + requires + starts_inc(ts), + 0 <= n < a.nodes.len(), + 0 <= x < tn(ts), + ts.toks[x].start == a.nodes[n].start, + ensures + node_tok(a, ts, n) == ts.toks[x], +{ + assert(exists|y: int| 0 <= y < tn(ts) && ts.toks[y].start == a.nodes[n].start); + let y = choose|y: int| 0 <= y < tn(ts) && ts.toks[y].start == a.nodes[n].start; + if y < x { + assert(ts.toks[y].start < ts.toks[x].start); + } + if y > x { + assert(ts.toks[x].start < ts.toks[y].start); + } +} + +/// The words of the identifier rules, as code points. +proof fn lemma_words_early() + ensures + sv("yield"@) =~= seq![0x79u32, 0x69, 0x65, 0x6C, 0x64], + sv("await"@) =~= seq![0x61u32, 0x77, 0x61, 0x69, 0x74], + sv("arguments"@) =~= seq![0x61u32, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73], + sv("eval"@) =~= seq![0x65u32, 0x76, 0x61, 0x6C], + sv("implements"@) =~= seq![0x69u32, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x73], + sv("interface"@) =~= seq![0x69u32, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65], + sv("let"@) =~= seq![0x6Cu32, 0x65, 0x74], + sv("package"@) =~= seq![0x70u32, 0x61, 0x63, 0x6B, 0x61, 0x67, 0x65], + sv("private"@) =~= seq![0x70u32, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65], + sv("protected"@) =~= seq![0x70u32, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74, 0x65, 0x64], + sv("public"@) =~= seq![0x70u32, 0x75, 0x62, 0x6C, 0x69, 0x63], + sv("static"@) =~= seq![0x73u32, 0x74, 0x61, 0x74, 0x69, 0x63], +{ + reveal_strlit("yield"); + reveal_strlit("await"); + reveal_strlit("arguments"); + reveal_strlit("eval"); + reveal_strlit("implements"); + reveal_strlit("interface"); + reveal_strlit("let"); + reveal_strlit("package"); + reveal_strlit("private"); + reveal_strlit("protected"); + reveal_strlit("public"); + reveal_strlit("static"); + assert("yield"@ =~= seq!['y', 'i', 'e', 'l', 'd']); + assert("await"@ =~= seq!['a', 'w', 'a', 'i', 't']); + assert("arguments"@ =~= seq!['a', 'r', 'g', 'u', 'm', 'e', 'n', 't', 's']); + assert("eval"@ =~= seq!['e', 'v', 'a', 'l']); + assert("implements"@ =~= seq!['i', 'm', 'p', 'l', 'e', 'm', 'e', 'n', 't', 's']); + assert("interface"@ =~= seq!['i', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e']); + assert("let"@ =~= seq!['l', 'e', 't']); + assert("package"@ =~= seq!['p', 'a', 'c', 'k', 'a', 'g', 'e']); + assert("private"@ =~= seq!['p', 'r', 'i', 'v', 'a', 't', 'e']); + assert("protected"@ =~= seq!['p', 'r', 'o', 't', 'e', 'c', 't', 'e', 'd']); + assert("public"@ =~= seq!['p', 'u', 'b', 'l', 'i', 'c']); + assert("static"@ =~= seq!['s', 't', 'a', 't', 'i', 'c']); +} + +/// Two slices of code points are the same. +fn seq_eq(a: &[u32], b: &[u32]) -> (r: bool) + ensures + r == (a@ =~= b@), +{ + if a.len() != b.len() { + return false; + } + let mut i: usize = 0; + while i < a.len() + invariant + a.len() == b.len(), + i <= a.len(), + forall|q: int| 0 <= q < i ==> a@[q] == b@[q], + decreases a.len() - i, + { + let (x, y) = match (a.get(i), b.get(i)) { + (Some(x), Some(y)) => (*x, *y), + _ => { + return false; + }, + }; + if x != y { + return false; + } + i = i.saturating_add(1); + } + true +} + +/// The index of the reserved word `name` is, if it is one. +fn reserved_of(name: &[u32]) -> (r: Option) + ensures + match r { + Some(w) => w < 38 && name@ =~= reserved_chars(w as int), + None => forall|w: int| 0 <= w < 38 ==> !(name@ =~= #[trigger] reserved_chars(w)), + }, +{ + let mut w: usize = 0; + while w < 38 + invariant + w <= 38, + forall|q: int| 0 <= q < w ==> !(name@ =~= #[trigger] reserved_chars(q)), + decreases 38 - w, + { + let c = reserved_slice(w); + if seq_eq(name, c) { + return Some(w); + } + w = w.saturating_add(1); + } + None +} + +// --------------------------------------------------------------------- +// The environment. +// --------------------------------------------------------------------- + +/// The facts about the position of a node that the checked early errors read: the +/// executable form of `spec::EarlyEnv` with no labels and no private names. +#[derive(Clone, Copy)] +pub struct EEnv { + /// `IsStrict`. + pub strict: bool, + /// The goal symbol is `Module`. + pub module: bool, + /// `[Yield]`. + pub yield_: bool, + /// `[Await]`. + pub await_: bool, + /// In an iteration statement. + pub in_loop: bool, + /// In an iteration statement or a `switch`. + pub in_breakable: bool, + /// `SuperProperty` is allowed. + pub super_prop: bool, + /// `SuperCall` is allowed. + pub super_call: bool, + /// `new.target` is allowed. + pub new_target: bool, + /// `arguments` is not allowed. + pub no_arguments: bool, + /// `yield` and `await` expressions are not allowed. + pub no_yield_await: bool, + /// `[Tagged]`. + pub tagged: bool, + /// The nearest class has a heritage. + pub derived: bool, +} + +/// The specification's environment of an executable one. +pub open spec fn eenv_of(e: EEnv) -> EarlyEnv { + EarlyEnv { + strict: e.strict, + module: e.module, + yield_: e.yield_, + await_: e.await_, + labels: Seq::empty(), + in_loop: e.in_loop, + in_breakable: e.in_breakable, + super_prop: e.super_prop, + super_call: e.super_call, + new_target: e.new_target, + no_arguments: e.no_arguments, + no_yield_await: e.no_yield_await, + tagged: e.tagged, + privates: Seq::empty(), + derived: e.derived, + } +} + +/// Two environments are the same. +fn eenv_eq(p: &EEnv, q: &EEnv) -> (r: bool) + ensures + r == (eenv_of(*p) == eenv_of(*q)), +{ + p.strict == q.strict && p.module == q.module && p.yield_ == q.yield_ && p.await_ == q.await_ + && p.in_loop == q.in_loop && p.in_breakable == q.in_breakable && p.super_prop + == q.super_prop && p.super_call == q.super_call && p.new_target == q.new_target + && p.no_arguments == q.no_arguments && p.no_yield_await == q.no_yield_await && p.tagged + == q.tagged && p.derived == q.derived +} + +/// `spec::child_env` for the node kinds whose arm is simple: child `k` of node `n`. +#[verifier::rlimit(400)] +fn child_env_exec(nodes: &[Node], n: usize, k: usize, e: &EEnv, Ghost(ts): Ghost) -> (r: Option) + requires + n < nodes.len(), + ast_wf(arena_of(nodes@)), + k < nodes@[n as int].children.len(), + ensures + match r { + Some(c) => eenv_of(c) == child_env(arena_of(nodes@), ts, n as int, k as int, eenv_of(*e)), + None => true, + }, +{ + let nd = match nodes.get(n) { + Some(x) => x, + None => { + return None; + }, + }; + let ch = match nd.children.as_slice().get(k) { + Some(c) => *c as usize, + None => { + return None; + }, + }; + proof { + let a = arena_of(nodes@); + assert(a.nodes[n as int] == nodes@[n as int]@); + assert(nd == &nodes@[n as int]); + assert(a.nodes[n as int].children[k as int] == ch as int); + assert(a.nodes[n as int].kind == nd.kind); + } + let plain = EEnv { tagged: false, ..*e }; + match nd.kind { + NodeKind::FunctionDeclaration | NodeKind::FunctionExpression | NodeKind::GeneratorDeclaration + | NodeKind::GeneratorExpression | NodeKind::AsyncFunctionDeclaration + | NodeKind::AsyncFunctionExpression | NodeKind::AsyncGeneratorDeclaration + | NodeKind::AsyncGeneratorExpression | NodeKind::ArrowFunction | NodeKind::AsyncArrowFunction + | NodeKind::MethodDefinition | NodeKind::FieldDefinition | NodeKind::ClassStaticBlock + | NodeKind::ClassDeclaration | NodeKind::ClassExpression | NodeKind::ClassBody + | NodeKind::LabelledStatement => None, + NodeKind::ObjectLiteral => Some(EEnv { derived: false, ..*e }), + NodeKind::DoWhileStatement => if k == 0 { + Some(EEnv { in_loop: true, in_breakable: true, ..*e }) + } else { + Some(*e) + }, + NodeKind::WhileStatement => if k == 1 { + Some(EEnv { in_loop: true, in_breakable: true, ..*e }) + } else { + Some(*e) + }, + NodeKind::ForStatement => if k == 3 { + Some(EEnv { in_loop: true, in_breakable: true, ..*e }) + } else { + Some(*e) + }, + NodeKind::ForInStatement | NodeKind::ForOfStatement => if k == 2 { + Some(EEnv { in_loop: true, in_breakable: true, ..*e }) + } else { + Some(*e) + }, + NodeKind::SwitchStatement => if k >= 1 { + Some(EEnv { in_breakable: true, ..*e }) + } else { + Some(*e) + }, + NodeKind::TaggedTemplate => Some(EEnv { tagged: k == 1, ..*e }), + NodeKind::TemplateLiteral => { + let ck = match nodes.get(ch) { + Some(x) => x.kind, + None => { + return None; + }, + }; + proof { + let a = arena_of(nodes@); + assert(a.nodes[ch as int] == nodes@[ch as int]@); + } + if matches!(ck, NodeKind::TemplateElement) { + Some(*e) + } else { + Some(plain) + } + }, + _ => Some(plain), + } +} + +// --------------------------------------------------------------------- +// Rules. +// --------------------------------------------------------------------- + +/// §13.1.1 the identifier rules in terms of the name, the kind of node and the environment. +pub open spec fn ident_name_ok(nm: Seq, kind: NodeKind, env: EarlyEnv) -> bool { + let is_yield = nm =~= sv("yield"@); + let is_await = nm =~= sv("await"@); + !(kind == NodeKind::BindingIdentifier && env.strict && (nm =~= sv("arguments"@) || nm + =~= sv("eval"@))) && !(env.strict && is_strict_reserved(nm)) && !(env.module && is_await) + && !(env.yield_ && is_yield) && !(env.await_ && is_await) && !(is_reserved_text(nm) + && !is_yield && !is_await) && !(kind == NodeKind::IdentifierReference && env.no_arguments + && nm =~= sv("arguments"@)) +} + +/// `early_identifier_ok` is `ident_name_ok` of the node's name. +proof fn lemma_ident_rule(a: AstV, ts: Stream, c: int, env: EarlyEnv) + ensures + early_identifier_ok(a, ts, c, env) == ident_name_ok(name_of(a, ts, c), kd(a, c), env), +{ +} + +/// §13.1.1 for an identifier of `name`. +fn ident_early(name: &[u32], binding: bool, reference: bool, e: &EEnv) -> (r: bool) + ensures + r ==> ident_name_ok( + name@, + if binding { + NodeKind::BindingIdentifier + } else if reference { + NodeKind::IdentifierReference + } else { + NodeKind::LabelIdentifier + }, + eenv_of(*e), + ), +{ + proof { + lemma_words_early(); + } + let is_yield = seq_eq(name, &[0x79, 0x69, 0x65, 0x6C, 0x64]); + let is_await = seq_eq(name, &[0x61, 0x77, 0x61, 0x69, 0x74]); + let is_args = seq_eq(name, &[0x61, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73]); + let is_eval = seq_eq(name, &[0x65, 0x76, 0x61, 0x6C]); + let strict_reserved = is_yield || seq_eq(name, &[0x69, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x73]) + || seq_eq(name, &[0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65]) + || seq_eq(name, &[0x6C, 0x65, 0x74]) || seq_eq(name, &[0x70, 0x61, 0x63, 0x6B, 0x61, 0x67, 0x65]) + || seq_eq(name, &[0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65]) + || seq_eq(name, &[0x70, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74, 0x65, 0x64]) + || seq_eq(name, &[0x70, 0x75, 0x62, 0x6C, 0x69, 0x63]) + || seq_eq(name, &[0x73, 0x74, 0x61, 0x74, 0x69, 0x63]); + let reserved = reserved_of(name); + let is_reserved = reserved.is_some(); + proof { + if let Some(w) = reserved { + lemma_reserved_chars(w as int); + assert(is_reserved_text(name@)) by { + assert(0 <= w < reserved_words().len() && name@ =~= cps(reserved_words()[w as int])); + } + } else { + assert(!is_reserved_text(name@)) by { + assert forall|w: int| 0 <= w < reserved_words().len() implies !(name@ =~= cps( + #[trigger] reserved_words()[w], + )) by { + lemma_reserved_chars(w); + } + } + } + } + !(binding && e.strict && (is_args || is_eval)) && !(e.strict && strict_reserved) + && !(e.module && is_await) && !(e.yield_ && is_yield) && !(e.await_ && is_await) + && !(is_reserved && !is_yield && !is_await) && !(reference && e.no_arguments && is_args) +} + +/// The statement `c` is not a labelled function (`is_labelled_function`): it is not a label. +fn not_labelled(nodes: &[Node], c: usize) -> (r: bool) + requires + c < nodes.len(), + ensures + r ==> !is_labelled_function(arena_of(nodes@), c as int), +{ + match nodes.get(c) { + Some(x) => { + proof { + let a = arena_of(nodes@); + assert(a.nodes[c as int] == nodes@[c as int]@); + } + !matches!(x.kind, NodeKind::LabelledStatement) + }, + None => false, + } +} + +/// The token a node starts at, found from its start. +fn node_token(nodes: &[Node], toks: &[DTok], by_start: &[usize], m: usize) -> (r: Option) + requires + m < nodes.len(), + ensures + match r { + Some(x) => x < toks.len() && toks@[x as int].start as int == nodes@[m as int].start as int, + None => true, + }, +{ + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let x = match by_start.get(nd.start) { + Some(x) => *x, + None => { + return None; + }, + }; + match toks.get(x) { + Some(t) => if t.start == nd.start { + Some(x) + } else { + None + }, + None => None, + } +} + +/// §8.6.4 the node `c` is a `~simple~` assignment target (through parentheses). +fn target_simple( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + by_start: &[usize], + c0: usize, + strict: bool, + Ghost(ts): Ghost, +) -> (r: bool) + requires + c0 < nodes.len(), + ast_wf(arena_of(nodes@)), + toks_match(src@, toks@, ts), + starts_inc(ts), + ensures + r ==> target_type(arena_of(nodes@), ts, c0 as int, strict) == TargetType::Simple, +{ + let _ = src.len(); + let ghost a = arena_of(nodes@); + let mut c = c0; + loop + invariant + c < nodes.len(), + a == arena_of(nodes@), + ast_wf(a), + toks_match(src@, toks@, ts), + starts_inc(ts), + target_type(a, ts, c0 as int, strict) == target_type(a, ts, c as int, strict), + decreases c, + { + let nd = match nodes.get(c) { + Some(x) => x, + None => { + return false; + }, + }; + proof { + assert(a.nodes[c as int] == nodes@[c as int]@); + assert(nd == &nodes@[c as int]); + assert(a.nodes[c as int].kind == nd.kind); + } + match nd.kind { + NodeKind::MemberExpression | NodeKind::SuperProperty => { + return true; + }, + NodeKind::IdentifierReference => { + let x = match node_token(nodes, toks, by_start, c) { + Some(x) => x, + None => { + return false; + }, + }; + let t = match toks.get(x) { + Some(t) => t, + None => { + return false; + }, + }; + let bad = strict && (seq_eq(t.name.as_slice(), &[0x65, 0x76, 0x61, 0x6C]) + || seq_eq(t.name.as_slice(), &[0x61, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73])); + proof { + lemma_words_early(); + assert(t == &toks@[x as int]); + assert(dtok_matches(src@, toks@[x as int], ts.toks[x as int])); + lemma_node_tok_at(a, ts, c as int, x as int); + assert(name_of(a, ts, c as int) =~= t.name@); + assert(a.nodes.len() == nodes@.len()); + if !bad { + assert(a.nodes[c as int].kind == NodeKind::IdentifierReference); + assert(!(strict && (name_of(a, ts, c as int) =~= sv("eval"@) || name_of( + a, + ts, + c as int, + ) =~= sv("arguments"@)))); + assert(target_type(a, ts, c as int, strict) == TargetType::Simple); + } + } + return !bad; + }, + NodeKind::ParenthesizedExpression => { + let k0 = match nd.children.as_slice().get(ZERO) { + Some(k) => *k as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[c as int].children[0] == k0 as int); + } + if k0 >= c { + return false; + } + c = k0; + }, + _ => { + return false; + }, + } + } +} + +/// The kinds `early_local` has an arm for (other kinds have none: it is `true`). +fn has_arm(k: NodeKind) -> (r: bool) + ensures + !r ==> (k != NodeKind::IdentifierReference && k != NodeKind::BindingIdentifier && k + != NodeKind::LabelIdentifier && k != NodeKind::NumericLiteral && k + != NodeKind::StringLiteral && k != NodeKind::RegularExpressionLiteral && k + != NodeKind::TemplateElement && k != NodeKind::ObjectLiteral && k + != NodeKind::CoverInitializedName && k != NodeKind::SuperProperty && k + != NodeKind::SuperCall && k != NodeKind::NewTarget && k != NodeKind::ImportMeta && k + != NodeKind::MemberExpression && k != NodeKind::OptionalChain && k + != NodeKind::RelationalExpression && k != NodeKind::UnaryExpression && k + != NodeKind::UpdateExpression && k != NodeKind::AssignmentExpression && k + != NodeKind::AssignmentProperty && k != NodeKind::AssignmentElement && k + != NodeKind::AssignmentRestElement && k != NodeKind::AssignmentRestProperty && k + != NodeKind::YieldExpression && k != NodeKind::AwaitExpression && k + != NodeKind::BlockStatement && k != NodeKind::LexicalDeclaration && k + != NodeKind::IfStatement && k != NodeKind::DoWhileStatement && k + != NodeKind::WhileStatement && k != NodeKind::ForStatement && k + != NodeKind::ForInStatement && k != NodeKind::ForOfStatement && k + != NodeKind::ContinueStatement && k != NodeKind::BreakStatement && k + != NodeKind::WithStatement && k != NodeKind::SwitchStatement && k + != NodeKind::LabelledStatement && k != NodeKind::Catch && k != NodeKind::FunctionBody + && k != NodeKind::FunctionDeclaration && k != NodeKind::FunctionExpression && k + != NodeKind::GeneratorDeclaration && k != NodeKind::GeneratorExpression && k + != NodeKind::AsyncFunctionDeclaration && k != NodeKind::AsyncFunctionExpression && k + != NodeKind::AsyncGeneratorDeclaration && k != NodeKind::AsyncGeneratorExpression && k + != NodeKind::ArrowFunction && k != NodeKind::AsyncArrowFunction && k + != NodeKind::MethodDefinition && k != NodeKind::ClassBody && k != NodeKind::Script + && k != NodeKind::Module && k != NodeKind::WithClause && k != NodeKind::ExportDeclaration + && k != NodeKind::ExportSpecifier && k != NodeKind::ImportSpecifier), +{ + matches!( + k, + NodeKind::IdentifierReference | NodeKind::BindingIdentifier | NodeKind::LabelIdentifier + | NodeKind::NumericLiteral | NodeKind::StringLiteral | NodeKind::RegularExpressionLiteral + | NodeKind::TemplateElement | NodeKind::ObjectLiteral | NodeKind::CoverInitializedName + | NodeKind::SuperProperty | NodeKind::SuperCall | NodeKind::NewTarget | NodeKind::ImportMeta + | NodeKind::MemberExpression | NodeKind::OptionalChain | NodeKind::RelationalExpression + | NodeKind::UnaryExpression | NodeKind::UpdateExpression | NodeKind::AssignmentExpression + | NodeKind::AssignmentProperty | NodeKind::AssignmentElement | NodeKind::AssignmentRestElement + | NodeKind::AssignmentRestProperty | NodeKind::YieldExpression | NodeKind::AwaitExpression + | NodeKind::BlockStatement | NodeKind::LexicalDeclaration | NodeKind::IfStatement + | NodeKind::DoWhileStatement | NodeKind::WhileStatement | NodeKind::ForStatement + | NodeKind::ForInStatement | NodeKind::ForOfStatement | NodeKind::ContinueStatement + | NodeKind::BreakStatement | NodeKind::WithStatement | NodeKind::SwitchStatement + | NodeKind::LabelledStatement | NodeKind::Catch | NodeKind::FunctionBody + | NodeKind::FunctionDeclaration | NodeKind::FunctionExpression | NodeKind::GeneratorDeclaration + | NodeKind::GeneratorExpression | NodeKind::AsyncFunctionDeclaration + | NodeKind::AsyncFunctionExpression | NodeKind::AsyncGeneratorDeclaration + | NodeKind::AsyncGeneratorExpression | NodeKind::ArrowFunction | NodeKind::AsyncArrowFunction + | NodeKind::MethodDefinition | NodeKind::ClassBody | NodeKind::Script | NodeKind::Module + | NodeKind::WithClause | NodeKind::ExportDeclaration | NodeKind::ExportSpecifier + | NodeKind::ImportSpecifier + ) +} + +/// An item whose `LexicallyDeclaredNames` is empty, in a list that is `top` (a script's) or not. +pub open spec fn lex_empty_kind(k: NodeKind, top: bool) -> bool { + !(k == NodeKind::LexicalDeclaration || k == NodeKind::ClassDeclaration || k + == NodeKind::ImportDeclaration || k == NodeKind::ExportDeclaration || (!top && (k + == NodeKind::FunctionDeclaration || k == NodeKind::GeneratorDeclaration || k + == NodeKind::AsyncFunctionDeclaration || k == NodeKind::AsyncGeneratorDeclaration || k + == NodeKind::LabelledStatement))) +} + +/// The lexically declared names of a list of such items are none. +proof fn lemma_lex_list_empty(a: AstV, ts: Stream, n: int, ks: Seq, k: int, top: bool) + requires + forall|j: int| 0 <= j < ks.len() ==> lex_empty_kind(kd(a, #[trigger] ks[j]), top), + ensures + lex_names_list(a, ts, n, ks, k, top) =~= Seq::empty(), + decreases ks.len() - k, +{ + if 0 <= k < ks.len() { + lemma_lex_list_empty(a, ts, n, ks, k + 1, top); + if 0 <= ks[k] < n { + assert(lex_empty_kind(kd(a, ks[k]), top)); + assert(lex_names_item(a, ts, ks[k], top) =~= Seq::empty()); + } + } +} + +/// `list_early` of a list whose items declare nothing lexically. +proof fn lemma_list_early_empty(a: AstV, ts: Stream, n: int, ks: Seq, strict: bool, top: bool) + requires + forall|j: int| 0 <= j < ks.len() ==> lex_empty_kind(kd(a, #[trigger] ks[j]), top), + ensures + list_early(a, ts, n, ks, strict, top), +{ + lemma_lex_list_empty(a, ts, n, ks, 0, top); + let lex = lex_names_list(a, ts, n, ks, 0, top); + assert(lex =~= Seq::empty()); + assert(!has_forbidden_duplicate(lex, strict)); + assert(plain_names(lex) =~= Seq::empty()); + assert(!intersects(plain_names(lex), if top { + top_var_names_list(a, ts, n, ks, 0) + } else { + var_names_list(a, ts, n, ks, 0) + })); +} + +/// The items of node `m` declare nothing lexically. +fn items_lex_empty(nodes: &[Node], m: usize, top: bool) -> (r: bool) + requires + m < nodes.len(), + ast_wf(arena_of(nodes@)), + ensures + r ==> forall|j: int| + 0 <= j < arena_of(nodes@).nodes[m as int].children.len() ==> lex_empty_kind( + kd(arena_of(nodes@), #[trigger] arena_of(nodes@).nodes[m as int].children[j]), + top, + ), +{ + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return false; + }, + }; + let len = nd.children.len(); + let ghost a = arena_of(nodes@); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + } + let mut k: usize = 0; + while k < len + invariant + m < nodes.len(), + nodes@.len() == nodes.len(), + a == arena_of(nodes@), + ast_wf(a), + nd == &nodes@[m as int], + len == nd.children.len(), + len == a.nodes[m as int].children.len(), + k <= len, + forall|j: int| + 0 <= j < k ==> lex_empty_kind(kd(a, #[trigger] a.nodes[m as int].children[j]), top), + decreases len - k, + { + let c = match nd.children.as_slice().get(k) { + Some(x) => *x as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[k as int] == c as int); + lemma_child_before(a, m as int, k as int); + } + let ck = match nodes.get(c) { + Some(x) => x.kind, + None => { + return false; + }, + }; + proof { + assert(a.nodes[c as int] == nodes@[c as int]@); + } + let ok = !(matches!( + ck, + NodeKind::LexicalDeclaration | NodeKind::ClassDeclaration | NodeKind::ImportDeclaration + | NodeKind::ExportDeclaration + ) || (!top && matches!( + ck, + NodeKind::FunctionDeclaration | NodeKind::GeneratorDeclaration + | NodeKind::AsyncFunctionDeclaration | NodeKind::AsyncGeneratorDeclaration + | NodeKind::LabelledStatement + ))); + if !ok { + return false; + } + k = k.saturating_add(1); + } + true +} + +/// The kind of child `i` of node `m`, `Script` where there is none (`spec::kd(a, kid(ks, i))`). +fn kid_kind(nodes: &[Node], m: usize, i: usize) -> (r: Option) + requires + m < nodes.len(), + ast_wf(arena_of(nodes@)), + ensures + match r { + Some(k) => i < arena_of(nodes@).nodes[m as int].children.len() && kd( + arena_of(nodes@), + arena_of(nodes@).nodes[m as int].children[i as int], + ) == k, + None => true, + }, +{ + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let c = match nd.children.as_slice().get(i) { + Some(c) => *c as usize, + None => { + return None; + }, + }; + proof { + let a = arena_of(nodes@); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children[i as int] == c as int); + lemma_child_before(a, m as int, i as int); + } + if c >= m { + return None; + } + match nodes.get(c) { + Some(x) => { + proof { + let a = arena_of(nodes@); + assert(a.nodes[c as int] == nodes@[c as int]@); + } + Some(x.kind) + }, + None => None, + } +} + +/// `early_local` of node `m` in `e`, for the rules this module covers (`false` otherwise). +#[verifier::rlimit(400)] +fn early_local_exec( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + by_start: &[usize], + m: usize, + e: &EEnv, + Ghost(ts): Ghost, +) -> (r: bool) + requires + m < nodes.len(), + ast_wf(arena_of(nodes@)), + toks_match(src@, toks@, ts), + starts_inc(ts), + ensures + r ==> early_local(arena_of(nodes@), ts, m as int, eenv_of(*e)), +{ + let ghost a = arena_of(nodes@); + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].op == nd.op); + assert(a.nodes[m as int].flag == nd.flag); + } + let kind = nd.kind; + if !has_arm(kind) { + return true; + } + match kind { + NodeKind::NumericLiteral | NodeKind::StringLiteral | NodeKind::TemplateElement + | NodeKind::IdentifierReference | NodeKind::BindingIdentifier | NodeKind::LabelIdentifier => { + let x = match node_token(nodes, toks, by_start, m) { + Some(x) => x, + None => { + return false; + }, + }; + let t = match toks.get(x) { + Some(t) => t, + None => { + return false; + }, + }; + proof { + assert(t == &toks@[x as int]); + assert(dtok_matches(src@, toks@[x as int], ts.toks[x as int])); + lemma_node_tok_at(a, ts, m as int, x as int); + } + match kind { + NodeKind::NumericLiteral | NodeKind::StringLiteral => !(e.strict && t.legacy), + NodeKind::TemplateElement => e.tagged || !t.invalid_escape, + _ => { + let ok = ident_early( + t.name.as_slice(), + matches!(kind, NodeKind::BindingIdentifier), + matches!(kind, NodeKind::IdentifierReference), + e, + ); + proof { + lemma_ident_rule(a, ts, m as int, eenv_of(*e)); + assert(name_of(a, ts, m as int) =~= t.name@); + } + ok + }, + } + }, + NodeKind::SuperProperty => e.super_prop, + NodeKind::SuperCall => e.super_call, + NodeKind::NewTarget => e.new_target, + NodeKind::ImportMeta => e.module, + NodeKind::YieldExpression | NodeKind::AwaitExpression => !e.no_yield_await, + NodeKind::MemberExpression => !matches!(nd.op, Op::PrivateDot), + NodeKind::OptionalChain => !matches!(nd.op, Op::ChainTemplate | Op::ChainPrivateDot), + NodeKind::RelationalExpression => match kid_kind(nodes, m, 0) { + Some(k0) => !matches!(k0, NodeKind::PrivateIdentifier), + None => false, + }, + NodeKind::UnaryExpression => !matches!(nd.op, Op::Delete) || !e.strict, + NodeKind::UpdateExpression => { + let c = match nd.children.as_slice().get(ZERO) { + Some(c) => *c as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[0] == c as int); + lemma_child_before(a, m as int, 0); + } + c < m && target_simple(src, nodes, toks, by_start, c, e.strict, Ghost(ts)) + }, + NodeKind::AssignmentExpression => { + let c = match nd.children.as_slice().get(ZERO) { + Some(c) => *c as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[0] == c as int); + lemma_child_before(a, m as int, 0); + } + if c >= m { + return false; + } + let ck = match nodes.get(c) { + Some(x) => x.kind, + None => { + return false; + }, + }; + proof { + assert(a.nodes[c as int] == nodes@[c as int]@); + } + (matches!(nd.op, Op::Assign) + && matches!(ck, NodeKind::ObjectAssignmentPattern | NodeKind::ArrayAssignmentPattern)) + || target_simple(src, nodes, toks, by_start, c, e.strict, Ghost(ts)) + }, + NodeKind::IfStatement => { + let (k1, k2) = match (kid_kind(nodes, m, 1), kid_kind(nodes, m, 2)) { + (Some(x), Some(y)) => (x, y), + _ => { + return false; + }, + }; + let c1 = match nd.children.as_slice().get(1) { + Some(c) => *c as usize, + None => { + return false; + }, + }; + let c2 = match nd.children.as_slice().get(2) { + Some(c) => *c as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[1] == c1 as int); + assert(a.nodes[m as int].children[2] == c2 as int); + lemma_child_before(a, m as int, 1); + lemma_child_before(a, m as int, 2); + } + c1 < m && c2 < m && not_labelled(nodes, c1) && not_labelled(nodes, c2) && !(e.strict + && (matches!(k1, NodeKind::FunctionDeclaration) || matches!(k2, NodeKind::FunctionDeclaration))) + }, + NodeKind::WhileStatement | NodeKind::WithStatement | NodeKind::DoWhileStatement => { + let which: usize = if matches!(kind, NodeKind::DoWhileStatement) { 0 } else { 1 }; + let c = match nd.children.as_slice().get(which) { + Some(c) => *c as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[which as int] == c as int); + lemma_child_before(a, m as int, which as int); + } + c < m && not_labelled(nodes, c) && (!matches!(kind, NodeKind::WithStatement) || !e.strict) + }, + NodeKind::ForStatement => { + let c = match nd.children.as_slice().get(3) { + Some(c) => *c as usize, + None => { + return false; + }, + }; + let k0 = match kid_kind(nodes, m, 0) { + Some(k) => k, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[3] == c as int); + lemma_child_before(a, m as int, 3); + } + c < m && not_labelled(nodes, c) && !matches!(k0, NodeKind::LexicalDeclaration) + }, + NodeKind::ContinueStatement | NodeKind::BreakStatement => { + let k0 = match kid_kind(nodes, m, 0) { + Some(k) => k, + None => { + return false; + }, + }; + if matches!(k0, NodeKind::LabelIdentifier) { + return false; + } + if matches!(kind, NodeKind::ContinueStatement) { + e.in_loop + } else { + e.in_breakable + } + }, + NodeKind::BlockStatement => { + let ok = items_lex_empty(nodes, m, false); + proof { + if ok { + lemma_list_early_empty(a, ts, m as int, a.nodes[m as int].children, e.strict, false); + } + } + ok + }, + NodeKind::Script => { + let ok = items_lex_empty(nodes, m, true); + proof { + if ok { + lemma_list_early_empty(a, ts, m as int, a.nodes[m as int].children, e.strict, true); + } + } + ok + }, + _ => false, + } +} + + +/// The first statement of the root is not a directive: no Use Strict Directive. +proof fn lemma_no_directive(a: AstV, ts: Stream, ks: Seq) + requires + ks.len() == 0 || !is_directive(a, ks[0]), + ensures + !has_use_strict(a, ts, ks), +{ +} + +/// The root is not a Directive Prologue's: its first item is not a string literal statement. +fn root_has_no_directive(nodes: &[Node], root: usize) -> (r: bool) + requires + root < nodes.len(), + ast_wf(arena_of(nodes@)), + ensures + r ==> (arena_of(nodes@).nodes[root as int].children.len() == 0 || !is_directive( + arena_of(nodes@), + arena_of(nodes@).nodes[root as int].children[0], + )), +{ + let nd = match nodes.get(root) { + Some(x) => x, + None => { + return false; + }, + }; + if nd.children.is_empty() { + proof { + let a = arena_of(nodes@); + assert(a.nodes[root as int] == nodes@[root as int]@); + assert(nd == &nodes@[root as int]); + assert(a.nodes[root as int].children.len() == 0); + } + return true; + } + let k0 = match kid_kind(nodes, root, 0) { + Some(k) => k, + None => { + return false; + }, + }; + if !matches!(k0, NodeKind::ExpressionStatement) { + return true; + } + let c = match nd.children.as_slice().get(ZERO) { + Some(c) => *c as usize, + None => { + return false; + }, + }; + proof { + let a = arena_of(nodes@); + assert(a.nodes[root as int] == nodes@[root as int]@); + assert(nd == &nodes@[root as int]); + assert(a.nodes[root as int].children[0] == c as int); + lemma_child_before(a, root as int, 0); + } + if c >= root { + return false; + } + match kid_kind(nodes, c, 0) { + Some(k) => !matches!(k, NodeKind::StringLiteral), + None => false, + } +} + +/// [`check_early`] on the canonical stream of the executable tokens and gaps +/// ([`canon_stream`]), which needs no ghost argument. +pub fn check_early_canon( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + gaps: &[Ins], + module: bool, +) -> (r: Derivation) + requires + ast_wf(arena_of(nodes@)), + gaps@.len() == toks@.len() + 1, + ensures + r is Verified ==> early_errors_ok( + arena_of(nodes@), + canon_stream(src@, toks@, gaps@), + goal_of(module), + ), +{ + let _ = gaps.len(); + let nt = toks.len(); + let mut k: usize = 0; + while k < nt + invariant + nt == toks.len(), + k <= nt, + forall|x: int| + 0 <= x < k ==> (#[trigger] toks@[x]).start <= toks@[x].end && toks@[x].end + <= src@.len(), + decreases nt - k, + { + let t = match toks.get(k) { + Some(t) => t, + None => { + return Derivation::Unsupported; + }, + }; + if t.start > t.end || t.end > src.len() { + return Derivation::Unsupported; + } + k = k.saturating_add(1); + } + let ghost ts = canon_stream(src@, toks@, gaps@); + proof { + assert(toks_match(src@, toks@, ts)) by { + assert(toks@.len() == ts.toks.len()); + assert forall|x: int| 0 <= x < toks@.len() implies dtok_matches( + src@, + toks@[x], + #[trigger] ts.toks[x], + ) by { + assert(ts.toks[x] == canon_tok(src@, toks@[x])); + } + } + } + check_early(src, nodes, toks, module, Ghost(ts)) +} + +/// Checks that the arena has no early error (`spec::early_errors_ok`), for the rules and +/// node kinds listed at the top of the module, given the executable tokens (the +/// assumption `toks_match`). `Failed` is never returned; what is not covered is +/// `Unsupported`. +#[verifier::rlimit(400)] +pub fn check_early( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + module: bool, + Ghost(ts): Ghost, +) -> (r: Derivation) + requires + ast_wf(arena_of(nodes@)), + toks_match(src@, toks@, ts), + ensures + r is Verified ==> early_errors_ok(arena_of(nodes@), ts, goal_of(module)), +{ + let n = nodes.len(); + if n == 0 || module { + return Derivation::Unsupported; + } + let last = n.saturating_sub(1); + let nt = toks.len(); + // The tokens start at increasing positions. + let mut k: usize = 0; + while k < nt + invariant + nt == toks.len(), + k <= nt, + toks_match(src@, toks@, ts), + forall|x: int, y: int| + 0 <= x < y < k ==> (#[trigger] toks@[x]).start < (#[trigger] toks@[y]).start, + decreases nt - k, + { + if k > 0 { + let (p, t) = match (toks.get(k.saturating_sub(1)), toks.get(k)) { + (Some(p), Some(t)) => (p, t), + _ => { + return Derivation::Unsupported; + }, + }; + if p.start >= t.start { + return Derivation::Unsupported; + } + } + k = k.saturating_add(1); + } + proof { + assert(starts_inc(ts)) by { + assert forall|x: int, y: int| 0 <= x < y < tn(ts) implies (#[trigger] ts.toks[x]).start + < (#[trigger] ts.toks[y]).start by { + assert(dtok_matches(src@, toks@[x], ts.toks[x])); + assert(dtok_matches(src@, toks@[y], ts.toks[y])); + } + } + } + // A hint for finding a token from its start. + let size = src.len().saturating_add(1); + let mut by_start: Vec = Vec::new(); + let mut q: usize = 0; + while q < size + invariant + q <= size, + by_start.len() == q, + decreases size - q, + { + by_start.push(usize::MAX); + q = q.saturating_add(1); + } + let mut x: usize = 0; + while x < nt + invariant + x <= nt, + nt == toks.len(), + by_start.len() == size, + decreases nt - x, + { + let t = match toks.get(x) { + Some(t) => t, + None => { + return Derivation::Unsupported; + }, + }; + if t.start < by_start.len() { + by_start.set(t.start, x); + } + x = x.saturating_add(1); + } + // The root's environment: a script without a Use Strict Directive. + if !root_has_no_directive(nodes, last) { + return Derivation::Unsupported; + } + let root_e = EEnv { + strict: false, + module: false, + yield_: false, + await_: false, + in_loop: false, + in_breakable: false, + super_prop: false, + super_call: false, + new_target: false, + no_arguments: false, + no_yield_await: false, + tagged: false, + derived: false, + }; + let mut envs: Vec = Vec::new(); + let mut q: usize = 0; + while q < n + invariant + q <= n, + envs.len() == q, + decreases n - q, + { + envs.push(root_e); + q = q.saturating_add(1); + } + let ghost a = arena_of(nodes@); + proof { + assert(a.root == nodes.len() as int - 1); + } + // Untrusted: the environment each child is to be checked in, from the root down. + let mut i = n; + while i > 0 + invariant + i <= n, + n == nodes.len(), + envs.len() == n, + ast_wf(a), + a == arena_of(nodes@), + decreases i, + { + i = i.saturating_sub(1); + let nd = match nodes.get(i) { + Some(x) => x, + None => { + return Derivation::Unsupported; + }, + }; + let env_i = match envs.get(i) { + Some(x) => *x, + None => { + return Derivation::Unsupported; + }, + }; + let len = nd.children.len(); + let mut kk: usize = 0; + while kk < len + invariant + kk <= len, + len == nd.children.len(), + envs.len() == n, + n == nodes.len(), + i < nodes.len(), + nd == &nodes@[i as int], + ast_wf(a), + a == arena_of(nodes@), + len == nodes@[i as int].children.len(), + decreases len - kk, + { + if let (Some(ce), Some(c)) = ( + child_env_exec(nodes, i, kk, &env_i, Ghost(ts)), + nd.children.as_slice().get(kk), + ) { + let c = *c as usize; + if c < n { + envs.set(c, ce); + } + } + kk = kk.saturating_add(1); + } + } + // Bottom-up: each node's rules hold, and each child's recorded environment is the + // one `child_env` gives it. + let mut m: usize = 0; + while m < n + invariant + m <= n, + n == nodes.len(), + envs.len() == n, + ast_wf(a), + a == arena_of(nodes@), + toks_match(src@, toks@, ts), + starts_inc(ts), + forall|j: int| 0 <= j < m ==> early(a, ts, j, eenv_of(envs@[j])), + decreases n - m, + { + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return Derivation::Unsupported; + }, + }; + let env_m = match envs.get(m) { + Some(x) => *x, + None => { + return Derivation::Unsupported; + }, + }; + if !early_local_exec(src, nodes, toks, &by_start, m, &env_m, Ghost(ts)) { + return Derivation::Unsupported; + } + let len = nd.children.len(); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + } + let mut kk: usize = 0; + while kk < len + invariant + kk <= len, + len == nd.children.len(), + m < n, + n == nodes.len(), + envs.len() == n, + nd == &nodes@[m as int], + len == a.nodes[m as int].children.len(), + ast_wf(a), + a == arena_of(nodes@), + forall|j: int| 0 <= j < m ==> early(a, ts, j, eenv_of(envs@[j])), + forall|q: int| + 0 <= q < kk ==> { + let c = #[trigger] a.nodes[m as int].children[q]; + 0 <= c < m && early(a, ts, c, child_env(a, ts, m as int, q, eenv_of(env_m))) + }, + decreases len - kk, + { + let c = match nd.children.as_slice().get(kk) { + Some(c) => *c as usize, + None => { + return Derivation::Unsupported; + }, + }; + proof { + assert(a.nodes[m as int].children[kk as int] == c as int); + lemma_child_before(a, m as int, kk as int); + } + let ce = match child_env_exec(nodes, m, kk, &env_m, Ghost(ts)) { + Some(ce) => ce, + None => { + return Derivation::Unsupported; + }, + }; + let have = match envs.get(c) { + Some(x) => *x, + None => { + return Derivation::Unsupported; + }, + }; + if c >= m || !eenv_eq(&have, &ce) { + return Derivation::Unsupported; + } + kk = kk.saturating_add(1); + } + proof { + assert(early(a, ts, m as int, eenv_of(envs@[m as int]))); + } + m = m.saturating_add(1); + } + let root_have = match envs.get(last) { + Some(x) => *x, + None => { + return Derivation::Unsupported; + }, + }; + if !eenv_eq(&root_have, &root_e) { + return Derivation::Unsupported; + } + proof { + let g = goal_of(module); + assert(g == SourceGoal::Script); + lemma_no_directive(a, ts, a.nodes[a.root].children); + assert(!has_use_strict(a, ts, kids(a, a.root))); + assert(root_env(a, ts, g) == eenv_of(root_e)); + assert(a.root == last as int); + assert(early(a, ts, a.root, eenv_of(envs@[a.root]))); + } + Derivation::Verified +} + +} // verus! diff --git a/crates/clazel-js-syntax/src/exec.rs b/crates/clazel-js-syntax/src/exec.rs index d8ad9ec9..3e8b6d21 100644 --- a/crates/clazel-js-syntax/src/exec.rs +++ b/crates/clazel-js-syntax/src/exec.rs @@ -25,6 +25,17 @@ pub fn parse(src: &[u32], goal: SourceGoal) -> Result { /// with `Verified` carries a proof of `spec::derives_root` (modulo the lexer), and /// with `Unsupported` is only tested. pub fn parse_checked(src: &[u32], goal: SourceGoal) -> Result<(Ast, Derivation), ParseError> { + parse_checked_early(src, goal).map(|(ast, d, _)| (ast, d)) +} + +/// [`parse_checked`], and what [`crate::arena_early::check_early_canon`] found of the arena: +/// `Verified` (the third component) means the arena has no early error +/// (`spec::early_errors_ok`), so `Verified` in both means `spec::is_valid_parse` holds, modulo +/// the assumptions of [`crate::arena_d`]; `Unsupported` that a rule or node kind is not covered. +pub fn parse_checked_early( + src: &[u32], + goal: SourceGoal, +) -> Result<(Ast, Derivation, Derivation), ParseError> { // Recursion is bounded by `MAX_DEPTH` nested nodes, each a few frames; a // thread with room for that is cheaper than a stack overflow. Short // sources cannot nest that deep. @@ -45,7 +56,10 @@ pub fn parse_checked(src: &[u32], goal: SourceGoal) -> Result<(Ast, Derivation), }) } -fn parse_inner(src: &[u32], goal: SourceGoal) -> Result<(Ast, Derivation), ParseError> { +fn parse_inner( + src: &[u32], + goal: SourceGoal, +) -> Result<(Ast, Derivation, Derivation), ParseError> { let module = goal == SourceGoal::Module; let mut p = Parser::new(src, module)?; let root = p.parse_program()?; @@ -67,7 +81,8 @@ fn parse_inner(src: &[u32], goal: SourceGoal) -> Result<(Ast, Derivation), Parse if d == Derivation::Failed { return Err(ParseError::Syntax); } - Ok((ast, d)) + let early = crate::arena_early::check_early_canon(src, &ast.nodes, &p.rec, &gaps, module); + Ok((ast, d, early)) } /// The nodes reachable from `root`, in their original order, renumbered. The diff --git a/crates/clazel-js-syntax/src/lib.rs b/crates/clazel-js-syntax/src/lib.rs index 0b486106..789024a0 100644 --- a/crates/clazel-js-syntax/src/lib.rs +++ b/crates/clazel-js-syntax/src/lib.rs @@ -46,6 +46,11 @@ //! lemmas that a node of the shape the parser builds is derived by [`spec::d`]. //! The check assumes the tokens are the lexer specification's, which the //! executable lexer does not meet yet, and that inserted `;` are justified. +//! [`arena_e`] and [`arena_m`] cover the rest of the script grammar and every +//! `import` and `export` form. [`arena_early`] is the same for the early errors: +//! a proven check of `spec::early` over the arena for a growing set of rules (the +//! list is at the top of the module), run by [`exec::parse_checked_early`]; where +//! both checks say `Verified`, `spec::is_valid_parse` holds, modulo the assumptions. //! //! Where the parser differs from the specification, on purpose or not: //! @@ -57,6 +62,7 @@ pub mod api; pub mod arena_d; pub mod arena_e; +pub mod arena_early; pub mod arena_m; pub mod ast; pub mod check; diff --git a/crates/clazel-js-syntax/src/token.rs b/crates/clazel-js-syntax/src/token.rs index 5c18f48e..059e8974 100644 --- a/crates/clazel-js-syntax/src/token.rs +++ b/crates/clazel-js-syntax/src/token.rs @@ -251,6 +251,9 @@ pub fn dtok_of(t: &Tok) -> crate::arena_d::DTok { end: t.end, nl: t.nl, escaped: t.escaped, + legacy: t.legacy, + invalid_escape: t.invalid_escape, + name: t.name.clone(), } } diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index 47e64a25..93f6f6e3 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -310,6 +310,63 @@ fn leftover_script_gaps_are_verified() { } } +fn early(s: &str) -> Option { + clazel_js_syntax::exec::parse_checked_early(&cps(s), SourceGoal::Script) + .ok() + .map(|(_, _, e)| e) +} + +/// The early rules the proven check covers. +#[test] +fn covered_early_rules_are_verified() { + for s in [ + "", + "1 + 2;", + "a = b; a.c = d; a[0]++; ++a.b;", + "010; '\\07';", + "yield = 1; var await = 2; let = 3;", + "`a${b}c`; f`\\u{`;", + "if (a) b; else c;", + "while (a) { b; if (c) break; else continue; }", + "do { break; } while (a);", + "for (;;) { break; }", + "for (var i = 0; i < n; i++) { continue; }", + "switch_ = 1; with (a) b;", + "a?.b?.[c]?.(d);", + "delete a.b; typeof a; void 0; a in b; a instanceof b;", + "{ a; { b; } }", + "var a; var a;", + "new.target", + ] { + let r = early(s); + if s == "new.target" { + assert!(r.is_none(), "{s}"); + } else { + assert!(r == Some(Derivation::Verified), "{s}"); + } + } +} + +/// What the proven early-error check leaves alone. +#[test] +fn other_early_rules_are_unsupported_not_failed() { + for s in [ + "'use strict'; a = 1;", + "let a;", + "a: b;", + "(function () {})", + "class A {}", + "for (a in b) ;", + "/a/;", + "a.#b;", + "try {} catch (e) {}", + "switch (a) { case 1: }", + ] { + let r = early(s); + assert!(r != Some(Derivation::Verified) && r != Some(Derivation::Failed), "{s}"); + } +} + /// Productions only a sloppy-mode `Script` has. #[test] fn covered_sloppy_programs_are_verified() { diff --git a/crates/clazel-js-syntax/tests/test262.rs b/crates/clazel-js-syntax/tests/test262.rs index 9ea6b155..dad0e302 100644 --- a/crates/clazel-js-syntax/tests/test262.rs +++ b/crates/clazel-js-syntax/tests/test262.rs @@ -257,9 +257,10 @@ fn test262_fixtures_parse() -> Result<(), String> { #[cfg_attr(miri, ignore = "reads files")] fn test262_verified_share() -> Result<(), String> { use clazel_js_syntax::arena_d::Derivation; - use clazel_js_syntax::exec::parse_checked; + use clazel_js_syntax::exec::{parse_checked, parse_checked_early}; let (mut positives, mut verified) = (0usize, 0usize); let (mut mpositives, mut mverified) = (0usize, 0usize); + let (mut early, mut both, mut mearly, mut mboth) = (0usize, 0usize, 0usize, 0usize); for case in TEST262 { if !judged(case) || case.negative.is_some() { continue; @@ -271,13 +272,20 @@ fn test262_verified_share() -> Result<(), String> { s.extend("\"use strict\";\n".chars().map(u32::from)); } s.extend(src.iter().copied()); - let ok = matches!(parse_checked(&s, goal), Ok((_, Derivation::Verified))); + let (ok, eok) = match parse_checked_early(&s, goal) { + Ok((_, d, e)) => (d == Derivation::Verified, e == Derivation::Verified), + Err(_) => (false, false), + }; if goal == SourceGoal::Module { mpositives += 1; mverified += usize::from(ok); + mearly += usize::from(eok); + mboth += usize::from(ok && eok); } else { positives += 1; verified += usize::from(ok); + early += usize::from(eok); + both += usize::from(ok && eok); } } } @@ -307,6 +315,9 @@ fn test262_verified_share() -> Result<(), String> { fv += usize::from(d == Derivation::Verified); } } + println!( + "Early errors verified: {early} of {positives} script positive runs ({both} with the derivation too), {mearly} of {mpositives} module positive runs ({mboth} with the derivation too)" + ); println!( "Verified: {verified} of {positives} script positive runs, {mverified} of {mpositives} module positive runs, {fv} of {fnn} module fixtures, {hv} of {hn} harness files" ); From b4f66d80b13770cce55359d9627aa86ade4c9739 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 15:48:21 +0000 Subject: [PATCH 020/195] clazel-jit: the state relation and the refinement statements of the LIR to x86-64 back end Contracts before code (CLAUDE.md rule 3). spec.rs: the frame in the context's writable area, the relation between a LIR state and an x86-64 machine state, running code. contract.rs: per-template refinement of clazel-lir's eval by clazel-x64's step, the exit sequence's refinement, and the emitter's contracts. api.rs: the contract-only Backend trait. No template and no proof yet; the crate stays at tier 0. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 10 + crates/clazel-jit/Cargo.toml | 30 ++ crates/clazel-jit/src/api.rs | 47 +++ crates/clazel-jit/src/contract.rs | 178 +++++++++++ crates/clazel-jit/src/lib.rs | 29 ++ crates/clazel-jit/src/spec.rs | 485 ++++++++++++++++++++++++++++++ xtask/src/status.rs | 2 + 7 files changed, 781 insertions(+) create mode 100644 crates/clazel-jit/Cargo.toml create mode 100644 crates/clazel-jit/src/api.rs create mode 100644 crates/clazel-jit/src/contract.rs create mode 100644 crates/clazel-jit/src/lib.rs create mode 100644 crates/clazel-jit/src/spec.rs diff --git a/Cargo.lock b/Cargo.lock index c8972623..7730682a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -388,6 +388,16 @@ dependencies = [ "vstd", ] +[[package]] +name = "clazel-jit" +version = "0.0.0" +dependencies = [ + "clazel-codecheck", + "clazel-lir", + "clazel-x64", + "vstd", +] + [[package]] name = "clazel-js-lexer" version = "0.0.0" diff --git a/crates/clazel-jit/Cargo.toml b/crates/clazel-jit/Cargo.toml new file mode 100644 index 00000000..f916b9c3 --- /dev/null +++ b/crates/clazel-jit/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "clazel-jit" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish.workspace = true +description = "The JIT's back ends (docs/phases/jit.md item J.9): LIR to x86-64 with no register allocation, each LIR instruction a fixed template over scratch registers, with a Verus refinement proof per template. First slice: straight-line integer code. No JS front end, no A64 back end, no code cache yet." + +[dependencies] +vstd = "=0.0.0-2026-10-04-0306" +# The source language, the target instruction subset, and the validator whose +# ABI (context register, region table, exit sequence) the templates follow. +clazel-lir = { path = "../clazel-lir" } +clazel-x64 = { path = "../clazel-x64" } +clazel-codecheck = { path = "../clazel-codecheck" } + +# Verification tier (docs/VERIFICATION.md). `tier` is what is proven about the +# shipped code today: nothing is claimed until CI's full verification of this +# crate is green (CLAUDE.md rule 7), and the crate has no independent +# transcription or mutation file yet. `target-tier` is what jit.md's "Crates" +# table sets. +[package.metadata.clazel] +tier = 0 +target-tier = 2 + +[package.metadata.verus] +verify = true + +[lints] +workspace = true diff --git a/crates/clazel-jit/src/api.rs b/crates/clazel-jit/src/api.rs new file mode 100644 index 00000000..c89461f1 --- /dev/null +++ b/crates/clazel-jit/src/api.rs @@ -0,0 +1,47 @@ +//! The contract-only API of the back end: a trait with no implementation, so +//! Verus accepts it with no escape hatch (CLAUDE.md rule 4), the pattern of +//! `clazel-x64`'s and `clazel-codecheck`'s `api.rs`. The implementation (the +//! next commit) implements it, or replaces it with free functions whose +//! `requires` and `ensures` are the same predicates. +//! +//! The input is [`Op`]s, not `clazel_lir::spec::Instr`: LIR's own type holds +//! proof-only numbers and sequences, and the JS front end (J.10) will have its +//! own executable form. [`Op`]'s `view` says which LIR instruction each stands +//! for. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// The LIR → x86-64 back end, with its contracts. +pub trait Backend { + /// The x86-64 instructions for the straight-line program `ops`, in a + /// function with `nl` locals, entered with an empty operand stack (see + /// [`crate::contract::emit_body_ensures`]). + fn emit_body(ops: &[Op], nl: usize) -> (r: Option>) + requires + crate::contract::emit_requires(ops@, nl), + ensures + crate::contract::emit_body_ensures(ops@, nl, match r { + Some(v) => Some(v@), + None => None, + }), + ; + + /// The bytes of a blob: the canonical encoding of the body, then the exit + /// sequence for `exit_code` (see [`crate::contract::emit_blob_ensures`]). + fn emit_blob(ops: &[Op], nl: usize, exit_code: u32) -> (r: Option>) + requires + crate::contract::emit_requires(ops@, nl), + ensures + crate::contract::emit_blob_ensures(ops@, nl, exit_code, match r { + Some(v) => Some(v@), + None => None, + }), + ; +} + +} // verus! diff --git a/crates/clazel-jit/src/contract.rs b/crates/clazel-jit/src/contract.rs new file mode 100644 index 00000000..10357a69 --- /dev/null +++ b/crates/clazel-jit/src/contract.rs @@ -0,0 +1,178 @@ +//! What the back end must be proven to satisfy (CLAUDE.md rule 3, +//! docs/SPEC-STYLE.md): the refinement statements, and one `requires` and one +//! `ensures` predicate for each method of [`super::api::Backend`], in terms of +//! [`super::spec`] and the two semantics it relates. These are written before +//! any template (the templates are the next commit); reviewing them and +//! `spec` is enough to know what is claimed. +//! +//! # The refinement statement +//! +//! [`refines`]`(i, nl, h, code)` says that the x86-64 instruction list `code` +//! is a correct translation of the LIR instruction `i`, for a function with +//! `nl` locals, when the operand stack has `h` values. For every layout and +//! every `create_undef` (the machine's unspecified function for undefined +//! flags, so the statement holds for all of them), every LIR state `a` and +//! machine state `m` related by [`rel`]: +//! +//! - if LIR evaluates `i` in `a` (with any fuel) and **falls through** to the +//! state `a2` (a `Stuck` or `OutOfFuel` outcome is not claimed about, and +//! `i` is not required to be well typed: if it is not, LIR is `Stuck`, and +//! the statement says nothing), +//! - and the end of the code is a canonical address, +//! - then running `code` from `m` ([`run_seq`]) does not fault, ends in a +//! machine state `m2` related to `a2` by [`rel`], with `rip` after the code, +//! and `m2` differs from `m` only in the exit area ([`preserved`]). +//! +//! That is a **forward simulation of one LIR step by one template**, for the +//! LIR semantics that is deterministic. Soundness of the whole translation +//! (every execution of the machine code is the image of a LIR execution) needs +//! the converse for the exits, branches and `Stuck`: the exit is +//! [`exit_refines`]; the others are for the control-flow templates. A +//! straight-line program is one [`refines`] over [`prog_instr`]. +//! +//! # What is not stated +//! +//! - That the output is **accepted by the validator.** jit.md requires it and +//! `tests/validator.rs` checks it for every template and generated +//! programs, by running the executable validator. It is not a theorem here. +//! - That a *failed* LIR step (a bounds-check exit, `Stuck`) is matched by the +//! machine: no template in this slice has one. +//! - Anything about [`rel`]'s `rip`, flags or scratch registers. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// What the machine must be in after `code` ran from `m`, for the LIR state +/// `a2` that `i` reached: no fault, related, `rip` after the code, and +/// nothing outside the exit area changed. +pub open spec fn refines_post( + lay: lir::Layout, + a2: lir::St, + m: x64::State, + nl: nat, + code: Seq, + r: Option, +) -> bool { + match r { + Some(m2) => rel(lay, a2, m2, nl) && m2.rip == m.rip + code_len(code) && preserved(m, m2), + None => false, + } +} + +/// `code` refines the LIR instruction `i` at stack height `h` with `nl` +/// locals (see the module doc). +pub open spec fn refines(i: lir::Instr, nl: nat, h: nat, code: Seq) -> bool { + forall| + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + m: x64::State, + fuel: nat, + | + #![trigger lir::eval(lay, i, a, fuel), run_seq(cu, m, code)] + a.stack.len() == h && rel(lay, a, m, nl) && x64::canonical(m.rip + code_len(code)) + ==> match lir::eval(lay, i, a, fuel) { + lir::Outcome::Normal(a2) => refines_post(lay, a2, m, nl, code, run_seq(cu, m, code)), + _ => true, + } +} + +/// The exit sequence for `c` refines LIR's `exit c` with no operands, given +/// the stack the enter stub leaves ([`stack_ok`]): running the three +/// instructions does not fault; the machine ends at the return address the +/// stub pushed, with the exit code `c` in the context's exit-code word, the +/// frame and the regions as they were ([`rel`] still holds, and the +/// memory outside the exit area is unchanged), and `rsp` popped by the +/// `ret`. +pub open spec fn exit_refines(c: u32, nl: nat) -> bool { + forall| + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + m: x64::State, + fuel: nat, + | + #![trigger lir::eval(lay, lir::Instr::Exit(c as nat, seq![]), a, fuel), run_seq(cu, m, exit_seq(c))] + rel(lay, a, m, nl) && stack_ok(m) && x64::canonical(m.rip + code_len(exit_seq(c))) + ==> match lir::eval(lay, lir::Instr::Exit(c as nat, seq![]), a, fuel) { + lir::Outcome::Exit(code, _, a2) => match run_seq(cu, m, exit_seq(c)) { + Some(m2) => { + let rsp = x64::logext(64, m.rgf[abi::sp_reg() as int] as int); + rel(lay, a2, m2, nl) && preserved_mem(m, m2) && x64::read_mem( + m2.mem, + ctx_of(m) + abi::exit_code_off(), + 8, + ) == Some(code as int) && m2.rgf[abi::sp_reg() as int] as int == x64::loghead( + 64, + rsp + 8, + ) && match x64::read_mem(m.mem, rsp, 8) { + Some(raw) => m2.rip == x64::logext(64, raw), + None => false, + } + }, + None => false, + }, + _ => true, + } +} + +// ---------------------------------------------------------------------------- +// The emitter's contracts (the executable back end, `api::Backend`) +// ---------------------------------------------------------------------------- + +/// The instructions of `code` are all in the x86-64 subset +/// ([`x64::valid_instr`]). +pub open spec fn all_valid_instrs(code: Seq) -> bool { + forall|j: int| 0 <= j < code.len() ==> x64::valid_instr(#[trigger] code[j]) +} + +/// Precondition of `emit_body` and `emit_blob`: none. Every program and every +/// local count is a legal input (one outside the first slice, or too large +/// for the frame, is answered `None`). +pub open spec fn emit_requires(ops: Seq, nl: usize) -> bool { + true +} + +/// Postcondition of `emit_body`: the program has a translation exactly when +/// [`prog_ok`] says every instruction has a template; the translation is in +/// the subset and refines the program's LIR instruction. +pub open spec fn emit_body_ensures( + ops: Seq, + nl: usize, + r: Option>, +) -> bool { + match r { + Some(code) => prog_ok(ops, nl as nat, 0) && all_valid_instrs(code) && refines( + prog_instr(ops), + nl as nat, + 0, + code, + ), + None => !prog_ok(ops, nl as nat, 0), + } +} + +/// Postcondition of `emit_blob`: the bytes are the canonical encodings +/// ([`clazel_codecheck::spec::enc_all`], which is what the validator reads +/// back) of a body that refines the program, followed by the exit sequence +/// for `exit_code`. `None` exactly when the program has no translation. +pub open spec fn emit_blob_ensures( + ops: Seq, + nl: usize, + exit_code: u32, + r: Option>, +) -> bool { + match r { + Some(bytes) => prog_ok(ops, nl as nat, 0) && exists|body: Seq| + #![trigger all_valid_instrs(body)] + all_valid_instrs(body) && refines(prog_instr(ops), nl as nat, 0, body) && bytes + == clazel_codecheck::spec::enc_all(body + exit_seq(exit_code)), + None => !prog_ok(ops, nl as nat, 0), + } +} + +} // verus! diff --git a/crates/clazel-jit/src/lib.rs b/crates/clazel-jit/src/lib.rs new file mode 100644 index 00000000..3802c9f3 --- /dev/null +++ b/crates/clazel-jit/src/lib.rs @@ -0,0 +1,29 @@ +//! The JIT's back ends (docs/phases/jit.md item J.9), the x86-64 one first: +//! LIR → x86-64 with **no register allocation**. Every LIR local, and every +//! element of LIR's operand stack, is a frame slot; each LIR instruction is a +//! fixed template over the scratch registers `rax`, `rcx` and `rdx`, so each +//! template's proof is local. +//! +//! This is the first slice of J.9, and it is written contract first (CLAUDE.md +//! rule 3). +//! +//! - [`spec`]: **what the back end is about.** The state relation between a +//! LIR state and an x86-64 machine state, the frame layout (the codecheck +//! ABI fixes where the code may write), the straight-line source subset +//! [`spec::Op`]. Read its header first: it lists the modelling choices. +//! - [`contract`]: the refinement statements (a template's x86-64 code, +//! run under `clazel-x64`'s `step` from a related state, reaches a state +//! related to LIR's `eval`), and the emitter's contracts. +//! - [`api`]: the contract-only trait [`api::Backend`]. +//! +//! # Status +//! +//! Tier 0, and nothing is proven yet: this commit holds the statements only. +//! The templates, their proofs, the emitter and the validator test follow. +//! +//! Tier: see `[package.metadata.clazel]` in `Cargo.toml` and +//! `docs/VERIFICATION.md`. + +pub mod api; +pub mod contract; +pub mod spec; diff --git a/crates/clazel-jit/src/spec.rs b/crates/clazel-jit/src/spec.rs new file mode 100644 index 00000000..965356e9 --- /dev/null +++ b/crates/clazel-jit/src/spec.rs @@ -0,0 +1,485 @@ +//! What the LIR → x86-64 back end is *about* (jit.md item J.9): the state +//! relation between a LIR state and an x86-64 machine state, the shape of a +//! template, and the small definitions the refinement statements of +//! [`crate::contract`] are written in. Nothing here runs and nothing is +//! proven; the templates are in `templates` and their proofs in the modules +//! after it. +//! +//! # Source +//! +//! There is no standard to transcribe. The sources are: +//! +//! - **jit.md, "J.9 Back ends"**: "No register allocation: every LIR local is +//! a frame slot, and each LIR instruction is a fixed template over scratch +//! registers, so each template's proof is local. Per-template refinement of +//! LIR semantics, then composition over structured control flow." +//! - **`clazel-lir`'s `spec`** ([`lir::eval`]): the meaning of the source. +//! - **`clazel-x64`'s `spec`** ([`x64::step`]): the meaning of the target. +//! - **`clazel-codecheck`'s `spec::abi`**: the context register, the region +//! table, and which context bytes the code may write. The templates follow +//! it, so that what they emit is accepted (the test in +//! `tests/validator.rs`; the validator's own spec is not re-stated here). +//! +//! # Modelling choices +//! +//! These are *ours*: jit.md fixes "a frame slot per local" but not where the +//! frame is, or what happens to LIR's operand stack. +//! +//! 1. **The frame is the context's writable area.** The only memory the +//! validator lets code write without a bounds-check sequence is the exit +//! area of the context, bytes `256..512` from `r15` +//! ([`abi::exit_code_off`], [`abi::ctx_size`]). The frame is the part of it +//! after the exit code: slot `j` is the 8 bytes at `r15 + 264 + 8 j` +//! ([`slot_disp`]), for `j < 31` ([`max_slots`]). A function whose locals +//! and operand stack need more than 31 slots is refused ([`prog_ok`]). A +//! larger frame is a region (jit.md J.0: the interpreter's value stack), +//! reached through the 8-instruction bounds-check sequence on every +//! access; that needs the memory templates and is future work. **The exit +//! code word (offset 256) is not a slot**, so an exit sequence does not +//! overwrite a local. +//! 2. **LIR's operand stack is in the frame too.** LIR is a stack machine (it +//! mirrors WebAssembly), and "every local is a slot" needs a home for the +//! stack. Locals are slots `0 .. nl`; the operand stack's element `k` +//! (bottom first) is slot `nl + k`. The height of the stack at each +//! instruction is a static fact of well-typed straight-line code, so a +//! template is a function of `(op, nl, h)` ([`templates::tmpl`]). +//! 3. **A value is a 64-bit word.** An `i64` and an `f64` (its bit pattern) +//! are stored as they are, and an `i32` zero-extended +//! ([`lir::val_bits`], which is below `2^32` for an `i32`). The type is +//! not stored: it is static. +//! 4. **No register is live between two LIR instructions.** The scratch +//! registers `rax`, `rcx` and `rdx` ([`rax`], [`rcx`], [`rdx`]) and the +//! flags are dead at each template's start and end, so the relation does +//! not mention them. `r15` (the context) and `rsp` are never written. +//! 5. **Running code is [`run_seq`]**: [`x64::step`] on each instruction of a +//! `Seq` in turn. That the bytes at `rip` are the canonical +//! encoding of the instruction ([`x64::fetch_ok`]) is not part of it: +//! instead [`preserved`] says the code writes nothing but the exit area, +//! so code placed outside the exit area stays what it was, and the bytes +//! are `enc_all` of the instruction list (the emitter's contract). +//! 6. **Addresses are user-space addresses.** The context lies below +//! `2^47` ([`ctx_ok`]), so every address a template forms is canonical and +//! equals the effective address (no wrap-around), and the code's end +//! address is canonical (a `requires` of each refinement). +//! 7. **LIR memory is related, not yet touched.** [`mem_rel`] relates each +//! region byte of LIR's memory to the machine's, and every template in +//! this slice leaves both unchanged. The memory templates (`bounds_check`, +//! `load`, `store`) are not here. +//! +//! # What is not here +//! +//! The memory instructions, structured control flow (`block`, `loop`, `if`, +//! `br`, `br_if`, `br_table`), `exit` with operands, `f64` arithmetic, +//! comparisons and conversions (LIR's `f64` operators are uninterpreted +//! functions, so a refinement to SSE needs an axiom this crate does not +//! add), rotates, and the A64 back end. + +/// The validator's ABI, re-exported so that this crate's modules read one namespace. +pub use clazel_codecheck::spec::abi; +/// LIR's semantics, re-exported likewise. +pub use clazel_lir::spec as lir; +/// The x86-64 subset's semantics, re-exported likewise. +pub use clazel_x64::spec as x64; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +// ============================================================================ +// Section: the source subset +// ============================================================================ + +/// A LIR instruction of the first slice, in a form executable code can build: +/// `clazel-lir`'s own `Instr` holds `nat`s and `Seq`s, which exist only in +/// proofs. [`View`] is the LIR instruction it stands for. +pub enum Op { + /// `nop`. + Nop, + /// `t.const v`. + Const(lir::Val), + /// `local.get x`. + LocalGet(usize), + /// `local.set x`. + LocalSet(usize), + /// `local.tee x`. + LocalTee(usize), + /// `drop`. + Drop, + /// `select`. + Select, + /// A binary numeric instruction. + Bin(lir::BinOp), + /// A unary numeric instruction. + Un(lir::UnOp), +} + +impl vstd::view::View for Op { + type V = lir::Instr; + + open spec fn view(&self) -> lir::Instr { + match *self { + Op::Nop => lir::Instr::Nop, + Op::Const(v) => lir::Instr::Const(v), + Op::LocalGet(x) => lir::Instr::LocalGet(x as nat), + Op::LocalSet(x) => lir::Instr::LocalSet(x as nat), + Op::LocalTee(x) => lir::Instr::LocalTee(x as nat), + Op::Drop => lir::Instr::Drop, + Op::Select => lir::Instr::Select, + Op::Bin(b) => lir::Instr::Bin(b), + Op::Un(u) => lir::Instr::Un(u), + } + } +} + +/// A straight-line program as one LIR instruction: `((nop; op_0); op_1); ...`, +/// the left-nested `then` chain, so that the program minus its last +/// instruction is the first operand of the outermost `then`. +pub open spec fn prog_instr(ops: Seq) -> lir::Instr + decreases ops.len(), +{ + if ops.len() == 0 { + lir::Instr::Nop + } else { + lir::Instr::Then(Box::new(prog_instr(ops.drop_last())), Box::new(ops.last()@)) + } +} + +/// How many operand-stack values the instruction takes. +pub open spec fn pops(op: Op) -> nat { + match op { + Op::Nop => 0, + Op::Const(_) => 0, + Op::LocalGet(_) => 0, + Op::LocalSet(_) => 1, + Op::LocalTee(_) => 1, + Op::Drop => 1, + Op::Select => 3, + Op::Bin(_) => 2, + Op::Un(_) => 1, + } +} + +/// How many operand-stack values the instruction leaves. +pub open spec fn pushes(op: Op) -> nat { + match op { + Op::Nop => 0, + Op::Const(_) => 1, + Op::LocalGet(_) => 1, + Op::LocalSet(_) => 0, + Op::LocalTee(_) => 1, + Op::Drop => 0, + Op::Select => 1, + Op::Bin(_) => 1, + Op::Un(_) => 1, + } +} + +/// The stack height after `op` at height `h`. +pub open spec fn height_after_op(op: Op, h: nat) -> nat { + (h - pops(op) + pushes(op)) as nat +} + +/// The integer binary operators this slice has templates for: everything but +/// `rotl` and `rotr`, which the x86-64 subset has no instruction for. +pub open spec fn ibin_supported(o: lir::IBin) -> bool { + match o { + lir::IBin::Rotl => false, + lir::IBin::Rotr => false, + _ => true, + } +} + +/// The binary instructions of this slice: integer arithmetic and logic, and +/// integer comparisons. Not the `f64` ones (see the header). +pub open spec fn bin_supported(b: lir::BinOp) -> bool { + match b { + lir::BinOp::I32(o) => ibin_supported(o), + lir::BinOp::I64(o) => ibin_supported(o), + lir::BinOp::I32Cmp(_) => true, + lir::BinOp::I64Cmp(_) => true, + lir::BinOp::F64(_) => false, + lir::BinOp::F64Cmp(_) => false, + } +} + +/// The unary instructions of this slice: the integer tests and conversions, +/// and the `f64` instructions that are bit operations (`neg`, `abs`, +/// `reinterpret`). Not `sqrt` or the integer-to-`f64` conversions. +pub open spec fn un_supported(u: lir::UnOp) -> bool { + match u { + lir::UnOp::I32Eqz => true, + lir::UnOp::I64Eqz => true, + lir::UnOp::F64Neg => true, + lir::UnOp::F64Abs => true, + lir::UnOp::F64Sqrt => false, + lir::UnOp::I32WrapI64 => true, + lir::UnOp::I64ExtendI32S => true, + lir::UnOp::I64ExtendI32U => true, + lir::UnOp::F64ConvertI32S => false, + lir::UnOp::F64ConvertI32U => false, + lir::UnOp::F64ConvertI64S => false, + lir::UnOp::F64ConvertI64U => false, + lir::UnOp::F64ReinterpretI64 => true, + lir::UnOp::I64ReinterpretF64 => true, + } +} + +/// The instruction has a template, and is well formed at a stack of height +/// `h` with `nl` locals: its operands exist, its local index is in range, +/// and everything it reads or writes is one of the 31 frame slots. +pub open spec fn op_ok(op: Op, nl: nat, h: nat) -> bool { + pops(op) <= h && nl + height_after_op(op, h) <= max_slots() && match op { + Op::LocalGet(x) => x < nl, + Op::LocalSet(x) => x < nl, + Op::LocalTee(x) => x < nl, + Op::Bin(b) => bin_supported(b), + Op::Un(u) => un_supported(u), + _ => true, + } +} + +/// The stack height after the program `ops`, started at height `h`. +pub open spec fn height_after(ops: Seq, h: nat) -> nat + decreases ops.len(), +{ + if ops.len() == 0 { + h + } else { + height_after_op(ops.last(), height_after(ops.drop_last(), h)) + } +} + +/// Every instruction of `ops` has a template at its place in the program, for +/// `nl` locals and a stack that starts at height `h`, and the starting frame +/// fits. +pub open spec fn prog_ok(ops: Seq, nl: nat, h: nat) -> bool + decreases ops.len(), +{ + if ops.len() == 0 { + nl + h <= max_slots() + } else { + prog_ok(ops.drop_last(), nl, h) && op_ok(ops.last(), nl, height_after(ops.drop_last(), h)) + } +} + +// ============================================================================ +// Section: the frame +// ============================================================================ + +/// `rax`, the first scratch register. +pub open spec fn rax() -> u8 { + 0 +} + +/// `rcx`, the second scratch register (and the shift count: `shl r, cl`). +pub open spec fn rcx() -> u8 { + 1 +} + +/// `rdx`, the third scratch register. +pub open spec fn rdx() -> u8 { + 2 +} + +/// The offset from the context register of frame slot 0: the first word +/// after the exit code (modelling choice 1). +pub open spec fn frame_off() -> int { + abi::exit_code_off() + 8 +} + +/// The number of frame slots: the words of the context after the exit code. +pub open spec fn max_slots() -> nat { + ((abi::ctx_size() - frame_off()) / 8) as nat +} + +/// The displacement of frame slot `j` from the context register. +pub open spec fn slot_disp(j: nat) -> int { + frame_off() + 8 * j +} + +/// The memory operand of frame slot `j`: `[r15 + 264 + 8 j]`. +pub open spec fn slot_mem(j: nat) -> x64::Mem { + x64::Mem { base: abi::ctx_reg(), index: None, disp: slot_disp(j) as i32 } +} + +/// The value of the context register in `m`, as an address. +pub open spec fn ctx_of(m: x64::State) -> int { + m.rgf[abi::ctx_reg() as int] as int +} + +/// The context lies in user space: the 512 bytes from the context register +/// are all below `2^47` (modelling choice 6). +pub open spec fn ctx_ok(m: x64::State) -> bool { + m.rgf.len() == 16 && 0 <= ctx_of(m) && ctx_of(m) + abi::ctx_size() <= x64::p2(47) +} + +/// `a` is a byte of the context's exit area (what [`abi`] lets code write). +pub open spec fn in_exit_area(ctxb: int, a: int) -> bool { + ctxb + abi::exit_code_off() <= a && a < ctxb + abi::ctx_size() +} + +/// Every byte of the exit area is mapped. +pub open spec fn exit_area_mapped(mm: Map, ctxb: int) -> bool { + forall|a: int| #[trigger] in_exit_area(ctxb, a) ==> mm.dom().contains(a) +} + +/// The 8 bytes at the address of slot `j` read as the word `v`. +pub open spec fn slot_holds(mm: Map, ctxb: int, j: nat, v: nat) -> bool { + x64::read_mem(mm, ctxb + slot_disp(j), 8) == Some(v as int) +} + +// ============================================================================ +// Section: the state relation +// ============================================================================ + +/// The value in slot `j` of the LIR state `a`, which has `nl` locals: a local +/// for `j < nl`, else the operand stack's element `j - nl`. +pub open spec fn slot_val(a: lir::St, nl: nat, j: nat) -> lir::Val { + if j < nl { + a.locals[j as int] + } else { + a.stack[(j - nl) as int] + } +} + +/// The addresses of the regions of `lay` are the addresses of its bytes: `a` +/// is inside some region. +pub open spec fn in_regions(lay: lir::Layout, a: nat) -> bool { + exists|r: int| + #![trigger lay[r]] + 0 <= r < lay.len() && lay[r].base <= a && a < lay[r].base + lay[r].bound +} + +/// LIR's memory and the machine's agree on every byte of every region: the +/// machine maps it, and holds the byte LIR's memory reads (absent bytes read +/// 0, `lir::byte_at`). +pub open spec fn mem_rel(lay: lir::Layout, lm: lir::Mem, mm: Map) -> bool { + forall|a: nat| #[trigger] in_regions(lay, a) ==> mm.dom().contains(a as int) && mm[a as int] + == lir::byte_at(lm, a) +} + +/// No region overlaps the context's exit area, which holds the frame: the +/// frame is the only machine memory the templates write, and it is nobody's +/// region. +pub open spec fn regions_clear_of_exit_area(lay: lir::Layout, ctxb: int) -> bool { + forall|a: nat| #[trigger] in_regions(lay, a) ==> !in_exit_area(ctxb, a as int) +} + +/// **The state relation.** The LIR state `a`, with `nl` locals, is +/// represented by the machine state `m`: +/// +/// 1. `m` is a well-formed machine state ([`x64::wf`]), with the context in +/// user space ([`ctx_ok`]) and the layout well formed and clear of the +/// exit area; +/// 2. the frame fits: `a` has `nl` locals and `nl + height` is at most 31; +/// 3. the exit area is mapped, so a store to a slot does not fault; +/// 4. every local, and every operand-stack element, is in its slot, as the +/// 64-bit word [`lir::val_bits`] of its value; +/// 5. memory is related ([`mem_rel`]). +/// +/// The scratch registers, the flags, `rip` and the XMM registers are not +/// constrained (modelling choice 4); the refinement statements say where +/// `rip` is. +pub open spec fn rel(lay: lir::Layout, a: lir::St, m: x64::State, nl: nat) -> bool { + x64::wf(m) && ctx_ok(m) && lir::layout_wf(lay) && regions_clear_of_exit_area(lay, ctx_of(m)) + && a.locals.len() == nl && nl + a.stack.len() <= max_slots() && exit_area_mapped( + m.mem, + ctx_of(m), + ) && (forall|j: nat| + j < nl + a.stack.len() ==> #[trigger] slot_holds( + m.mem, + ctx_of(m), + j, + lir::val_bits(slot_val(a, nl, j)), + )) && mem_rel(lay, a.mem, m.mem) +} + +/// What a template leaves alone in memory: the context register keeps its +/// value, the set of mapped addresses is the same, and every byte outside the +/// exit area keeps its value. So the code (which lives outside the exit +/// area) and every region are as they were. +pub open spec fn preserved_mem(m: x64::State, m2: x64::State) -> bool { + m.rgf.len() == 16 && m2.rgf.len() == 16 && m2.rgf[abi::ctx_reg() as int] + == m.rgf[abi::ctx_reg() as int] && m2.mem.dom() == m.mem.dom() && (forall|a: int| + #[trigger] m.mem.dom().contains(a) && !in_exit_area(ctx_of(m), a) ==> m2.mem[a] + == m.mem[a]) +} + +/// [`preserved_mem`], and the stack pointer keeps its value too (no +/// template but the exit sequence's `ret` touches it, and the validator +/// forbids writing it). +pub open spec fn preserved(m: x64::State, m2: x64::State) -> bool { + preserved_mem(m, m2) && m2.rgf[abi::sp_reg() as int] == m.rgf[abi::sp_reg() as int] +} + +// ============================================================================ +// Section: running code +// ============================================================================ + +/// Run the instructions of `code` one after the other from `s`, each by +/// [`x64::step`], stopping at a fault (`None`). `rip` advances by each +/// instruction's length (and, for a jump, goes to its target; the straight-line +/// templates have none). +pub open spec fn run_seq( + cu: spec_fn(nat) -> nat, + s: x64::State, + code: Seq, +) -> Option + decreases code.len(), +{ + if code.len() == 0 { + Some(s) + } else { + match x64::step(cu, s, code[0]) { + Some(s1) => run_seq(cu, s1, code.skip(1)), + None => None, + } + } +} + +/// The exit sequence for `c`, as the validator recognizes it +/// (`clazel_codecheck::spec::exit_unit_at`): `mov rax, c`, `mov [r15 + 256], +/// rax`, `ret`. It is LIR's `exit` with no operands (a function that falls +/// off its end exits with code `c`). +pub open spec fn exit_seq(c: u32) -> Seq { + seq![ + x64::Instr::MovImm32 { dst: rax(), imm_u32: c }, + x64::Instr::MovStore { + sz: x64::Size::W64, + mem: x64::Mem { base: abi::ctx_reg(), index: None, disp: abi::exit_code_off() as i32 }, + src: rax(), + }, + x64::Instr::Ret, + ] +} + +/// The machine's stack is as the enter stub leaves it for the `ret` of an +/// exit sequence: `rsp` points at 8 mapped bytes holding a canonical return +/// address, `rsp + 8` is canonical, and the stack word is not in the context +/// (so the exit code's store cannot change it). +pub open spec fn stack_ok(m: x64::State) -> bool { + m.rgf.len() == 16 && { + let rsp = x64::logext(64, m.rgf[abi::sp_reg() as int] as int); + match x64::read_mem(m.mem, rsp, 8) { + Some(raw) => x64::canonical(x64::logext(64, rsp + 8)) && x64::canonical( + x64::logext(64, raw), + ) && (rsp + 8 <= ctx_of(m) + abi::exit_code_off() || ctx_of(m) + abi::ctx_size() + <= rsp), + None => false, + } + } +} + +/// The length in bytes of the canonical encodings of `code`, one after the +/// other. +pub open spec fn code_len(code: Seq) -> nat + decreases code.len(), +{ + if code.len() == 0 { + 0 + } else { + x64::instr_len(code[0]) + code_len(code.skip(1)) + } +} + +} // verus! diff --git a/xtask/src/status.rs b/xtask/src/status.rs index 95f09263..09d156b0 100644 --- a/xtask/src/status.rs +++ b/xtask/src/status.rs @@ -95,6 +95,8 @@ const PLACES: &[(&str, Place)] = &[ ("clazel-codecheck", Place::Primitive), // The JIT's low-level IR (item J.5). ("clazel-lir", Place::Renderer), + // The JIT's back ends (item J.9), the x86-64 one first. + ("clazel-jit", Place::Renderer), ("clazel-ipc", Place::Primitive), ("clazel-sandbox", Place::Os), ("clazel-sys", Place::Os), From 9fd6116888f8264c20431d02a8aaca6a2ef641cd Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 15:55:08 +0000 Subject: [PATCH 021/195] clazel-js-heap: run 10 random element sequences under Miri, not 300 300 took 3013 s under Miri in CI, over xtask's 300 s limit; 10 of the same sequence take about 100 s. The normal test job still runs all 300. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-heap/src/elements/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/clazel-js-heap/src/elements/mod.rs b/crates/clazel-js-heap/src/elements/mod.rs index 5e8a2986..18a59e24 100644 --- a/crates/clazel-js-heap/src/elements/mod.rs +++ b/crates/clazel-js-heap/src/elements/mod.rs @@ -392,7 +392,11 @@ mod tests { #[test] fn matches_the_spec_on_random_sequences() { let mut rng = Lcg(0x5EED); - for _ in 0..300 { + // Miri interprets every step: 300 sequences took 3013 s there, over + // xtask's 300 s limit, so it runs the first 10 of the same sequence + // (about 100 s). The full count runs in the normal test job. + let sequences = if cfg!(miri) { 10 } else { 300 }; + for _ in 0..sequences { let mut e = Elements::new(); let mut s = Spec::new(0); for _ in 0..200 { From ab230f75e0ae4df5f9ccba1619c3a2c10cd6e2c1 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 15:57:52 +0000 Subject: [PATCH 022/195] clazel-js-heap: Kani harness for the marker (GC1), Graph trait, slice-based mark_into The marker is proven to contain the roots and be closed under the reachability rules for every graph of 4 nodes. The whole-heap harness did not finish in 10 minutes and is not included. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-heap/src/gc/contract.rs | 90 +++++++++++++++---- crates/clazel-js-heap/src/gc/mod.rs | 54 ++++++++---- crates/clazel-js-heap/src/proofs.rs | 106 +++++++++++++++++++++++ 3 files changed, 216 insertions(+), 34 deletions(-) diff --git a/crates/clazel-js-heap/src/gc/contract.rs b/crates/clazel-js-heap/src/gc/contract.rs index 0eb008d7..fca64eec 100644 --- a/crates/clazel-js-heap/src/gc/contract.rs +++ b/crates/clazel-js-heap/src/gc/contract.rs @@ -36,9 +36,11 @@ //! //! - **GC1 Safety.** A slot reachable from the roots is never freed. It //! keeps its index and generation, so every reference the program holds -//! to it still resolves, to the same object. This is the invariant the -//! Kani harnesses prove for every heap up to their bound, and the -//! property test checks on random heaps of any size ([`safe`]). +//! to it still resolves, to the same object. The Kani +//! harness proves the marker keeps every reachable node of every graph +//! up to its bound (see `src/proofs.rs` for the bound and for what is +//! not proven), and the property test checks the whole collector on +//! random heaps of any size ([`safe`]). //! - **GC2 Precision.** A slot not reachable from the roots is freed in //! that collection, so a collection leaves exactly the reachable slots //! ([`exact`]). Garbage is not a safety matter; this keeps the collector @@ -90,25 +92,78 @@ pub struct Node { pub ephemerons: Vec<(usize, usize)>, } +/// A heap graph: what [`reachable`] and the collector's `mark` read. The +/// provided implementations are for the slices of [`Node`]; the Kani +/// harnesses give it fixed-size arrays, which CBMC handles far faster than +/// vectors of vectors. +pub trait Graph { + /// The number of nodes. + fn len(&self) -> usize; + /// The strong edges of node `i` (none if there is no node `i`). + fn strong(&self, i: usize) -> &[usize]; + /// The ephemerons of node `i` (none if there is no node `i`). + fn ephemerons(&self, i: usize) -> &[(usize, usize)]; + /// Whether there are no nodes. + fn is_empty(&self) -> bool { + self.len() == 0 + } +} + +impl Graph for [Node] { + fn len(&self) -> usize { + <[Node]>::len(self) + } + fn strong(&self, i: usize) -> &[usize] { + self.get(i).map_or(&[], |n| &n.strong) + } + fn ephemerons(&self, i: usize) -> &[(usize, usize)] { + self.get(i).map_or(&[], |n| &n.ephemerons) + } +} + +impl Graph for Vec { + fn len(&self) -> usize { + Vec::len(self) + } + fn strong(&self, i: usize) -> &[usize] { + self.as_slice().strong(i) + } + fn ephemerons(&self, i: usize) -> &[(usize, usize)] { + self.as_slice().ephemerons(i) + } +} + +impl Graph for [Node; N] { + fn len(&self) -> usize { + N + } + fn strong(&self, i: usize) -> &[usize] { + self.as_slice().strong(i) + } + fn ephemerons(&self, i: usize) -> &[(usize, usize)] { + self.as_slice().ephemerons(i) + } +} + /// The nodes reachable from `roots` (module header, "Reachability"), as one /// flag per node. A root or edge naming no node (a stale or out-of-range /// reference) reaches nothing. #[must_use] -pub fn reachable(graph: &[Node], roots: &[usize]) -> Vec { +pub fn reachable(graph: &G, roots: &[usize]) -> Vec { let mut marked = vec![false; graph.len()]; for &r in roots { mark(&mut marked, r); } loop { let mut changed = false; - for (i, node) in graph.iter().enumerate() { + for i in 0..graph.len() { if !marked.get(i).copied().unwrap_or(false) { continue; } - for &e in &node.strong { + for &e in graph.strong(i) { changed |= mark(&mut marked, e); } - for &(k, v) in &node.ephemerons { + for &(k, v) in graph.ephemerons(i) { if marked.get(k).copied().unwrap_or(false) { changed |= mark(&mut marked, v); } @@ -133,7 +188,7 @@ fn mark(marked: &mut [bool], i: usize) -> bool { /// GC1: every reachable node survives. #[must_use] -pub fn safe(graph: &[Node], roots: &[usize], survives: &[bool]) -> bool { +pub fn safe(graph: &G, roots: &[usize], survives: &[bool]) -> bool { survives.len() == graph.len() && reachable(graph, roots) .iter() @@ -143,7 +198,7 @@ pub fn safe(graph: &[Node], roots: &[usize], survives: &[bool]) -> bool { /// GC1 and GC2: exactly the reachable nodes survive. #[must_use] -pub fn exact(graph: &[Node], roots: &[usize], survives: &[bool]) -> bool { +pub fn exact(graph: &G, roots: &[usize], survives: &[bool]) -> bool { reachable(graph, roots) == survives } @@ -152,16 +207,15 @@ pub fn exact(graph: &[Node], roots: &[usize], survives: &[bool]) -> bool { /// key of a surviving map may name a freed node only before GC4 clears the /// entry, so keys are not checked here. #[must_use] -pub fn closed(graph: &[Node], survives: &[bool]) -> bool { +pub fn closed(graph: &G, survives: &[bool]) -> bool { let alive = |i: usize| survives.get(i).copied().unwrap_or(false); - graph - .iter() - .enumerate() - .filter(|&(i, _)| alive(i)) - .all(|(_, n)| { - n.strong.iter().all(|&e| alive(e)) - && n.ephemerons.iter().all(|&(k, v)| !alive(k) || alive(v)) - }) + (0..graph.len()).filter(|&i| alive(i)).all(|i| { + graph.strong(i).iter().all(|&e| alive(e)) + && graph + .ephemerons(i) + .iter() + .all(|&(k, v)| !alive(k) || alive(v)) + }) } #[cfg(test)] diff --git a/crates/clazel-js-heap/src/gc/mod.rs b/crates/clazel-js-heap/src/gc/mod.rs index 105c14ce..e0668336 100644 --- a/crates/clazel-js-heap/src/gc/mod.rs +++ b/crates/clazel-js-heap/src/gc/mod.rs @@ -35,7 +35,7 @@ pub mod contract; use crate::arena::{self, Arena, Ref}; use crate::elements::Elements; use crate::value::Value; -use contract::Node; +use contract::{Graph, Node}; /// What a heap object is, beyond its ordinary properties. #[derive(Clone, Debug)] @@ -455,45 +455,67 @@ fn clear_weak(o: &mut Object, live: &Liveness, cleanups: &mut Vec) { /// Mark the nodes reachable from `roots`: a worklist for the strong edges, /// and passes over the ephemerons until none marks anything new. /// [`contract::reachable`] is its specification, and the Kani harnesses -/// prove them equal on every graph of their bound. +/// prove it closed over the roots and edges (so GC1) on every graph of +/// their bound. #[must_use] -pub fn mark(graph: &[Node], roots: &[usize]) -> Vec { +pub fn mark(graph: &G, roots: &[usize]) -> Vec { let mut marked = vec![false; graph.len()]; - let mut work: Vec = Vec::new(); + // Each node is queued at most once, so a stack of `len` never overflows. + let mut work = vec![0usize; graph.len()]; + mark_into(graph, roots, &mut marked, &mut work); + marked +} + +/// [`mark`] over storage the caller provides: `marked` (one flag per node, +/// all false) is filled in, and `work` (a stack of at least one slot per +/// node) is scratch. The Kani harnesses call this with arrays, because +/// CBMC does not finish with vectors in the model. +pub fn mark_into( + graph: &G, + roots: &[usize], + marked: &mut [bool], + work: &mut [usize], +) { + let mut top = 0usize; for &r in roots { - visit(&mut marked, &mut work, r); + visit(marked, work, &mut top, r); } loop { - while let Some(i) = work.pop() { - if let Some(node) = graph.get(i) { - for &e in &node.strong { - visit(&mut marked, &mut work, e); - } + while top > 0 { + top = top.saturating_sub(1); + let Some(i) = work.get(top).copied() else { + break; + }; + for &e in graph.strong(i) { + visit(marked, work, &mut top, e); } } let mut progressed = false; - for (i, node) in graph.iter().enumerate() { + for i in 0..graph.len() { if !marked.get(i).copied().unwrap_or(false) { continue; } - for &(k, v) in &node.ephemerons { + for &(k, v) in graph.ephemerons(i) { if marked.get(k).copied().unwrap_or(false) { - progressed |= visit(&mut marked, &mut work, v); + progressed |= visit(marked, work, &mut top, v); } } } if !progressed { - return marked; + return; } } } /// Mark `i` and queue it, if it names a node not yet marked. -fn visit(marked: &mut [bool], work: &mut Vec, i: usize) -> bool { +fn visit(marked: &mut [bool], work: &mut [usize], top: &mut usize, i: usize) -> bool { match marked.get_mut(i) { Some(m) if !*m => { *m = true; - work.push(i); + if let Some(slot) = work.get_mut(*top) { + *slot = i; + *top = top.saturating_add(1); + } true } _ => false, diff --git a/crates/clazel-js-heap/src/proofs.rs b/crates/clazel-js-heap/src/proofs.rs index e42da50b..11e2b628 100644 --- a/crates/clazel-js-heap/src/proofs.rs +++ b/crates/clazel-js-heap/src/proofs.rs @@ -318,3 +318,109 @@ fn symbol_key_encoding_any() { assert_eq!(encode(PropertyKey::String(Key(big))), None); assert_eq!(encode(PropertyKey::Symbol(SymbolId(big))), None); } + +// ---- Third slice: the collector ----------------------------------------- +// +// Bounds, stated. `gc_mark_closed_over_roots` proves the real marker +// (`gc::mark_into`, which `gc::mark` and so `Heap::collect` call) for every +// graph of `GRAPH` nodes where each node has one strong edge and one +// ephemeron, each naming any node or no node (a stale reference, or no +// edge), with any `GRAPH` roots: the marked set contains the roots and is +// closed under the rules that define reachability (a strong edge of a +// marked node; an ephemeron value whose map and key are marked). +// `gc::contract::reachable` is the least set with those two properties, so +// it is inside the marked set: every reachable node survives (GC1). That +// is the kernel of "a slot reachable from the roots is never freed". +// +// NOT proven by Kani: +// - GC2 (nothing unreachable is kept), by tests only. +// - `Heap::collect` as a whole: graph extraction, weak clearing, the sweep +// (GC3, GC4, GC6) and the safe-point guard. A harness over a heap of two +// objects (one slot value each, a `WeakRef`, any roots) was written and +// ran past a 10-minute limit without finishing, as the elements harnesses +// through `Vec`s and `BTreeMap` did, and was dropped. A first version of +// the marker harness over `Vec`s ran out of memory; `mark_into` takes +// slices so that arrays stand in for the vectors. Freeing goes through +// `Arena::free`, whose invariants the arena harnesses prove. +// - Graphs past `GRAPH` nodes, and arbitrary operation sequences. The +// property test in `gc::tests` checks GC1 to GC6 on random heaps of up +// to 3,000 objects against an independent oracle, which is a test, not a +// proof. + +use crate::gc::contract::Graph; +use crate::gc::mark_into; + +/// Nodes in the graphs of `gc_mark_closed_over_roots`. +const GRAPH: usize = 4; + +/// A node name, or one that names no node. +fn any_name(n: usize) -> usize { + let i: usize = kani::any(); + kani::assume(i <= n); + i +} + +/// A graph of `GRAPH` nodes as fixed arrays (vectors of vectors made CBMC +/// run for over ten minutes): each node has one strong edge and one +/// ephemeron, and a name past the last node (`GRAPH`) is "no node", which +/// reaches nothing, so it stands for the absence of the edge as well as for +/// a stale reference. +struct Fixed { + strong: [usize; GRAPH], + eph: [(usize, usize); GRAPH], +} + +impl Graph for Fixed { + fn len(&self) -> usize { + GRAPH + } + fn strong(&self, i: usize) -> &[usize] { + self.strong.get(i..=i).unwrap_or(&[]) + } + fn ephemerons(&self, i: usize) -> &[(usize, usize)] { + self.eph.get(i..=i).unwrap_or(&[]) + } +} + +#[kani::proof] +#[kani::solver(cadical)] +#[kani::unwind(10)] +fn gc_mark_closed_over_roots() { + let mut g = Fixed { + strong: [0; GRAPH], + eph: [(0, 0); GRAPH], + }; + for s in &mut g.strong { + *s = any_name(GRAPH); + } + for e in &mut g.eph { + *e = (any_name(GRAPH), any_name(GRAPH)); + } + // Any `GRAPH` roots, each a node or none: any subset of the nodes. + let mut roots = [0usize; GRAPH]; + for r in &mut roots { + *r = any_name(GRAPH); + } + let mut marked = [false; GRAPH]; + let mut work = [0usize; GRAPH]; + mark_into(&g, &roots, &mut marked, &mut work); + // GC1. `marked` contains the roots, and is closed under the rules that + // define reachability (a strong edge of a marked node, an ephemeron + // value whose key and map are marked). `contract::reachable` is the + // least set with those two properties, so it is inside `marked`: every + // reachable node survives. (Equality, GC2, is checked by the unit test + // `mark_equals_the_specification_on_random_graphs`, and on heaps by the + // property test.) + let is = |i: usize| marked.get(i).copied().unwrap_or(false); + for &r in &roots { + assert!(r >= GRAPH || is(r)); + } + for i in 0..GRAPH { + if is(i) { + let e = g.strong.get(i).copied().unwrap_or(GRAPH); + assert!(e >= GRAPH || is(e)); + let (k, v) = g.eph.get(i).copied().unwrap_or((GRAPH, GRAPH)); + assert!(k >= GRAPH || v >= GRAPH || !is(k) || is(v)); + } + } +} From 9c675a0387a433c975aab0f47d0c7384b42bde6a Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 16:09:24 +0000 Subject: [PATCH 023/195] clazel-js-syntax: proven early errors for function code Function declarations and expressions of every kind, arrow functions and methods: env_fn and the Use Strict Directive of a body (use_strict_exec), function_early (non-simple parameters with a directive, duplicate parameters) from the proven BoundNames of every node (arena_names). Early errors are verified for 591 of 1567 script runs (was 507). Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_early.rs | 572 +++++++++++- crates/clazel-js-syntax/src/arena_names.rs | 971 ++++++++++++++++++++ crates/clazel-js-syntax/src/lib.rs | 1 + crates/clazel-js-syntax/tests/derivation.rs | 7 +- 4 files changed, 1527 insertions(+), 24 deletions(-) create mode 100644 crates/clazel-js-syntax/src/arena_names.rs diff --git a/crates/clazel-js-syntax/src/arena_early.rs b/crates/clazel-js-syntax/src/arena_early.rs index 64d4239c..e9fce0b2 100644 --- a/crates/clazel-js-syntax/src/arena_early.rs +++ b/crates/clazel-js-syntax/src/arena_early.rs @@ -6,9 +6,14 @@ //! //! **Covered.** The environment: every node kind whose `child_env` arm is the default //! (`[~Tagged]`) or one of the loop, `switch`, object literal, tagged template and -//! template arms; the `labels` and `privates` of the environment are empty, so a labelled -//! statement, a class, a function or an arrow function (whose `child_env` arms need -//! `has_use_strict`, `env_fn` and class bodies) makes the result `Unsupported`. +//! template arms, and the function declarations and expressions of every kind, arrow +//! functions and methods of object literals (`env_fn`, and `has_use_strict` of the body, +//! [`crate::arena_names::use_strict_exec`]); the `labels` and `privates` of the +//! environment are empty, so a labelled statement or a class makes the result `Unsupported`. +//! Function code: `function_early` ([`crate::arena_names::function_early_exec`]: Use Strict +//! Directive with non-simple parameters, duplicate parameters, from the BoundNames of +//! [`crate::arena_names::bound_names_all`]) and the statement list of a `FunctionBody` +//! that declares nothing lexically. //! The rules of `early_local`: every kind with no rule (the `_ => true` arm); //! `NumericLiteral` and `StringLiteral` (strict mode legacy forms); the three identifier //! kinds (§13.1.1: strict reserved words, `eval`, `arguments`, `yield`, `await`, the @@ -24,8 +29,8 @@ //! of a block and a script whose items declare nothing lexically (so //! `LexicallyDeclaredNames` is empty). //! -//! **Not covered** (the result is `Unsupported`): everything else, notably function -//! and class code, labels, lexical declarations, `for`-`in`/`of`, `switch`, `try` +//! **Not covered** (the result is `Unsupported`): everything else, notably +//! class code, labels, lexical declarations, `for`-`in`/`of`, `switch`, `try` //! (`catch` parameters), regular expression literals (`regexp_valid` is item 7.10's), //! private names, a Use Strict Directive in a script, and `Module` roots. //! @@ -34,6 +39,7 @@ //! and `name`, the lexer's contract of item 7.2). use crate::arena_d::*; +use crate::arena_names::*; use crate::ast::*; use crate::spec::*; use vstd::prelude::*; @@ -53,7 +59,7 @@ pub open spec fn starts_inc(ts: Stream) -> bool { } /// The first token of node `n` is `ts.toks[x]`. -proof fn lemma_node_tok_at(a: AstV, ts: Stream, n: int, x: int) +pub(crate) proof fn lemma_node_tok_at(a: AstV, ts: Stream, n: int, x: int) requires starts_inc(ts), 0 <= n < a.nodes.len(), @@ -115,7 +121,7 @@ proof fn lemma_words_early() } /// Two slices of code points are the same. -fn seq_eq(a: &[u32], b: &[u32]) -> (r: bool) +pub(crate) fn seq_eq(a: &[u32], b: &[u32]) -> (r: bool) ensures r == (a@ =~= b@), { @@ -237,13 +243,436 @@ fn eenv_eq(p: &EEnv, q: &EEnv) -> (r: bool) == q.tagged && p.derived == q.derived } +/// The arguments of `spec::env_fn` that say what the function code allows. +pub struct FnFlags { + /// `[Yield]`. + pub y: bool, + /// `[Await]`. + pub aw: bool, + /// `SuperProperty` is allowed. + pub sp: bool, + /// `SuperCall` is allowed. + pub sc: bool, + /// `new.target` is allowed. + pub nt: bool, + /// `arguments` is not allowed. + pub na: bool, + /// `yield` and `await` expressions are not allowed. + pub nya: bool, +} + +/// `spec::env_fn`. +fn env_fn_exec(e: &EEnv, strict: bool, f: FnFlags) -> (r: EEnv) + ensures + eenv_of(r) == env_fn(eenv_of(*e), strict, f.y, f.aw, f.sp, f.sc, f.nt, f.na, f.nya), +{ + EEnv { + strict, + module: e.module, + yield_: f.y, + await_: f.aw, + in_loop: false, + in_breakable: false, + super_prop: f.sp, + super_call: f.sc, + new_target: f.nt, + no_arguments: f.na, + no_yield_await: f.nya, + tagged: false, + derived: e.derived, + } +} + +/// `IsStrict` of the code of the function-like node `n` whose body is its third child: +/// the enclosing code's, or a Use Strict Directive of the body. +#[verifier::rlimit(400)] +fn fn_strict_exec( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + by_start: &[usize], + n: usize, + env_strict: bool, + Ghost(ts): Ghost, +) -> (r: Option) + requires + n < nodes.len(), + ast_wf(arena_of(nodes@)), + toks_match(src@, toks@, ts), + starts_inc(ts), + ensures + match r { + Some(v) => { + let a = arena_of(nodes@); + v == (env_strict || has_use_strict(a, ts, kids(a, kid(a.nodes[n as int].children, 2)))) + }, + None => true, + }, +{ + if env_strict { + return Some(true); + } + let ghost a = arena_of(nodes@); + let nd = match nodes.get(n) { + Some(x) => x, + None => { + return None; + }, + }; + proof { + assert(a.nodes[n as int] == nodes@[n as int]@); + assert(nd == &nodes@[n as int]); + assert(a.nodes[n as int].children.len() == nd.children.len()); + } + match nd.children.as_slice().get(2) { + Some(b) => { + let b = *b as usize; + proof { + assert(a.nodes[n as int].children[2] == b as int); + lemma_child_before(a, n as int, 2); + } + use_strict_exec(src, nodes, toks, by_start, b, Ghost(ts)) + }, + None => { + proof { + assert(kid(a.nodes[n as int].children, 2) == -1int); + assert(kids(a, -1int) =~= Seq::::empty()); + } + Some(false) + }, + } +} + +/// `IsStrict` of the code of the arrow function `n`. +#[verifier::rlimit(400)] +fn arrow_strict_exec( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + by_start: &[usize], + n: usize, + env_strict: bool, + Ghost(ts): Ghost, +) -> (r: Option) + requires + n < nodes.len(), + ast_wf(arena_of(nodes@)), + toks_match(src@, toks@, ts), + starts_inc(ts), + ensures + match r { + Some(v) => { + let a = arena_of(nodes@); + let k1 = kid(a.nodes[n as int].children, 1); + v == (env_strict || (kd(a, k1) == NodeKind::FunctionBody && has_use_strict( + a, + ts, + kids(a, k1), + ))) + }, + None => true, + }, +{ + if env_strict { + return Some(true); + } + let ghost a = arena_of(nodes@); + let nd = match nodes.get(n) { + Some(x) => x, + None => { + return None; + }, + }; + proof { + assert(a.nodes[n as int] == nodes@[n as int]@); + assert(nd == &nodes@[n as int]); + assert(a.nodes[n as int].children.len() == nd.children.len()); + } + match kid_kind(nodes, n, 1) { + Some(NodeKind::FunctionBody) => { + let b = match nd.children.as_slice().get(1) { + Some(b) => *b as usize, + None => { + return None; + }, + }; + proof { + assert(a.nodes[n as int].children[1] == b as int); + lemma_child_before(a, n as int, 1); + } + use_strict_exec(src, nodes, toks, by_start, b, Ghost(ts)) + }, + Some(_) => Some(false), + None => None, + } +} + +/// A function declaration or expression of any kind. +pub open spec fn is_function_kind(k: NodeKind) -> bool { + k == NodeKind::FunctionDeclaration || k == NodeKind::FunctionExpression || k + == NodeKind::GeneratorDeclaration || k == NodeKind::GeneratorExpression || k + == NodeKind::AsyncFunctionDeclaration || k == NodeKind::AsyncFunctionExpression || k + == NodeKind::AsyncGeneratorDeclaration || k == NodeKind::AsyncGeneratorExpression +} + +/// `spec::child_env` for a function declaration or expression of any kind. +#[verifier::rlimit(400)] +fn child_env_function( + tk: &Tk, + nodes: &[Node], + n: usize, + k: usize, + e: &EEnv, + Ghost(ts): Ghost, +) -> (r: Option) + requires + n < nodes.len(), + ast_wf(arena_of(nodes@)), + k < nodes@[n as int].children.len(), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + is_function_kind(nodes@[n as int].kind), + ensures + match r { + Some(c) => eenv_of(c) == child_env(arena_of(nodes@), ts, n as int, k as int, eenv_of(*e)), + None => true, + }, +{ + let src = tk.src; + let toks = tk.toks; + let by_start = tk.by_start; + let ghost a = arena_of(nodes@); + let kind = match nodes.get(n) { + Some(x) => x.kind, + None => { + return None; + }, + }; + proof { + assert(a.nodes[n as int] == nodes@[n as int]@); + assert(a.nodes[n as int].kind == kind); + } + let strict = match fn_strict_exec(src, nodes, toks, by_start, n, e.strict, Ghost(ts)) { + Some(v) => v, + None => { + return None; + }, + }; + let g = matches!( + kind, + NodeKind::GeneratorDeclaration | NodeKind::GeneratorExpression + | NodeKind::AsyncGeneratorDeclaration | NodeKind::AsyncGeneratorExpression + ); + let aw = matches!( + kind, + NodeKind::AsyncFunctionDeclaration | NodeKind::AsyncFunctionExpression + | NodeKind::AsyncGeneratorDeclaration | NodeKind::AsyncGeneratorExpression + ); + let expr = matches!( + kind, + NodeKind::FunctionExpression | NodeKind::GeneratorExpression + | NodeKind::AsyncFunctionExpression | NodeKind::AsyncGeneratorExpression + ); + if k == 0 { + Some( + EEnv { + strict, + yield_: if expr { + g + } else { + e.yield_ + }, + await_: if expr { + aw + } else { + e.await_ + }, + ..*e + }, + ) + } else { + Some(env_fn_exec(e, strict, FnFlags { y: g, aw, sp: false, sc: false, nt: true, na: false, nya: k == 1 })) + } +} + +/// `spec::child_env` for a method of an object literal. +#[verifier::rlimit(400)] +fn child_env_method( + tk: &Tk, + nodes: &[Node], + n: usize, + k: usize, + e: &EEnv, + Ghost(ts): Ghost, +) -> (r: Option) + requires + n < nodes.len(), + ast_wf(arena_of(nodes@)), + k < nodes@[n as int].children.len(), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + nodes@[n as int].kind == NodeKind::MethodDefinition, + ensures + match r { + Some(c) => eenv_of(c) == child_env(arena_of(nodes@), ts, n as int, k as int, eenv_of(*e)), + None => true, + }, +{ + let src = tk.src; + let toks = tk.toks; + let by_start = tk.by_start; + let ghost a = arena_of(nodes@); + let op = match nodes.get(n) { + Some(x) => x.op, + None => { + return None; + }, + }; + proof { + assert(a.nodes[n as int] == nodes@[n as int]@); + assert(a.nodes[n as int].op == op); + } + if k == 0 { + return Some(*e); + } + // A constructor of a derived class may `super()`: classes are not covered. + if e.derived { + return None; + } + let strict = match fn_strict_exec(src, nodes, toks, by_start, n, e.strict, Ghost(ts)) { + Some(v) => v, + None => { + return None; + }, + }; + let mg = matches!(op, Op::GeneratorMethod | Op::AsyncGeneratorMethod); + let ma = matches!(op, Op::AsyncMethod | Op::AsyncGeneratorMethod); + Some(env_fn_exec(e, strict, FnFlags { y: mg, aw: ma, sp: true, sc: false, nt: true, na: false, nya: k == 1 })) +} + +/// `spec::child_env` for an arrow function. +#[verifier::rlimit(400)] +fn child_env_arrow( + tk: &Tk, + nodes: &[Node], + n: usize, + k: usize, + e: &EEnv, + Ghost(ts): Ghost, +) -> (r: Option) + requires + n < nodes.len(), + ast_wf(arena_of(nodes@)), + k < nodes@[n as int].children.len(), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + nodes@[n as int].kind == NodeKind::ArrowFunction || nodes@[n as int].kind + == NodeKind::AsyncArrowFunction, + ensures + match r { + Some(c) => eenv_of(c) == child_env(arena_of(nodes@), ts, n as int, k as int, eenv_of(*e)), + None => true, + }, +{ + let src = tk.src; + let toks = tk.toks; + let by_start = tk.by_start; + let ghost a = arena_of(nodes@); + let kind = match nodes.get(n) { + Some(x) => x.kind, + None => { + return None; + }, + }; + proof { + assert(a.nodes[n as int] == nodes@[n as int]@); + assert(a.nodes[n as int].kind == kind); + } + let strict = match arrow_strict_exec(src, nodes, toks, by_start, n, e.strict, Ghost(ts)) { + Some(v) => v, + None => { + return None; + }, + }; + if matches!(kind, NodeKind::ArrowFunction) { + if k == 0 { + Some(env_fn_exec(e, strict, FnFlags { y: e.yield_, aw: e.await_, sp: e.super_prop, sc: e.super_call, nt: e.new_target, na: e.no_arguments, nya: true })) + } else { + Some(env_fn_exec(e, strict, FnFlags { y: false, aw: false, sp: e.super_prop, sc: e.super_call, nt: e.new_target, na: e.no_arguments, nya: false })) + } + } else if k == 0 { + let y = match kid_kind(nodes, n, 0) { + Some(NodeKind::BindingIdentifier) => e.yield_, + Some(_) => false, + None => { + return None; + }, + }; + Some(env_fn_exec(e, strict, FnFlags { y, aw: true, sp: e.super_prop, sc: e.super_call, nt: e.new_target, na: e.no_arguments, nya: true })) + } else { + Some(env_fn_exec(e, strict, FnFlags { y: false, aw: true, sp: e.super_prop, sc: e.super_call, nt: e.new_target, na: e.no_arguments, nya: false })) + } +} + +/// `spec::child_env` for the function-like nodes: child `k` of node `n`. +fn child_env_fnlike( + tk: &Tk, + nodes: &[Node], + n: usize, + k: usize, + e: &EEnv, + Ghost(ts): Ghost, +) -> (r: Option) + requires + n < nodes.len(), + ast_wf(arena_of(nodes@)), + k < nodes@[n as int].children.len(), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + ensures + match r { + Some(c) => eenv_of(c) == child_env(arena_of(nodes@), ts, n as int, k as int, eenv_of(*e)), + None => true, + }, +{ + let kind = match nodes.get(n) { + Some(x) => x.kind, + None => { + return None; + }, + }; + proof { + let a = arena_of(nodes@); + assert(a.nodes[n as int] == nodes@[n as int]@); + } + match kind { + NodeKind::FunctionDeclaration | NodeKind::FunctionExpression | NodeKind::GeneratorDeclaration + | NodeKind::GeneratorExpression | NodeKind::AsyncFunctionDeclaration + | NodeKind::AsyncFunctionExpression | NodeKind::AsyncGeneratorDeclaration + | NodeKind::AsyncGeneratorExpression => child_env_function(tk, nodes, n, k, e, Ghost(ts)), + NodeKind::MethodDefinition => child_env_method(tk, nodes, n, k, e, Ghost(ts)), + NodeKind::ArrowFunction | NodeKind::AsyncArrowFunction => child_env_arrow(tk, nodes, n, k, e, Ghost(ts)), + _ => None, + } +} + + /// `spec::child_env` for the node kinds whose arm is simple: child `k` of node `n`. #[verifier::rlimit(400)] -fn child_env_exec(nodes: &[Node], n: usize, k: usize, e: &EEnv, Ghost(ts): Ghost) -> (r: Option) +fn child_env_exec( + tk: &Tk, + nodes: &[Node], + n: usize, + k: usize, + e: &EEnv, + Ghost(ts): Ghost, +) -> (r: Option) requires n < nodes.len(), ast_wf(arena_of(nodes@)), k < nodes@[n as int].children.len(), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), ensures match r { Some(c) => eenv_of(c) == child_env(arena_of(nodes@), ts, n as int, k as int, eenv_of(*e)), @@ -275,9 +704,9 @@ fn child_env_exec(nodes: &[Node], n: usize, k: usize, e: &EEnv, Ghost(ts): Ghost | NodeKind::GeneratorExpression | NodeKind::AsyncFunctionDeclaration | NodeKind::AsyncFunctionExpression | NodeKind::AsyncGeneratorDeclaration | NodeKind::AsyncGeneratorExpression | NodeKind::ArrowFunction | NodeKind::AsyncArrowFunction - | NodeKind::MethodDefinition | NodeKind::FieldDefinition | NodeKind::ClassStaticBlock - | NodeKind::ClassDeclaration | NodeKind::ClassExpression | NodeKind::ClassBody - | NodeKind::LabelledStatement => None, + | NodeKind::MethodDefinition => child_env_fnlike(tk, nodes, n, k, e, Ghost(ts)), + NodeKind::FieldDefinition | NodeKind::ClassStaticBlock | NodeKind::ClassDeclaration + | NodeKind::ClassExpression | NodeKind::ClassBody | NodeKind::LabelledStatement => None, NodeKind::ObjectLiteral => Some(EEnv { derived: false, ..*e }), NodeKind::DoWhileStatement => if k == 0 { Some(EEnv { in_loop: true, in_breakable: true, ..*e }) @@ -420,7 +849,7 @@ fn not_labelled(nodes: &[Node], c: usize) -> (r: bool) } /// The token a node starts at, found from its start. -fn node_token(nodes: &[Node], toks: &[DTok], by_start: &[usize], m: usize) -> (r: Option) +pub(crate) fn node_token(nodes: &[Node], toks: &[DTok], by_start: &[usize], m: usize) -> (r: Option) requires m < nodes.len(), ensures @@ -619,7 +1048,7 @@ pub open spec fn lex_empty_kind(k: NodeKind, top: bool) -> bool { } /// The lexically declared names of a list of such items are none. -proof fn lemma_lex_list_empty(a: AstV, ts: Stream, n: int, ks: Seq, k: int, top: bool) +pub(crate) proof fn lemma_lex_list_empty(a: AstV, ts: Stream, n: int, ks: Seq, k: int, top: bool) requires forall|j: int| 0 <= j < ks.len() ==> lex_empty_kind(kd(a, #[trigger] ks[j]), top), ensures @@ -636,7 +1065,7 @@ proof fn lemma_lex_list_empty(a: AstV, ts: Stream, n: int, ks: Seq, k: int, } /// `list_early` of a list whose items declare nothing lexically. -proof fn lemma_list_early_empty(a: AstV, ts: Stream, n: int, ks: Seq, strict: bool, top: bool) +pub(crate) proof fn lemma_list_early_empty(a: AstV, ts: Stream, n: int, ks: Seq, strict: bool, top: bool) requires forall|j: int| 0 <= j < ks.len() ==> lex_empty_kind(kd(a, #[trigger] ks[j]), top), ensures @@ -655,7 +1084,7 @@ proof fn lemma_list_early_empty(a: AstV, ts: Stream, n: int, ks: Seq, stric } /// The items of node `m` declare nothing lexically. -fn items_lex_empty(nodes: &[Node], m: usize, top: bool) -> (r: bool) +pub(crate) fn items_lex_empty(nodes: &[Node], m: usize, top: bool) -> (r: bool) requires m < nodes.len(), ast_wf(arena_of(nodes@)), @@ -732,7 +1161,7 @@ fn items_lex_empty(nodes: &[Node], m: usize, top: bool) -> (r: bool) } /// The kind of child `i` of node `m`, `Script` where there is none (`spec::kd(a, kid(ks, i))`). -fn kid_kind(nodes: &[Node], m: usize, i: usize) -> (r: Option) +pub(crate) fn kid_kind(nodes: &[Node], m: usize, i: usize) -> (r: Option) requires m < nodes.len(), ast_wf(arena_of(nodes@)), @@ -782,10 +1211,8 @@ fn kid_kind(nodes: &[Node], m: usize, i: usize) -> (r: Option) /// `early_local` of node `m` in `e`, for the rules this module covers (`false` otherwise). #[verifier::rlimit(400)] fn early_local_exec( - src: &[u32], + tk: &Tk, nodes: &[Node], - toks: &[DTok], - by_start: &[usize], m: usize, e: &EEnv, Ghost(ts): Ghost, @@ -793,11 +1220,16 @@ fn early_local_exec( requires m < nodes.len(), ast_wf(arena_of(nodes@)), - toks_match(src@, toks@, ts), + toks_match(tk.src@, tk.toks@, ts), starts_inc(ts), + tk.bn.len() == nodes.len(), + bn_inv(arena_of(nodes@), ts, tk.toks@, tk.bn@, nodes.len() as int), ensures r ==> early_local(arena_of(nodes@), ts, m as int, eenv_of(*e)), { + let src = tk.src; + let toks = tk.toks; + let by_start = tk.by_start; let ghost a = arena_of(nodes@); let nd = match nodes.get(m) { Some(x) => x, @@ -1001,6 +1433,74 @@ fn early_local_exec( } ok }, + NodeKind::FunctionBody => { + let ok = items_lex_empty(nodes, m, true); + proof { + if ok { + lemma_list_early_empty(a, ts, m as int, a.nodes[m as int].children, e.strict, true); + } + } + ok + }, + NodeKind::FunctionDeclaration | NodeKind::FunctionExpression | NodeKind::GeneratorDeclaration + | NodeKind::GeneratorExpression | NodeKind::AsyncFunctionDeclaration + | NodeKind::AsyncFunctionExpression | NodeKind::AsyncGeneratorDeclaration + | NodeKind::AsyncGeneratorExpression | NodeKind::MethodDefinition => { + let (p, b) = match (nd.children.as_slice().get(1), nd.children.as_slice().get(2)) { + (Some(p), Some(b)) => (*p as usize, *b as usize), + _ => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[1] == p as int); + assert(a.nodes[m as int].children[2] == b as int); + lemma_child_before(a, m as int, 1); + lemma_child_before(a, m as int, 2); + } + function_early_exec( + tk, + nodes, + p, + Some(b), + matches!(kind, NodeKind::MethodDefinition), + e.strict, + Ghost(ts), + ) + }, + NodeKind::ArrowFunction | NodeKind::AsyncArrowFunction => { + let (p, b) = match (nd.children.as_slice().get(ZERO), nd.children.as_slice().get(1)) { + (Some(p), Some(b)) => (*p as usize, *b as usize), + _ => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[0] == p as int); + assert(a.nodes[m as int].children[1] == b as int); + lemma_child_before(a, m as int, 0); + lemma_child_before(a, m as int, 1); + } + let bk = match kid_kind(nodes, m, 1) { + Some(k) => k, + None => { + return false; + }, + }; + function_early_exec( + tk, + nodes, + p, + if matches!(bk, NodeKind::FunctionBody) { + Some(b) + } else { + None + }, + true, + e.strict, + Ghost(ts), + ) + }, _ => false, } } @@ -1219,6 +1719,14 @@ pub fn check_early( } x = x.saturating_add(1); } + // The names the declarations bind. + let bn = match bound_names_all(src, nodes, toks, &by_start, Ghost(ts)) { + Some(bn) => bn, + None => { + return Derivation::Unsupported; + }, + }; + let tk = Tk { src, toks, by_start: by_start.as_slice(), bn: bn.as_slice() }; // The root's environment: a script without a Use Strict Directive. if !root_has_no_directive(nodes, last) { return Derivation::Unsupported; @@ -1262,6 +1770,10 @@ pub fn check_early( envs.len() == n, ast_wf(a), a == arena_of(nodes@), + toks_match(src@, toks@, ts), + tk.src@ == src@, + tk.toks@ == toks@, + starts_inc(ts), decreases i, { i = i.saturating_sub(1); @@ -1289,11 +1801,15 @@ pub fn check_early( nd == &nodes@[i as int], ast_wf(a), a == arena_of(nodes@), + toks_match(src@, toks@, ts), + tk.src@ == src@, + tk.toks@ == toks@, + starts_inc(ts), len == nodes@[i as int].children.len(), decreases len - kk, { if let (Some(ce), Some(c)) = ( - child_env_exec(nodes, i, kk, &env_i, Ghost(ts)), + child_env_exec(&tk, nodes, i, kk, &env_i, Ghost(ts)), nd.children.as_slice().get(kk), ) { let c = *c as usize; @@ -1315,7 +1831,12 @@ pub fn check_early( ast_wf(a), a == arena_of(nodes@), toks_match(src@, toks@, ts), + tk.src@ == src@, + tk.toks@ == toks@, + tk.bn@ == bn@, starts_inc(ts), + bn.len() == n, + bn_inv(a, ts, toks@, bn@, n as int), forall|j: int| 0 <= j < m ==> early(a, ts, j, eenv_of(envs@[j])), decreases n - m, { @@ -1331,7 +1852,7 @@ pub fn check_early( return Derivation::Unsupported; }, }; - if !early_local_exec(src, nodes, toks, &by_start, m, &env_m, Ghost(ts)) { + if !early_local_exec(&tk, nodes, m, &env_m, Ghost(ts)) { return Derivation::Unsupported; } let len = nd.children.len(); @@ -1352,6 +1873,11 @@ pub fn check_early( len == a.nodes[m as int].children.len(), ast_wf(a), a == arena_of(nodes@), + toks_match(src@, toks@, ts), + tk.src@ == src@, + tk.toks@ == toks@, + tk.bn@ == bn@, + starts_inc(ts), forall|j: int| 0 <= j < m ==> early(a, ts, j, eenv_of(envs@[j])), forall|q: int| 0 <= q < kk ==> { @@ -1370,7 +1896,7 @@ pub fn check_early( assert(a.nodes[m as int].children[kk as int] == c as int); lemma_child_before(a, m as int, kk as int); } - let ce = match child_env_exec(nodes, m, kk, &env_m, Ghost(ts)) { + let ce = match child_env_exec(&tk, nodes, m, kk, &env_m, Ghost(ts)) { Some(ce) => ce, None => { return Derivation::Unsupported; diff --git a/crates/clazel-js-syntax/src/arena_names.rs b/crates/clazel-js-syntax/src/arena_names.rs new file mode 100644 index 00000000..a9e8dedc --- /dev/null +++ b/crates/clazel-js-syntax/src/arena_names.rs @@ -0,0 +1,971 @@ +//! The names the early errors of [`crate::arena_early`] compare, computed over the +//! arena and proven equal to the specification's (item 7.3): BoundNames (§8.2.1) of +//! every node as token indices ([`bound_names_all`]), a Use Strict Directive +//! (`has_use_strict`, §11.2.1, [`use_strict_exec`]), the simple-parameter and +//! duplicate-name rules of function code (`function_early`, §15.1.1, +//! [`function_early_exec`]). +//! +//! A name is kept as the index of the token it is the name of, so a list of names is +//! a `Vec` and [`names_of`] is the specification's `Seq>` of it. + +use crate::arena_d::*; +use crate::arena_early::*; +use crate::ast::*; +use crate::spec::*; +use vstd::prelude::*; + +verus! { + +/// What the executable checks read besides the arena: the source, the tokens, a hint for finding +/// a token from its start, and the BoundNames of every node. +pub struct Tk<'a> { + /// The source text. + pub src: &'a [u32], + /// The tokens the parser consumed. + pub toks: &'a [DTok], + /// For a start position, the index of the token that starts there (`usize::MAX` for none). + pub by_start: &'a [usize], + /// The BoundNames of each node ([`bn_inv`]). + pub bn: &'a [Vec], +} + +/// The names of the tokens `xs`. +pub open spec fn names_of(toks: Seq, xs: Seq) -> Seq> { + Seq::new(xs.len(), |i: int| toks[xs[i] as int].name@) +} + +/// Every index of `xs` is a token. +pub open spec fn idx_ok(toks: Seq, xs: Seq) -> bool { + forall|i: int| 0 <= i < xs.len() ==> (#[trigger] xs[i]) < toks.len() +} + +/// `bn[j]` is the BoundNames of node `j`, for every node before `m`. +pub open spec fn bn_inv(a: AstV, ts: Stream, toks: Seq, bn: Seq>, m: int) -> bool { + forall|j: int| + 0 <= j < m ==> { + let v = (#[trigger] bn[j])@; + idx_ok(toks, v) && names_of(toks, v) =~= bound_names(a, ts, j) + } +} + +/// The names of two lists put together. +proof fn lemma_names_add(toks: Seq, xs: Seq, ys: Seq) + ensures + names_of(toks, xs + ys) =~= names_of(toks, xs) + names_of(toks, ys), +{ +} + +/// `dst` gets the elements of `src` after its own. +fn push_all(dst: &mut Vec, src: &[usize]) + ensures + final(dst)@ =~= old(dst)@ + src@, +{ + let len = src.len(); + let mut i: usize = 0; + while i < len + invariant + len == src.len(), + i <= len, + dst@ =~= old(dst)@ + src@.subrange(0, i as int), + decreases len - i, + { + match src.get(i) { + Some(x) => { + dst.push(*x); + }, + None => { + return; + }, + } + proof { + assert(src@.subrange(0, i as int + 1) =~= src@.subrange(0, i as int).push(src@[i as int])); + } + i = i.saturating_add(1); + } + proof { + assert(src@.subrange(0, len as int) =~= src@); + } +} + +/// The BoundNames of node `m` with one child: the first, or the last. +pub open spec fn bn_one(a: AstV, ts: Stream, m: int, last: bool) -> Seq> { + let ch = a.nodes[m].children; + let idx = if last { + ch.len() - 1 + } else { + 0 + }; + if ch.len() > 0 && 0 <= ch[idx] < m { + bound_names(a, ts, ch[idx]) + } else { + Seq::empty() + } +} + +/// The BoundNames of the children `ks[..k]` of node `n`, put together. +pub open spec fn bn_pre(a: AstV, ts: Stream, n: int, ks: Seq, k: int) -> Seq> + decreases k, +{ + if k <= 0 { + Seq::empty() + } else { + bn_pre(a, ts, n, ks, k - 1) + (if 0 <= ks[k - 1] < n { + bound_names(a, ts, ks[k - 1]) + } else { + Seq::empty() + }) + } +} + +/// `bound_names_list` is the prefix and what is left. +proof fn lemma_bn_pre(a: AstV, ts: Stream, n: int, ks: Seq, k: int) + requires + 0 <= k <= ks.len(), + ensures + bound_names_list(a, ts, n, ks, 0) =~= bn_pre(a, ts, n, ks, k) + bound_names_list(a, ts, n, ks, k), + decreases k, +{ + if k > 0 { + lemma_bn_pre(a, ts, n, ks, k - 1); + reveal_with_fuel(bound_names_list, 2); + let here = if 0 <= ks[k - 1] < n { + bound_names(a, ts, ks[k - 1]) + } else { + Seq::empty() + }; + assert(bound_names_list(a, ts, n, ks, k - 1) =~= here + bound_names_list(a, ts, n, ks, k)); + assert(bn_pre(a, ts, n, ks, k) =~= bn_pre(a, ts, n, ks, k - 1) + here); + } +} + +/// The BoundNames of node `m` of a kind with one child. +fn bn_child( + nodes: &[Node], + toks: &[DTok], + bn: &[Vec], + m: usize, + last: bool, + Ghost(ts): Ghost, +) -> (r: Option>) + requires + m < nodes.len(), + bn.len() == m, + ast_wf(arena_of(nodes@)), + bn_inv(arena_of(nodes@), ts, toks@, bn@, m as int), + ensures + match r { + Some(v) => idx_ok(toks@, v@) && names_of(toks@, v@) =~= bn_one( + arena_of(nodes@), + ts, + m as int, + last, + ), + None => true, + }, +{ + let ghost a = arena_of(nodes@); + let _ = toks.len(); + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == nd.children.len()); + } + let len = nd.children.len(); + if len == 0 { + return Some(Vec::new()); + } + let idx = if last { + len.saturating_sub(1) + } else { + 0 + }; + let c = match nd.children.as_slice().get(idx) { + Some(c) => *c as usize, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int].children[idx as int] == c as int); + lemma_child_before(a, m as int, idx as int); + } + if c >= m { + return None; + } + let from = match bn.get(c) { + Some(v) => v, + None => { + return None; + }, + }; + let mut out: Vec = Vec::new(); + push_all(&mut out, from.as_slice()); + proof { + assert(bn@[c as int] == from); + assert(out@ =~= from@); + } + Some(out) +} + +/// The BoundNames of node `m` of a kind that binds its children's, in order. +fn bn_list( + nodes: &[Node], + toks: &[DTok], + bn: &[Vec], + m: usize, + Ghost(ts): Ghost, +) -> (r: Option>) + requires + m < nodes.len(), + bn.len() == m, + ast_wf(arena_of(nodes@)), + bn_inv(arena_of(nodes@), ts, toks@, bn@, m as int), + ensures + match r { + Some(v) => idx_ok(toks@, v@) && names_of(toks@, v@) =~= bound_names_list( + arena_of(nodes@), + ts, + m as int, + arena_of(nodes@).nodes[m as int].children, + 0, + ), + None => true, + }, +{ + let ghost a = arena_of(nodes@); + let _ = toks.len(); + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let len = nd.children.len(); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + } + let ghost ks = a.nodes[m as int].children; + let mut out: Vec = Vec::new(); + let mut k: usize = 0; + while k < len + invariant + k <= len, + len == nd.children.len(), + m < nodes.len(), + bn.len() == m, + nd == &nodes@[m as int], + a == arena_of(nodes@), + ast_wf(a), + ks == a.nodes[m as int].children, + len == ks.len(), + bn_inv(a, ts, toks@, bn@, m as int), + idx_ok(toks@, out@), + names_of(toks@, out@) =~= bn_pre(a, ts, m as int, ks, k as int), + decreases len - k, + { + let c = match nd.children.as_slice().get(k) { + Some(c) => *c as usize, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int].children[k as int] == c as int); + lemma_child_before(a, m as int, k as int); + } + if c >= m { + return None; + } + let from = match bn.get(c) { + Some(v) => v, + None => { + return None; + }, + }; + let ghost before = out@; + push_all(&mut out, from.as_slice()); + proof { + assert(bn@[c as int] == from); + lemma_names_add(toks@, before, from@); + assert(bn_pre(a, ts, m as int, ks, k as int + 1) =~= bn_pre(a, ts, m as int, ks, k as int) + + bound_names(a, ts, c as int)); + assert forall|i: int| 0 <= i < out@.len() implies (#[trigger] out@[i]) < toks.len() by { + if i < before.len() { + assert(out@[i] == before[i]); + } else { + assert(out@[i] == from@[i - before.len()]); + } + } + } + k = k.saturating_add(1); + } + proof { + lemma_bn_pre(a, ts, m as int, ks, len as int); + assert(bound_names_list(a, ts, m as int, ks, len as int) =~= Seq::>::empty()); + } + Some(out) +} + +/// The BoundNames of the `BindingIdentifier` node `m`. +fn bn_ident( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + by_start: &[usize], + m: usize, + Ghost(ts): Ghost, +) -> (r: Option>) + requires + m < nodes.len(), + ast_wf(arena_of(nodes@)), + toks_match(src@, toks@, ts), + starts_inc(ts), + ensures + match r { + Some(v) => idx_ok(toks@, v@) && names_of(toks@, v@) =~= seq![name_of( + arena_of(nodes@), + ts, + m as int, + )], + None => true, + }, +{ + let _ = src.len(); + let x = match node_token(nodes, toks, by_start, m) { + Some(x) => x, + None => { + return None; + }, + }; + let out: Vec = vec![x]; + proof { + let a = arena_of(nodes@); + assert(dtok_matches(src@, toks@[x as int], ts.toks[x as int])); + lemma_node_tok_at(a, ts, m as int, x as int); + assert(a.nodes.len() == nodes@.len()); + assert(out@ =~= seq![x]); + assert(names_of(toks@, out@) =~= seq![toks@[x as int].name@]); + assert(name_of(a, ts, m as int) =~= toks@[x as int].name@); + } + Some(out) +} + +/// The BoundNames of every node, as the tokens that name them. +#[verifier::rlimit(400)] +pub fn bound_names_all( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + by_start: &[usize], + Ghost(ts): Ghost, +) -> (r: Option>>) + requires + ast_wf(arena_of(nodes@)), + toks_match(src@, toks@, ts), + starts_inc(ts), + ensures + match r { + Some(bn) => bn.len() == nodes.len() && bn_inv( + arena_of(nodes@), + ts, + toks@, + bn@, + nodes.len() as int, + ), + None => true, + }, +{ + let ghost a = arena_of(nodes@); + let n = nodes.len(); + let mut bn: Vec> = Vec::new(); + let mut m: usize = 0; + while m < n + invariant + m <= n, + n == nodes.len(), + bn.len() == m, + a == arena_of(nodes@), + ast_wf(a), + toks_match(src@, toks@, ts), + starts_inc(ts), + bn_inv(a, ts, toks@, bn@, m as int), + decreases n - m, + { + let kind = match nodes.get(m) { + Some(x) => x.kind, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(a.nodes[m as int].kind == kind); + } + let cur: Vec = match kind { + NodeKind::BindingIdentifier => match bn_ident(src, nodes, toks, by_start, m, Ghost(ts)) { + Some(v) => v, + None => { + return None; + }, + }, + NodeKind::BindingElement | NodeKind::BindingRestElement | NodeKind::BindingRestProperty + | NodeKind::FunctionRestParameter | NodeKind::VariableDeclaration | NodeKind::LexicalBinding + | NodeKind::ForDeclaration => match bn_child(nodes, toks, bn.as_slice(), m, false, Ghost(ts)) { + Some(v) => v, + None => { + return None; + }, + }, + NodeKind::BindingProperty => match bn_child(nodes, toks, bn.as_slice(), m, true, Ghost(ts)) { + Some(v) => v, + None => { + return None; + }, + }, + NodeKind::ObjectBindingPattern | NodeKind::ArrayBindingPattern | NodeKind::FormalParameters + | NodeKind::VariableStatement | NodeKind::LexicalDeclaration + | NodeKind::VariableDeclarationList => match bn_list(nodes, toks, bn.as_slice(), m, Ghost(ts)) { + Some(v) => v, + None => { + return None; + }, + }, + _ => Vec::new(), + }; + proof { + assert(idx_ok(toks@, cur@)); + assert(names_of(toks@, cur@) =~= bound_names(a, ts, m as int)); + } + let ghost old_bn = bn@; + bn.push(cur); + proof { + assert forall|j: int| 0 <= j < m as int + 1 implies { + let v = (#[trigger] bn@[j])@; + idx_ok(toks@, v) && names_of(toks@, v) =~= bound_names(a, ts, j) + } by { + if j < m as int { + assert(bn@[j] == old_bn[j]); + } + } + } + m = m.saturating_add(1); + } + Some(bn) +} + +// --------------------------------------------------------------------- +// Use Strict Directive. +// --------------------------------------------------------------------- + +/// The text of the two forms of a Use Strict Directive, as code points. +proof fn lemma_use_strict_words() + ensures + cps("\"use strict\""@) =~= seq![34u32, 117, 115, 101, 32, 115, 116, 114, 105, 99, 116, 34], + cps("'use strict'"@) =~= seq![39u32, 117, 115, 101, 32, 115, 116, 114, 105, 99, 116, 39], +{ + reveal_strlit("\"use strict\""); + reveal_strlit("'use strict'"); + assert("\"use strict\""@ =~= seq!['"', 'u', 's', 'e', ' ', 's', 't', 'r', 'i', 'c', 't', '"']); + assert("'use strict'"@ =~= seq!['\'', 'u', 's', 'e', ' ', 's', 't', 'r', 'i', 'c', 't', '\'']); +} + +/// The code points of `src` from `start` to `end` are `lit`. +fn range_is(src: &[u32], start: usize, end: usize, lit: &[u32]) -> (r: bool) + requires + start <= end, + end <= src.len(), + ensures + r == (src@.subrange(start as int, end as int) =~= lit@), +{ + if end.saturating_sub(start) != lit.len() { + return false; + } + let len = lit.len(); + let mut i: usize = 0; + while i < len + invariant + len == lit.len(), + len == end - start, + end <= src.len(), + start <= end, + i <= len, + forall|q: int| 0 <= q < i ==> src@[start as int + q] == lit@[q], + decreases len - i, + { + let (x, y) = match (src.get(start.saturating_add(i)), lit.get(i)) { + (Some(x), Some(y)) => (*x, *y), + _ => { + return false; + }, + }; + if x != y { + proof { + assert(src@.subrange(start as int, end as int)[i as int] == src@[start as int + i as int]); + } + return false; + } + i = i.saturating_add(1); + } + proof { + assert(src@.subrange(start as int, end as int) =~= lit@); + } + true +} + +/// No item of `ks` before `k` is a Use Strict Directive, they are all directives, and `k` +/// is not a directive or the end: the items have no Use Strict Directive. +proof fn lemma_no_use_strict(a: AstV, ts: Stream, ks: Seq, k: int) + requires + 0 <= k <= ks.len(), + forall|m: int| + 0 <= m < k ==> is_directive(a, #[trigger] ks[m]) && !is_use_strict_directive( + a, + ts, + ks[m], + ), + k == ks.len() || !is_directive(a, ks[k]), + ensures + !has_use_strict(a, ts, ks), +{ + assert forall|kk: int| + 0 <= kk < ks.len() implies !(is_use_strict_directive(a, ts, #[trigger] ks[kk]) && (forall|m: int| + 0 <= m <= kk ==> is_directive(a, #[trigger] ks[m]))) by { + if kk < k { + assert(!is_use_strict_directive(a, ts, ks[kk])); + } else { + assert(0 <= k <= kk); + assert(k < ks.len()); + assert(!is_directive(a, ks[k])); + } + } +} + +/// The items of node `b` have a Use Strict Directive (`has_use_strict`). +#[verifier::rlimit(400)] +pub fn use_strict_exec( + src: &[u32], + nodes: &[Node], + toks: &[DTok], + by_start: &[usize], + b: usize, + Ghost(ts): Ghost, +) -> (r: Option) + requires + b < nodes.len(), + ast_wf(arena_of(nodes@)), + toks_match(src@, toks@, ts), + starts_inc(ts), + ensures + match r { + Some(v) => v == has_use_strict(arena_of(nodes@), ts, kids(arena_of(nodes@), b as int)), + None => true, + }, +{ + let ghost a = arena_of(nodes@); + let nd = match nodes.get(b) { + Some(x) => x, + None => { + return None; + }, + }; + let len = nd.children.len(); + proof { + assert(a.nodes[b as int] == nodes@[b as int]@); + assert(nd == &nodes@[b as int]); + assert(a.nodes[b as int].children.len() == len); + lemma_use_strict_words(); + } + let ghost ks = a.nodes[b as int].children; + let mut k: usize = 0; + while k < len + invariant + k <= len, + len == nd.children.len(), + b < nodes.len(), + nd == &nodes@[b as int], + a == arena_of(nodes@), + ast_wf(a), + toks_match(src@, toks@, ts), + starts_inc(ts), + ks == a.nodes[b as int].children, + len == ks.len(), + forall|m: int| + 0 <= m < k ==> is_directive(a, #[trigger] ks[m]) && !is_use_strict_directive( + a, + ts, + ks[m], + ), + decreases len - k, + { + let c = match nd.children.as_slice().get(k) { + Some(c) => *c as usize, + None => { + return None; + }, + }; + proof { + assert(a.nodes[b as int].children[k as int] == c as int); + lemma_child_before(a, b as int, k as int); + } + let cnd = match nodes.get(c) { + Some(x) => x, + None => { + return None; + }, + }; + proof { + assert(a.nodes[c as int] == nodes@[c as int]@); + assert(cnd == &nodes@[c as int]); + } + let not_directive = if !matches!(cnd.kind, NodeKind::ExpressionStatement) { + true + } else { + match kid_kind(nodes, c, 0) { + Some(k0) => !matches!(k0, NodeKind::StringLiteral), + None => { + return None; + }, + } + }; + if not_directive { + proof { + assert(!is_directive(a, ks[k as int])); + lemma_no_use_strict(a, ts, ks, k as int); + } + return Some(false); + } + let e = match cnd.children.as_slice().get(ZERO) { + Some(e) => *e as usize, + None => { + return None; + }, + }; + proof { + assert(a.nodes[c as int].children[0] == e as int); + lemma_child_before(a, c as int, 0); + assert(is_directive(a, ks[k as int])); + } + let x = match node_token(nodes, toks, by_start, e) { + Some(x) => x, + None => { + return None; + }, + }; + let t = match toks.get(x) { + Some(t) => t, + None => { + return None; + }, + }; + proof { + assert(t == &toks@[x as int]); + assert(dtok_matches(src@, toks@[x as int], ts.toks[x as int])); + lemma_node_tok_at(a, ts, e as int, x as int); + } + let r1 = range_is(src, t.start, t.end, &[34, 117, 115, 101, 32, 115, 116, 114, 105, 99, 116, 34]); + let r2 = range_is(src, t.start, t.end, &[39, 117, 115, 101, 32, 115, 116, 114, 105, 99, 116, 39]); + proof { + let c_ = ks[k as int]; + assert(c_ == c as int); + assert(kids(a, c as int) == a.nodes[c as int].children); + assert(kid(kids(a, c_), 0) == e as int); + assert(node_tok(a, ts, e as int) == ts.toks[x as int]); + assert(ts.toks[x as int].text =~= src@.subrange(t.start as int, t.end as int)); + assert(is_directive(a, c_)); + lemma_use_strict_words(); + assert(r1 == (ts.toks[x as int].text =~= cps("\"use strict\""@))); + assert(r2 == (ts.toks[x as int].text =~= cps("'use strict'"@))); + assert(is_use_strict_directive(a, ts, c_) == (ts.toks[x as int].text =~= cps( + "\"use strict\""@, + ) || ts.toks[x as int].text =~= cps("'use strict'"@))); + } + if r1 || r2 { + proof { + assert(is_use_strict_directive(a, ts, ks[k as int])); + assert(0 <= k as int && (k as int) < ks.len() && is_use_strict_directive( + a, + ts, + #[trigger] ks[k as int], + ) && (forall|m: int| 0 <= m <= k as int ==> is_directive(a, #[trigger] ks[m]))); + assert(has_use_strict(a, ts, ks)); + } + return Some(true); + } + proof { + assert(!is_use_strict_directive(a, ts, ks[k as int])); + } + k = k.saturating_add(1); + } + proof { + lemma_no_use_strict(a, ts, ks, len as int); + } + Some(false) +} + +// --------------------------------------------------------------------- +// Parameters. +// --------------------------------------------------------------------- + +/// Each parameter of the `FormalParameters` node `p` is a plain `BindingIdentifier`, without an +/// initializer (`is_simple_params`). +pub fn simple_params_exec(nodes: &[Node], p: usize) -> (r: bool) + requires + p < nodes.len(), + ast_wf(arena_of(nodes@)), + ensures + r ==> is_simple_params(arena_of(nodes@), p as int), +{ + let ghost a = arena_of(nodes@); + let nd = match nodes.get(p) { + Some(x) => x, + None => { + return false; + }, + }; + let len = nd.children.len(); + proof { + assert(a.nodes[p as int] == nodes@[p as int]@); + assert(nd == &nodes@[p as int]); + assert(a.nodes[p as int].children.len() == len); + } + let mut k: usize = 0; + while k < len + invariant + k <= len, + len == nd.children.len(), + p < nodes.len(), + nd == &nodes@[p as int], + a == arena_of(nodes@), + ast_wf(a), + len == a.nodes[p as int].children.len(), + forall|q: int| + 0 <= q < k ==> { + let e = #[trigger] kids(a, p as int)[q]; + kd(a, e) == NodeKind::BindingElement && first_kid_kind(a, e) + == NodeKind::BindingIdentifier && kd(a, kid(kids(a, e), 1)) + == NodeKind::Absent + }, + decreases len - k, + { + let c = match nd.children.as_slice().get(k) { + Some(c) => *c as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[p as int].children[k as int] == c as int); + lemma_child_before(a, p as int, k as int); + assert(kids(a, p as int) == a.nodes[p as int].children); + } + let ck = match nodes.get(c) { + Some(x) => x.kind, + None => { + return false; + }, + }; + proof { + assert(a.nodes[c as int] == nodes@[c as int]@); + } + if !matches!(ck, NodeKind::BindingElement) { + return false; + } + match (kid_kind(nodes, c, 0), kid_kind(nodes, c, 1)) { + (Some(NodeKind::BindingIdentifier), Some(NodeKind::Absent)) => {}, + _ => { + return false; + }, + } + proof { + assert(kd(a, c as int) == NodeKind::BindingElement); + } + k = k.saturating_add(1); + } + true +} + +/// The names `xs` have no name twice. +pub fn no_dup_exec(toks: &[DTok], xs: &[usize]) -> (r: bool) + requires + idx_ok(toks@, xs@), + ensures + r ==> !has_duplicate(names_of(toks@, xs@)), +{ + let len = xs.len(); + let mut i: usize = 0; + while i < len + invariant + len == xs.len(), + i <= len, + idx_ok(toks@, xs@), + forall|x: int, y: int| + 0 <= x < i && x < y < len ==> !(names_of(toks@, xs@)[x] =~= names_of(toks@, xs@)[y]), + decreases len - i, + { + let ni = match xs.get(i) { + Some(x) => match toks.get(*x) { + Some(t) => t, + None => { + return false; + }, + }, + None => { + return false; + }, + }; + let mut j: usize = i.saturating_add(1); + while j < len + invariant + len == xs.len(), + i < len, + i < j, + j <= len, + idx_ok(toks@, xs@), + ni == &toks@[xs@[i as int] as int], + forall|x: int, y: int| + 0 <= x < i && x < y < len ==> !(names_of(toks@, xs@)[x] =~= names_of(toks@, xs@)[y]), + forall|y: int| i < y < j ==> !(names_of(toks@, xs@)[i as int] =~= names_of(toks@, xs@)[y]), + decreases len - j, + { + let nj = match xs.get(j) { + Some(x) => match toks.get(*x) { + Some(t) => t, + None => { + return false; + }, + }, + None => { + return false; + }, + }; + if seq_eq(ni.name.as_slice(), nj.name.as_slice()) { + return false; + } + j = j.saturating_add(1); + } + i = i.saturating_add(1); + } + proof { + assert forall|x: int, y: int| + 0 <= x < y < names_of(toks@, xs@).len() implies !(#[trigger] names_of(toks@, xs@)[x] + =~= #[trigger] names_of(toks@, xs@)[y]) by { + assert(x < len && y < len); + } + } + true +} + +/// `function_early` of the function-like production with the `FormalParameters` node `params` +/// and the body whose statements are the children of node `body` (none, for `None`), in code +/// that is strict if `env_strict` or if the body has a Use Strict Directive. +#[verifier::rlimit(400)] +pub fn function_early_exec( + tk: &Tk, + nodes: &[Node], + params: usize, + body: Option, + unique: bool, + env_strict: bool, + Ghost(ts): Ghost, +) -> (r: bool) + requires + params < nodes.len(), + match body { + Some(b) => b < nodes.len(), + None => true, + }, + ast_wf(arena_of(nodes@)), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + tk.bn.len() == nodes.len(), + bn_inv(arena_of(nodes@), ts, tk.toks@, tk.bn@, nodes.len() as int), + ensures + r ==> { + let a = arena_of(nodes@); + let body_ks = match body { + Some(b) => kids(a, b as int), + None => Seq::empty(), + }; + function_early(a, ts, params as int, body_ks, unique, env_strict || has_use_strict( + a, + ts, + body_ks, + )) + }, +{ + let src = tk.src; + let toks = tk.toks; + let by_start = tk.by_start; + let bn = tk.bn; + let ghost a = arena_of(nodes@); + let (hus, lex_empty) = match body { + Some(b) => { + let h = match use_strict_exec(src, nodes, toks, by_start, b, Ghost(ts)) { + Some(h) => h, + None => { + return false; + }, + }; + (h, items_lex_empty(nodes, b, true)) + }, + None => (false, true), + }; + if !lex_empty { + return false; + } + let simple = simple_params_exec(nodes, params); + if hus && !simple { + return false; + } + let names = match bn.get(params) { + Some(v) => v, + None => { + return false; + }, + }; + proof { + assert(bn@[params as int] == names); + assert(idx_ok(toks@, names@)); + } + let need_unique = env_strict || hus || unique || !simple; + let distinct = no_dup_exec(toks, names.as_slice()); + if need_unique && !distinct { + return false; + } + proof { + let body_ks = match body { + Some(b) => kids(a, b as int), + None => Seq::empty(), + }; + let nb = a.nodes.len() as int; + let strict = env_strict || has_use_strict(a, ts, body_ks); + assert(has_use_strict(a, ts, body_ks) == hus); + if let Some(b) = body { + lemma_lex_list_empty(a, ts, nb, body_ks, 0, true); + } + assert(lex_names_list(a, ts, nb, body_ks, 0, true) =~= Seq::::empty()); + assert(plain_names(lex_names_list(a, ts, nb, body_ks, 0, true)) =~= Seq::>::empty()); + let bnames = bound_names(a, ts, params as int); + assert(bnames =~= names_of(toks@, names@)); + assert(!intersects(bnames, plain_names(lex_names_list(a, ts, nb, body_ks, 0, true)))); + if strict || unique || !is_simple_params(a, params as int) { + if env_strict || hus || unique || !simple { + assert(!has_duplicate(names_of(toks@, names@))); + } else { + assert(simple); + assert(is_simple_params(a, params as int)); + } + } + } + true +} + +} // verus! diff --git a/crates/clazel-js-syntax/src/lib.rs b/crates/clazel-js-syntax/src/lib.rs index 789024a0..39ed3cab 100644 --- a/crates/clazel-js-syntax/src/lib.rs +++ b/crates/clazel-js-syntax/src/lib.rs @@ -63,6 +63,7 @@ pub mod api; pub mod arena_d; pub mod arena_e; pub mod arena_early; +pub mod arena_names; pub mod arena_m; pub mod ast; pub mod check; diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index 93f6f6e3..421c224b 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -336,6 +336,12 @@ fn covered_early_rules_are_verified() { "delete a.b; typeof a; void 0; a in b; a instanceof b;", "{ a; { b; } }", "var a; var a;", + "(function () {})", + "function f(a, [b], {c}, ...d) { return a; }", + "function f(a, a) { }", + "(a, b) => a + b;", + "function* g(x) { yield x; } async function h() { await 1; }", + "function f() { 'use strict'; return 1; }", "new.target", ] { let r = early(s); @@ -354,7 +360,6 @@ fn other_early_rules_are_unsupported_not_failed() { "'use strict'; a = 1;", "let a;", "a: b;", - "(function () {})", "class A {}", "for (a in b) ;", "/a/;", From bcf42d915a66a521b5456c5b7778f4b678d39ae4 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 16:19:10 +0000 Subject: [PATCH 024/195] clazel-js-syntax: proven early errors for scripts with a Use Strict Directive and object literals The root's strictness is the exact has_use_strict of its Directive Prologue; ObjectLiteral checks duplicate __proto__ entries and private-named methods. Early errors are verified for 1218 of 1567 script runs (was 591). Module roots and exports_early are not covered yet. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_early.rs | 83 +------- crates/clazel-js-syntax/src/arena_names.rs | 213 ++++++++++++++++++++ crates/clazel-js-syntax/tests/derivation.rs | 3 +- 3 files changed, 225 insertions(+), 74 deletions(-) diff --git a/crates/clazel-js-syntax/src/arena_early.rs b/crates/clazel-js-syntax/src/arena_early.rs index e9fce0b2..2f58b88e 100644 --- a/crates/clazel-js-syntax/src/arena_early.rs +++ b/crates/clazel-js-syntax/src/arena_early.rs @@ -1433,6 +1433,7 @@ fn early_local_exec( } ok }, + NodeKind::ObjectLiteral => object_literal_exec(tk, nodes, m, Ghost(ts)), NodeKind::FunctionBody => { let ok = items_lex_empty(nodes, m, true); proof { @@ -1506,72 +1507,6 @@ fn early_local_exec( } -/// The first statement of the root is not a directive: no Use Strict Directive. -proof fn lemma_no_directive(a: AstV, ts: Stream, ks: Seq) - requires - ks.len() == 0 || !is_directive(a, ks[0]), - ensures - !has_use_strict(a, ts, ks), -{ -} - -/// The root is not a Directive Prologue's: its first item is not a string literal statement. -fn root_has_no_directive(nodes: &[Node], root: usize) -> (r: bool) - requires - root < nodes.len(), - ast_wf(arena_of(nodes@)), - ensures - r ==> (arena_of(nodes@).nodes[root as int].children.len() == 0 || !is_directive( - arena_of(nodes@), - arena_of(nodes@).nodes[root as int].children[0], - )), -{ - let nd = match nodes.get(root) { - Some(x) => x, - None => { - return false; - }, - }; - if nd.children.is_empty() { - proof { - let a = arena_of(nodes@); - assert(a.nodes[root as int] == nodes@[root as int]@); - assert(nd == &nodes@[root as int]); - assert(a.nodes[root as int].children.len() == 0); - } - return true; - } - let k0 = match kid_kind(nodes, root, 0) { - Some(k) => k, - None => { - return false; - }, - }; - if !matches!(k0, NodeKind::ExpressionStatement) { - return true; - } - let c = match nd.children.as_slice().get(ZERO) { - Some(c) => *c as usize, - None => { - return false; - }, - }; - proof { - let a = arena_of(nodes@); - assert(a.nodes[root as int] == nodes@[root as int]@); - assert(nd == &nodes@[root as int]); - assert(a.nodes[root as int].children[0] == c as int); - lemma_child_before(a, root as int, 0); - } - if c >= root { - return false; - } - match kid_kind(nodes, c, 0) { - Some(k) => !matches!(k, NodeKind::StringLiteral), - None => false, - } -} - /// [`check_early`] on the canonical stream of the executable tokens and gaps /// ([`canon_stream`]), which needs no ghost argument. pub fn check_early_canon( @@ -1727,12 +1662,15 @@ pub fn check_early( }, }; let tk = Tk { src, toks, by_start: by_start.as_slice(), bn: bn.as_slice() }; - // The root's environment: a script without a Use Strict Directive. - if !root_has_no_directive(nodes, last) { - return Derivation::Unsupported; - } + // The root's environment: a script, strict if its Directive Prologue has a Use Strict Directive. + let root_strict = match use_strict_exec(src, nodes, toks, by_start.as_slice(), last, Ghost(ts)) { + Some(v) => v, + None => { + return Derivation::Unsupported; + }, + }; let root_e = EEnv { - strict: false, + strict: root_strict, module: false, yield_: false, await_: false, @@ -1930,8 +1868,7 @@ pub fn check_early( proof { let g = goal_of(module); assert(g == SourceGoal::Script); - lemma_no_directive(a, ts, a.nodes[a.root].children); - assert(!has_use_strict(a, ts, kids(a, a.root))); + assert(a.root == last as int); assert(root_env(a, ts, g) == eenv_of(root_e)); assert(a.root == last as int); assert(early(a, ts, a.root, eenv_of(envs@[a.root]))); diff --git a/crates/clazel-js-syntax/src/arena_names.rs b/crates/clazel-js-syntax/src/arena_names.rs index a9e8dedc..ad225722 100644 --- a/crates/clazel-js-syntax/src/arena_names.rs +++ b/crates/clazel-js-syntax/src/arena_names.rs @@ -968,4 +968,217 @@ pub fn function_early_exec( true } +// --------------------------------------------------------------------- +// Object literals. +// --------------------------------------------------------------------- + +/// `__proto__` as code points. +proof fn lemma_proto_word() + ensures + sv("__proto__"@) =~= seq![0x5Fu32, 0x5F, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x5F, 0x5F], +{ + reveal_strlit("__proto__"); + assert("__proto__"@ =~= seq!['_', '_', 'p', 'r', 'o', 't', 'o', '_', '_']); +} + +/// The property `c` is a `__proto__: value` entry (`is_proto_entry`). +#[verifier::rlimit(400)] +fn is_proto_exec(tk: &Tk, nodes: &[Node], c: usize, Ghost(ts): Ghost) -> (r: Option) + requires + c < nodes.len(), + ast_wf(arena_of(nodes@)), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + ensures + match r { + Some(v) => v == is_proto_entry(arena_of(nodes@), ts, c as int), + None => true, + }, +{ + let src = tk.src; + let toks = tk.toks; + let by_start = tk.by_start; + let _ = src.len(); + let ghost a = arena_of(nodes@); + let nd = match nodes.get(c) { + Some(x) => x, + None => { + return None; + }, + }; + proof { + assert(a.nodes[c as int] == nodes@[c as int]@); + assert(nd == &nodes@[c as int]); + assert(a.nodes[c as int].kind == nd.kind); + assert(a.nodes[c as int].op == nd.op); + assert(a.nodes[c as int].children.len() == nd.children.len()); + assert(kids(a, c as int) == a.nodes[c as int].children); + } + if !matches!(nd.kind, NodeKind::PropertyDefinition) || !matches!(nd.op, Op::KeyValue) { + return Some(false); + } + let key = match nd.children.as_slice().get(ZERO) { + Some(k) => *k as usize, + None => { + return Some(false); + }, + }; + proof { + assert(a.nodes[c as int].children[0] == key as int); + lemma_child_before(a, c as int, 0); + } + let kk = match nodes.get(key) { + Some(x) => x.kind, + None => { + return None; + }, + }; + proof { + assert(a.nodes[key as int] == nodes@[key as int]@); + assert(a.nodes[key as int].kind == kk); + } + if !matches!(kk, NodeKind::IdentifierName | NodeKind::StringLiteral) { + return Some(false); + } + let x = match node_token(nodes, toks, by_start, key) { + Some(x) => x, + None => { + return None; + }, + }; + let t = match toks.get(x) { + Some(t) => t, + None => { + return None; + }, + }; + proof { + assert(t == &toks@[x as int]); + assert(dtok_matches(src@, toks@[x as int], ts.toks[x as int])); + lemma_node_tok_at(a, ts, key as int, x as int); + lemma_proto_word(); + } + Some(seq_eq(t.name.as_slice(), &[0x5F, 0x5F, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x5F, 0x5F])) +} + +/// `early_local` of an `ObjectLiteral` node `m`: at most one `__proto__: v` entry, and no method +/// with a private name. +#[verifier::rlimit(400)] +pub fn object_literal_exec(tk: &Tk, nodes: &[Node], m: usize, Ghost(ts): Ghost) -> (r: bool) + requires + m < nodes.len(), + ast_wf(arena_of(nodes@)), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + ensures + r ==> { + let a = arena_of(nodes@); + let ks = a.nodes[m as int].children; + (!exists|x: int, y: int| + 0 <= x < y < ks.len() && is_proto_entry(a, ts, #[trigger] ks[x]) && is_proto_entry( + a, + ts, + #[trigger] ks[y], + )) && (forall|x: int| + 0 <= x < ks.len() ==> !(kd(a, #[trigger] ks[x]) == NodeKind::MethodDefinition && kd( + a, + kid(kids(a, ks[x]), 0), + ) == NodeKind::PrivateIdentifier)) + }, +{ + let ghost a = arena_of(nodes@); + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return false; + }, + }; + let len = nd.children.len(); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + } + let ghost ks = a.nodes[m as int].children; + let mut seen = false; + let mut k: usize = 0; + while k < len + invariant + k <= len, + len == nd.children.len(), + m < nodes.len(), + nd == &nodes@[m as int], + a == arena_of(nodes@), + ast_wf(a), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + ks == a.nodes[m as int].children, + len == ks.len(), + seen ==> exists|x: int| 0 <= x < k && is_proto_entry(a, ts, #[trigger] ks[x]), + !seen ==> forall|x: int| 0 <= x < k ==> !is_proto_entry(a, ts, #[trigger] ks[x]), + forall|x: int, y: int| + 0 <= x < y < k ==> !(is_proto_entry(a, ts, #[trigger] ks[x]) && is_proto_entry( + a, + ts, + #[trigger] ks[y], + )), + forall|x: int| + 0 <= x < k ==> !(kd(a, #[trigger] ks[x]) == NodeKind::MethodDefinition && kd( + a, + kid(kids(a, ks[x]), 0), + ) == NodeKind::PrivateIdentifier), + decreases len - k, + { + let c = match nd.children.as_slice().get(k) { + Some(c) => *c as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[k as int] == c as int); + lemma_child_before(a, m as int, k as int); + } + let is_p = match is_proto_exec(tk, nodes, c, Ghost(ts)) { + Some(v) => v, + None => { + return false; + }, + }; + if is_p && seen { + return false; + } + let ck = match nodes.get(c) { + Some(x) => x.kind, + None => { + return false; + }, + }; + proof { + assert(a.nodes[c as int] == nodes@[c as int]@); + assert(a.nodes[c as int].kind == ck); + } + if matches!(ck, NodeKind::MethodDefinition) { + match kid_kind(nodes, c, 0) { + Some(NodeKind::PrivateIdentifier) => { + return false; + }, + Some(_) => {}, + None => { + return false; + }, + } + } + proof { + assert(kids(a, c as int) == a.nodes[c as int].children); + assert(ks[k as int] == c as int); + } + if is_p { + seen = true; + } + k = k.saturating_add(1); + } + true +} + } // verus! diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index 421c224b..27a620d1 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -336,6 +336,8 @@ fn covered_early_rules_are_verified() { "delete a.b; typeof a; void 0; a in b; a instanceof b;", "{ a; { b; } }", "var a; var a;", + "'use strict'; a = 1;", + "x = { m(a) { return a; }, get g() { return 1; }, __proto__: null, ['__proto__']: 1 };", "(function () {})", "function f(a, [b], {c}, ...d) { return a; }", "function f(a, a) { }", @@ -357,7 +359,6 @@ fn covered_early_rules_are_verified() { #[test] fn other_early_rules_are_unsupported_not_failed() { for s in [ - "'use strict'; a = 1;", "let a;", "a: b;", "class A {}", From 9e3b25bf82a9a16fb6cfa39611dfaaeaf80b4f59 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 16:44:17 +0000 Subject: [PATCH 025/195] clazel-jit: x86-64 templates for straight-line integer LIR, proven; emitter; validator test Templates for nop, drop, const, local.get/set/tee, select, the i32 and i64 add, sub, mul, and, or, xor, shl, shr_s, shr_u and ten comparisons, eqz, wrap, extend_s, extend_u, f64 neg and abs, and the reinterprets. Each refines clazel-lir's eval under clazel-x64's step (lemma_op_refines); a straight-line program refines the then-chain (lemma_prog_refines); the exit sequence refines exit (lemma_exit_refines). The emitter (emit.rs) returns the template code and its encoding, proven. tests/validator.rs runs clazel-codecheck's validator on every template and 3000 generated programs. spec.rs: op_ok now also requires nl + h <= 31 (the frame holds the current stack), which prog_ok already ensured; it only moves a hypothesis the proofs need into the per-instruction predicate. Not done: memory instructions, structured control flow, exit with operands, f64 arithmetic, rotates, a frame beyond 31 slots. Tier stays 0. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-jit/mutations.json | 44 + crates/clazel-jit/src/agree.rs | 188 ++++ crates/clazel-jit/src/alu.rs | 442 ++++++++ crates/clazel-jit/src/compose.rs | 152 +++ crates/clazel-jit/src/emit.rs | 786 ++++++++++++++ crates/clazel-jit/src/exit.rs | 218 ++++ crates/clazel-jit/src/flags.rs | 782 ++++++++++++++ crates/clazel-jit/src/lib.rs | 74 +- crates/clazel-jit/src/memlemmas.rs | 178 ++++ crates/clazel-jit/src/mid.rs | 531 ++++++++++ crates/clazel-jit/src/proofs.rs | 1407 ++++++++++++++++++++++++++ crates/clazel-jit/src/rel.rs | 229 +++++ crates/clazel-jit/src/runseq.rs | 353 +++++++ crates/clazel-jit/src/skel.rs | 209 ++++ crates/clazel-jit/src/spec.rs | 7 +- crates/clazel-jit/src/steps.rs | 199 ++++ crates/clazel-jit/src/templates.rs | 277 +++++ crates/clazel-jit/src/tlemmas.rs | 353 +++++++ crates/clazel-jit/tests/validator.rs | 388 +++++++ 19 files changed, 6809 insertions(+), 8 deletions(-) create mode 100644 crates/clazel-jit/mutations.json create mode 100644 crates/clazel-jit/src/agree.rs create mode 100644 crates/clazel-jit/src/alu.rs create mode 100644 crates/clazel-jit/src/compose.rs create mode 100644 crates/clazel-jit/src/emit.rs create mode 100644 crates/clazel-jit/src/exit.rs create mode 100644 crates/clazel-jit/src/flags.rs create mode 100644 crates/clazel-jit/src/memlemmas.rs create mode 100644 crates/clazel-jit/src/mid.rs create mode 100644 crates/clazel-jit/src/proofs.rs create mode 100644 crates/clazel-jit/src/rel.rs create mode 100644 crates/clazel-jit/src/runseq.rs create mode 100644 crates/clazel-jit/src/skel.rs create mode 100644 crates/clazel-jit/src/steps.rs create mode 100644 crates/clazel-jit/src/templates.rs create mode 100644 crates/clazel-jit/src/tlemmas.rs create mode 100644 crates/clazel-jit/tests/validator.rs diff --git a/crates/clazel-jit/mutations.json b/crates/clazel-jit/mutations.json new file mode 100644 index 00000000..123ff746 --- /dev/null +++ b/crates/clazel-jit/mutations.json @@ -0,0 +1,44 @@ +{ + "mutations": [ + { + "id": "setcc-less-than-uses-wrong-condition", + "file": "src/templates.rs", + "find": "lir::ICmp::LtS => 12,", + "replace": "lir::ICmp::LtS => 13,", + "expect": "killed-incidentally", + "reason": "The signed less-than comparison would read condition code 13 (`ge`) instead of 12 (`l`). The refinement of the comparison template fails (`flags::lemma_cc_icmp`, then `mid::lemma_mid_cmp`), because the code would compute the opposite of LIR's `lt_s`. It is not labelled `killed`: that needs a certificate, a concrete witness evaluated with `compute_only`, and the refinement statement is quantified over states, which `compute_only` cannot evaluate. So this claims no coverage, though the proof does catch the bug." + }, + { + "id": "select-takes-the-wrong-arm", + "file": "src/templates.rs", + "find": "x64::Instr::Cmovcc { cc: 4, sz: x64::Size::W64, dst: rax(), src: rcx() },", + "replace": "x64::Instr::Cmovcc { cc: 5, sz: x64::Size::W64, dst: rax(), src: rcx() },", + "expect": "killed-incidentally", + "reason": "`select` would take its second value when the condition is nonzero (`cmovne` for `cmove`). `mid::lemma_mid_select` fails, and with it the refinement of `select`. No certificate, for the reason of the first mutation, so no coverage is claimed." + }, + { + "id": "frame-overlaps-the-exit-code-word", + "file": "src/spec.rs", + "find": " abi::exit_code_off() + 8\n}", + "replace": " abi::exit_code_off()\n}", + "expect": "killed-incidentally", + "reason": "Frame slot 0 would be the exit-code word, so an exit sequence would overwrite a local. `steps::lemma_abi_consts` (which pins the frame to bytes 264 and up, and 31 slots) fails, and so do the proofs that rest on it. No certificate: the theorem that fails is about the constants, and `compute_only` would need a witness that is itself the mutated constant; no coverage is claimed." + }, + { + "id": "regions-may-overlap-the-frame", + "file": "src/spec.rs", + "find": " forall|a: nat| #[trigger] in_regions(lay, a) ==> !in_exit_area(ctxb, a as int)", + "replace": " true", + "expect": "killed-incidentally", + "reason": "A region may then overlap the context's exit area, where the frame is, so a store to a slot could change a byte LIR's memory holds. `rel::lemma_store_finish` fails (it needs the region bytes outside the exit area to be unchanged by the store). No certificate (the statement is quantified), so no coverage is claimed." + }, + { + "id": "preserved-forgets-the-stack-pointer", + "file": "src/spec.rs", + "find": " preserved_mem(m, m2) && m2.rgf[abi::sp_reg() as int] == m.rgf[abi::sp_reg() as int]\n}", + "replace": " preserved_mem(m, m2)\n}", + "expect": "survives", + "reason": "Drops the claim that a template leaves `rsp` as it was. The clause is a claim the real proofs establish (from `mid_post`'s preservation of `rsp`), but nothing downstream uses it: the templates never name `rsp` (`scratch` excludes it), and the exit sequence's `ret`, the one instruction that changes it, is stated by `exit_refines` against `preserved_mem` and its own statement of the new `rsp`. So removing the clause breaks no proof: a known gap in how much the proofs depend on it. Closing it needs a consumer, for example the validator's confinement theorem (jit.md exit criterion 2), which assumes `rsp` is never written by the code between exits." + } + ] +} diff --git a/crates/clazel-jit/src/agree.rs b/crates/clazel-jit/src/agree.rs new file mode 100644 index 00000000..5b66bddf --- /dev/null +++ b/crates/clazel-jit/src/agree.rs @@ -0,0 +1,188 @@ +//! How the LIR states before and after an instruction relate slot by slot +//! ([`slots_agree_except`], [`slots_agree`]), for each way an instruction +//! changes the locals and the operand stack: push a value, replace the top +//! `k` values by one, drop the top, set a local. They are what the template +//! proofs feed to the skeleton. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// Pushing `v`: the new top slot (`nl + h`) is the only slot that changes, and +/// it holds `v`'s word. +pub proof fn lemma_agree_push(a: lir::St, a2: lir::St, nl: nat, h: nat, v: lir::Val) + requires + a.stack.len() == h, + a.locals.len() == nl, + nl + h + 1 <= max_slots(), + a2 == a.with_stack(a.stack.push(v)), + ensures + super::rel::slots_agree_except(a, a2, nl, nl + h), + lir::val_bits(slot_val(a2, nl, nl + h)) == lir::val_bits(v), +{ + assert(a2.stack.len() == h + 1); + assert forall|j: nat| j < nl + a2.stack.len() && j != nl + h implies j < nl + a.stack.len() + && lir::val_bits(#[trigger] slot_val(a2, nl, j)) == lir::val_bits(slot_val(a, nl, j)) by { + if j >= nl { + assert(a2.stack[(j - nl) as int] == a.stack[(j - nl) as int]); + } + } + assert(a2.stack[h as int] == v); +} + +/// Replacing the top `k` values by one value `v`: the slot `nl + h - k` is the +/// only one that changes, and it holds `v`'s word. +pub proof fn lemma_agree_replace( + a: lir::St, + a2: lir::St, + nl: nat, + h: nat, + k: nat, + v: lir::Val, +) + requires + a.stack.len() == h, + a.locals.len() == nl, + 1 <= k <= h, + nl + (h - k) + 1 <= max_slots(), + a2 == a.with_stack(lir::below(a.stack, k).push(v)), + ensures + super::rel::slots_agree_except(a, a2, nl, (nl + h - k) as nat), + lir::val_bits(slot_val(a2, nl, (nl + h - k) as nat)) == lir::val_bits(v), +{ + let hk = (h - k) as nat; + assert(a2.stack.len() == hk + 1); + assert(lir::below(a.stack, k) =~= a.stack.take(hk as int)); + assert forall|j: nat| + j < nl + a2.stack.len() && j != (nl + h - k) as nat implies j < nl + a.stack.len() + && lir::val_bits(#[trigger] slot_val(a2, nl, j)) == lir::val_bits(slot_val(a, nl, j)) by { + if j >= nl { + assert(a2.stack[(j - nl) as int] == a.stack[(j - nl) as int]); + } + } + assert(a2.stack[hk as int] == v); +} + +/// Dropping the top value, or any change to the stack that keeps a prefix: +/// every slot of `a2` is a slot of `a`. +pub proof fn lemma_agree_drop(a: lir::St, a2: lir::St, nl: nat, h: nat) + requires + a.stack.len() == h, + a.locals.len() == nl, + 1 <= h, + nl + h <= max_slots(), + a2 == a.with_stack(a.stack.drop_last()), + ensures + super::rel::slots_agree(a, a2, nl), +{ + assert forall|j: nat| j < nl + a2.stack.len() implies j < nl + a.stack.len() && lir::val_bits( + #[trigger] slot_val(a2, nl, j), + ) == lir::val_bits(slot_val(a, nl, j)) by { + if j >= nl { + assert(a2.stack[(j - nl) as int] == a.stack[(j - nl) as int]); + } + } +} + +/// `local.set x`: the stack loses its top, local `x` takes its value. The only +/// slot that changes is `x`. +pub proof fn lemma_agree_set(a: lir::St, a2: lir::St, nl: nat, h: nat, x: nat) + requires + a.stack.len() == h, + a.locals.len() == nl, + 1 <= h, + x < nl, + nl + h <= max_slots(), + a2 == (lir::St { + stack: a.stack.drop_last(), + locals: a.locals.update(x as int, a.stack.last()), + mem: a.mem, + }), + ensures + super::rel::slots_agree_except(a, a2, nl, x), + lir::val_bits(slot_val(a2, nl, x)) == lir::val_bits(slot_val(a, nl, (nl + h - 1) as nat)), +{ + assert forall|j: nat| j < nl + a2.stack.len() && j != x implies j < nl + a.stack.len() + && lir::val_bits(#[trigger] slot_val(a2, nl, j)) == lir::val_bits(slot_val(a, nl, j)) by { + if j >= nl { + assert(a2.stack[(j - nl) as int] == a.stack[(j - nl) as int]); + } else { + assert(a2.locals[j as int] == a.locals[j as int]); + } + } + assert(a.stack.last() == a.stack[h - 1]); +} + +/// `local.tee x`: the stack is unchanged, local `x` takes the top's value. +pub proof fn lemma_agree_tee(a: lir::St, a2: lir::St, nl: nat, h: nat, x: nat) + requires + a.stack.len() == h, + a.locals.len() == nl, + 1 <= h, + x < nl, + nl + h <= max_slots(), + a2 == a.with_locals(a.locals.update(x as int, a.stack.last())), + ensures + super::rel::slots_agree_except(a, a2, nl, x), + lir::val_bits(slot_val(a2, nl, x)) == lir::val_bits(slot_val(a, nl, (nl + h - 1) as nat)), +{ + assert forall|j: nat| j < nl + a2.stack.len() && j != x implies j < nl + a.stack.len() + && lir::val_bits(#[trigger] slot_val(a2, nl, j)) == lir::val_bits(slot_val(a, nl, j)) by { + if j < nl { + assert(a2.locals[j as int] == a.locals[j as int]); + } + } + assert(a.stack.last() == a.stack[h - 1]); +} + +/// Replacing the top by a value with the same word changes no slot's word. +pub proof fn lemma_agree_same_word(a: lir::St, a2: lir::St, nl: nat, h: nat, v: lir::Val) + requires + a.stack.len() == h, + a.locals.len() == nl, + 1 <= h, + nl + h <= max_slots(), + lir::val_bits(v) == lir::val_bits(a.stack.last()), + a2 == a.with_stack(lir::below(a.stack, 1).push(v)), + ensures + super::rel::slots_agree(a, a2, nl), +{ + assert(lir::below(a.stack, 1) =~= a.stack.take((h - 1) as int)); + assert(a2.stack.len() == h); + assert forall|j: nat| j < nl + a2.stack.len() implies j < nl + a.stack.len() && lir::val_bits( + #[trigger] slot_val(a2, nl, j), + ) == lir::val_bits(slot_val(a, nl, j)) by { + if j >= nl { + if j - nl == h - 1 { + assert(a2.stack[(h - 1) as int] == v); + assert(a.stack.last() == a.stack[(h - 1) as int]); + } else { + assert(a2.stack[(j - nl) as int] == a.stack[(j - nl) as int]); + } + } + } +} + +/// A state is related to itself, to the same machine state: no change. +pub proof fn lemma_agree_refl(a: lir::St, nl: nat) + requires + a.locals.len() == nl, + nl + a.stack.len() <= max_slots(), + ensures + super::rel::slots_agree(a, a, nl), +{ +} + +/// `preserved` holds between a machine state and itself. +pub proof fn lemma_preserved_refl(m: x64::State) + requires + m.rgf.len() == 16, + ensures + preserved(m, m), +{ +} + +} // verus! diff --git a/crates/clazel-jit/src/alu.rs b/crates/clazel-jit/src/alu.rs new file mode 100644 index 00000000..f0c2864a --- /dev/null +++ b/crates/clazel-jit/src/alu.rs @@ -0,0 +1,442 @@ +//! The arithmetic, logic, shift and multiply instructions of the integer +//! templates: what `x64::step` does to the register file, and that the word +//! it leaves in `rax` is the result LIR's operator defines +//! (`lir::ibin32`, `lir::ibin64`). +//! +//! The results are statements about *values*: the 32-bit forms are given +//! zero-extended words (`x as u64`), and they leave a zero-extended word. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// What a register-only stretch of a template does, as far as the template's +/// other steps are concerned: `m1` is `m` with scratch registers changed +/// (`rd` now holds the word `w`), the same memory, the context register and +/// stack pointer as they were, `rip` moved on by `len`, and still a state +/// with 16 general and 16 XMM registers. +pub open spec fn mid_post(m: x64::State, m1: x64::State, rd: u8, w: nat, len: nat) -> bool { + m1.rgf.len() == 16 && m1.xmm.len() == 16 && m1.rgf[rd as int] as nat == w && m1.rgf[15] + == m.rgf[15] && m1.rgf[4] == m.rgf[4] && m1.mem == m.mem && m1.rip == m.rip + len +} + +/// `write_user_rflags` changes only the flags and the undefined-value seed. +pub proof fn lemma_wur_frame(cu: spec_fn(nat) -> nat, s: x64::State, vec: u32, mask: u32) + ensures + ({ + let t = x64::write_user_rflags(cu, s, vec, mask); + t.rgf == s.rgf && t.mem == s.mem && t.xmm == s.xmm && t.rip == s.rip + }), +{ +} + +/// A two-operand arithmetic or logic instruction (not `cmp`) writes the +/// destination register with the result of the operation, changes the flags, +/// and nothing else. +pub proof fn lemma_step_alu_rr( + cu: spec_fn(nat) -> nat, + m: x64::State, + alu: x64::AluOp, + sz: x64::Size, + dst: u8, + src: u8, +) + requires + x64::wf(m), + dst < 16, + src < 16, + !(alu is Cmp), + x64::canonical( + m.rip + x64::instr_len(x64::Instr::AluRR { alu: alu, sz: sz, dst: dst, src: src }), + ), + ensures + x64::step(cu, m, x64::Instr::AluRR { alu: alu, sz: sz, dst: dst, src: src }) is Some, + ({ + let m1 = x64::step( + cu, + m, + x64::Instr::AluRR { alu: alu, sz: sz, dst: dst, src: src }, + ).unwrap(); + let r = x64::gpr_arith_logic_spec( + x64::nbits(sz), + alu, + x64::rgfi_size(m, sz, dst), + x64::rgfi_size(m, sz, src), + m.rflags, + ); + m1.rgf == x64::set_rgfi_size(m, sz, dst, r.result).rgf && m1.mem == m.mem && m1.xmm + == m.xmm && m1.rip == m.rip + x64::instr_len( + x64::Instr::AluRR { alu: alu, sz: sz, dst: dst, src: src }, + ) + }), +{ + let i = x64::Instr::AluRR { alu: alu, sz: sz, dst: dst, src: src }; + let r = x64::gpr_arith_logic_spec( + x64::nbits(sz), + alu, + x64::rgfi_size(m, sz, dst), + x64::rgfi_size(m, sz, src), + m.rflags, + ); + let s1 = x64::set_rgfi_size(m, sz, dst, r.result); + lemma_wur_frame(cu, s1, r.rflags, r.undef); +} + +/// `imul dst, src` writes the destination register and the flags. +pub proof fn lemma_step_imul_rr( + cu: spec_fn(nat) -> nat, + m: x64::State, + sz: x64::Size, + dst: u8, + src: u8, +) + requires + x64::wf(m), + dst < 16, + src < 16, + x64::canonical( + m.rip + x64::instr_len(x64::Instr::ImulRR { sz: sz, dst: dst, src: src }), + ), + ensures + x64::step(cu, m, x64::Instr::ImulRR { sz: sz, dst: dst, src: src }) is Some, + ({ + let m1 = x64::step(cu, m, x64::Instr::ImulRR { sz: sz, dst: dst, src: src }).unwrap(); + let (low, cf) = x64::imul_spec( + x64::nbits(sz), + x64::rgfi_size(m, sz, src), + x64::rgfi_size(m, sz, dst), + ); + m1.rgf == x64::set_rgfi_size(m, sz, dst, low).rgf && m1.mem == m.mem && m1.xmm + == m.xmm && m1.rip == m.rip + x64::instr_len( + x64::Instr::ImulRR { sz: sz, dst: dst, src: src }, + ) + }), +{ + let (low, cf) = x64::imul_spec( + x64::nbits(sz), + x64::rgfi_size(m, sz, src), + x64::rgfi_size(m, sz, dst), + ); + let s1 = x64::set_rgfi_size(m, sz, dst, low); + // imul_flags is write_user_rflags on s1 + lemma_wur_frame( + cu, + s1, + x64::change_rflags( + m.rflags, + x64::FlagUpd { + cf: Some(cf), + pf: None, + af: None, + zf: None, + sf: None, + of: Some(cf), + }, + ), + x64::mask_pf() | x64::mask_af() | x64::mask_zf() | x64::mask_sf(), + ); +} + +/// `shl/shr/sar r, cl` writes the register and the flags. +pub proof fn lemma_step_shift_cl( + cu: spec_fn(nat) -> nat, + m: x64::State, + sh: x64::ShiftOp, + sz: x64::Size, + r: u8, +) + requires + x64::wf(m), + r < 16, + x64::canonical(m.rip + x64::instr_len(x64::Instr::ShiftCl { shift: sh, sz: sz, r: r })), + ensures + x64::step(cu, m, x64::Instr::ShiftCl { shift: sh, sz: sz, r: r }) is Some, + ({ + let m1 = x64::step(cu, m, x64::Instr::ShiftCl { shift: sh, sz: sz, r: r }).unwrap(); + let cnt = x64::shift_count(sz, x64::loghead(8, x64::rr64(m, 1))); + let o = x64::shift_spec(sh, x64::nbits(sz), x64::rgfi_size(m, sz, r), cnt, m.rflags); + m1.rgf == x64::set_rgfi_size(m, sz, r, o.result).rgf && m1.mem == m.mem && m1.xmm + == m.xmm && m1.rip == m.rip + x64::instr_len( + x64::Instr::ShiftCl { shift: sh, sz: sz, r: r }, + ) + }), +{ + let cnt = x64::shift_count(sz, x64::loghead(8, x64::rr64(m, 1))); + let o = x64::shift_spec(sh, x64::nbits(sz), x64::rgfi_size(m, sz, r), cnt, m.rflags); + let s1 = x64::write_user_rflags(cu, m, o.rflags, o.undef); + lemma_wur_frame(cu, m, o.rflags, o.undef); + let s2 = x64::set_rgfi_size(s1, sz, r, o.result); + assert(s1.rgf == m.rgf); + assert(x64::set_rgfi_size(s1, sz, r, o.result).rgf == x64::set_rgfi_size( + m, + sz, + r, + o.result, + ).rgf); +} + +// ---------------------------------------------------------------------------- +// Values: 32-bit +// ---------------------------------------------------------------------------- + +/// `add`, `sub`, `and`, `or`, `xor` on 32-bit operands compute LIR's result. +pub proof fn lemma_val32_alu(o: lir::IBin, x: u32, y: u32, fl: u32) + requires + super::templates::alu_of(o) is Some, + ensures + x64::gpr_arith_logic_spec(32, super::templates::alu_of(o).unwrap(), x as int, y as int, fl).result + == lir::ibin32(o, x, y) as int, +{ + super::memlemmas::lemma_p2_consts(); + vstd::arithmetic::power2::lemma2_to64(); + assert(x64::loghead(32, x as int) == x as int); + assert(x64::loghead(32, y as int) == y as int); + match o { + lir::IBin::Add => { + assert(lir::ibin32(o, x, y) as int == (x as int + y as int) % 0x1_0000_0000); + }, + lir::IBin::Sub => { + assert(lir::ibin32(o, x, y) as int == (x as int - y as int) % 0x1_0000_0000); + let a = x64::logext(32, x as int); + let b = x64::logext(32, y as int); + assert((a - b) % 0x1_0000_0000 == (x as int - y as int) % 0x1_0000_0000); + }, + lir::IBin::And => { + assert((x as u64) & (y as u64) == (x & y) as u64) by (bit_vector); + }, + lir::IBin::Or => { + assert((x as u64) | (y as u64) == (x | y) as u64) by (bit_vector); + }, + lir::IBin::Xor => { + assert((x as u64) ^ (y as u64) == (x ^ y) as u64) by (bit_vector); + }, + _ => {}, + } +} + +/// `add`, `sub`, `and`, `or`, `xor` on 64-bit operands compute LIR's result. +pub proof fn lemma_val64_alu(o: lir::IBin, x: u64, y: u64, fl: u32) + requires + super::templates::alu_of(o) is Some, + ensures + x64::gpr_arith_logic_spec(64, super::templates::alu_of(o).unwrap(), x as int, y as int, fl).result + == lir::ibin64(o, x, y) as int, +{ + super::memlemmas::lemma_p2_consts(); + vstd::arithmetic::power2::lemma2_to64(); + assert(x64::loghead(64, x as int) == x as int); + assert(x64::loghead(64, y as int) == y as int); + match o { + lir::IBin::Add => { + assert(lir::ibin64(o, x, y) as int == (x as int + y as int) % 0x1_0000_0000_0000_0000); + }, + lir::IBin::Sub => { + assert(lir::ibin64(o, x, y) as int == (x as int - y as int) + % 0x1_0000_0000_0000_0000); + let a = x64::logext(64, x as int); + let b = x64::logext(64, y as int); + assert((a - b) % 0x1_0000_0000_0000_0000 == (x as int - y as int) + % 0x1_0000_0000_0000_0000); + }, + lir::IBin::And => { + assert((x as u64) & (y as u64) == (x & y) as u64) by (bit_vector); + }, + lir::IBin::Or => { + assert((x as u64) | (y as u64) == (x | y) as u64) by (bit_vector); + }, + lir::IBin::Xor => { + assert((x as u64) ^ (y as u64) == (x ^ y) as u64) by (bit_vector); + }, + _ => {}, + } +} + +/// `imul` on 32-bit operands is LIR's `mul`: the low 32 bits of the product. +pub proof fn lemma_val32_mul(x: u32, y: u32) + ensures + x64::imul_spec(32, y as int, x as int).0 == lir::ibin32(lir::IBin::Mul, x, y) as int, +{ + super::memlemmas::lemma_p2_consts(); + vstd::arithmetic::power2::lemma2_to64(); + let m: int = 0x1_0000_0000; + let a = x64::logext(32, x as int); + let b = x64::logext(32, y as int); + assert(x64::loghead(32, x as int) == x as int); + assert(x64::loghead(32, y as int) == y as int); + assert(a % m == x as int % m); + assert(b % m == y as int % m); + vstd::arithmetic::div_mod::lemma_mul_mod_noop(a, b, m); + vstd::arithmetic::div_mod::lemma_mul_mod_noop(x as int, y as int, m); + vstd::arithmetic::div_mod::lemma_mod_mod(a * b, m, m); + assert(x64::p2(64) == m * m); + assert(lir::ibin32(lir::IBin::Mul, x, y) as int == (x as int * y as int) % m); +} + +/// `imul` on 64-bit operands is LIR's `mul`: the low 64 bits of the product. +pub proof fn lemma_val64_mul(x: u64, y: u64) + ensures + x64::imul_spec(64, y as int, x as int).0 == lir::ibin64(lir::IBin::Mul, x, y) as int, +{ + super::memlemmas::lemma_p2_consts(); + let m: int = 0x1_0000_0000_0000_0000; + let a = x64::logext(64, x as int); + let b = x64::logext(64, y as int); + assert(x64::loghead(64, x as int) == x as int); + assert(x64::loghead(64, y as int) == y as int); + assert(a % m == x as int % m); + assert(b % m == y as int % m); + vstd::arithmetic::div_mod::lemma_mul_mod_noop(a, b, m); + vstd::arithmetic::div_mod::lemma_mul_mod_noop(x as int, y as int, m); + vstd::arithmetic::power2::lemma_pow2_adds(64, 64); + vstd::arithmetic::power2::lemma2_to64(); + assert(x64::p2(128) == m * m); + vstd::arithmetic::div_mod::lemma_mod_mod(a * b, m, m); + assert(lir::ibin64(lir::IBin::Mul, x, y) as int == (x as int * y as int) % m); +} + +/// `shl`, `shr` and `sar` by `cl` on 32-bit operands compute LIR's shift: the +/// count is the low bits of `cl`, which is the count modulo the width. +pub proof fn lemma_val32_shift(o: lir::IBin, x: u32, y: u32, fl: u32) + requires + super::templates::shift_of(o) is Some, + ensures + ({ + let cnt = x64::shift_count( + x64::Size::W32, + x64::loghead(8, y as int), + ); + x64::shift_spec(super::templates::shift_of(o).unwrap(), 32, x as int, cnt, fl).result == lir::ibin32(o, x, y) as int + }), +{ + super::memlemmas::lemma_p2_consts(); + vstd::arithmetic::power2::lemma2_to64(); + assert(x64::p2(5) == 32 && x64::p2(6) == 64 && x64::p2(8) == 256); + let yi = y as int; + let cnt = x64::shift_count(x64::Size::W32, x64::loghead(8, yi)); + let k: nat = (yi % 32) as nat; + assert(cnt == yi % 32); + assert(x64::loghead(32, x as int) == x as int); + assert(x64::loghead(6, cnt) == cnt); + assert(cnt == k as int); + let p = x64::p2(k); + vstd::arithmetic::power2::lemma_pow2_pos(k); + assert(p == lir::pow2(k) as int); + assert(p > 0); + match o { + lir::IBin::Shl => { + assert(lir::ibin32(o, x, y) as int == (x as int * p) % 0x1_0000_0000); + }, + lir::IBin::ShrU => { + assert(x as int / p <= x as int) by (nonlinear_arith) + requires + p >= 1, + x as int >= 0, + ; + assert(0 <= x as int / p) by (nonlinear_arith) + requires + p >= 1, + x as int >= 0, + ; + assert(lir::ibin32(o, x, y) as int == x as int / p); + }, + lir::IBin::ShrS => { + let sg = lir::signed_of(32, x as int); + assert(x64::bit(x as int, 31) == (x as int / 0x8000_0000) % 2); + if x as int >= 0x8000_0000 { + assert(x64::logext(32, x as int) == x as int - 0x1_0000_0000); + assert(sg == x as int - 0x1_0000_0000); + } else { + assert(x64::logext(32, x as int) == x as int); + assert(sg == x as int); + assert(x as int / p <= x as int) by (nonlinear_arith) + requires + p >= 1, + x as int >= 0, + ; + assert(0 <= x as int / p) by (nonlinear_arith) + requires + p >= 1, + x as int >= 0, + ; + } + assert(lir::ibin32(o, x, y) as int == (sg / p) % 0x1_0000_0000); + }, + _ => {}, + } +} + +/// `shl`, `shr` and `sar` by `cl` on 64-bit operands compute LIR's shift: the +/// count is the low bits of `cl`, which is the count modulo the width. +pub proof fn lemma_val64_shift(o: lir::IBin, x: u64, y: u64, fl: u32) + requires + super::templates::shift_of(o) is Some, + ensures + ({ + let cnt = x64::shift_count( + x64::Size::W64, + x64::loghead(8, y as int), + ); + x64::shift_spec(super::templates::shift_of(o).unwrap(), 64, x as int, cnt, fl).result == lir::ibin64(o, x, y) as int + }), +{ + super::memlemmas::lemma_p2_consts(); + vstd::arithmetic::power2::lemma2_to64(); + assert(x64::p2(5) == 32 && x64::p2(6) == 64 && x64::p2(8) == 256); + let yi = y as int; + let cnt = x64::shift_count(x64::Size::W64, x64::loghead(8, yi)); + let k: nat = (yi % 64) as nat; + assert(cnt == yi % 64); + assert(x64::loghead(64, x as int) == x as int); + assert(x64::loghead(6, cnt) == cnt); + assert(cnt == k as int); + let p = x64::p2(k); + vstd::arithmetic::power2::lemma_pow2_pos(k); + assert(p == lir::pow2(k) as int); + assert(p > 0); + match o { + lir::IBin::Shl => { + assert(lir::ibin64(o, x, y) as int == (x as int * p) % 0x1_0000_0000_0000_0000); + }, + lir::IBin::ShrU => { + assert(x as int / p <= x as int) by (nonlinear_arith) + requires + p >= 1, + x as int >= 0, + ; + assert(0 <= x as int / p) by (nonlinear_arith) + requires + p >= 1, + x as int >= 0, + ; + assert(lir::ibin64(o, x, y) as int == x as int / p); + }, + lir::IBin::ShrS => { + let sg = lir::signed_of(64, x as int); + assert(x64::bit(x as int, 63) == (x as int / 0x8000_0000_0000_0000) % 2); + if x as int >= 0x8000_0000_0000_0000 { + assert(x64::logext(64, x as int) == x as int - 0x1_0000_0000_0000_0000); + assert(sg == x as int - 0x1_0000_0000_0000_0000); + } else { + assert(x64::logext(64, x as int) == x as int); + assert(sg == x as int); + assert(x as int / p <= x as int) by (nonlinear_arith) + requires + p >= 1, + x as int >= 0, + ; + assert(0 <= x as int / p) by (nonlinear_arith) + requires + p >= 1, + x as int >= 0, + ; + } + assert(lir::ibin64(o, x, y) as int == (sg / p) % 0x1_0000_0000_0000_0000); + }, + _ => {}, + } +} + +} // verus! diff --git a/crates/clazel-jit/src/compose.rs b/crates/clazel-jit/src/compose.rs new file mode 100644 index 00000000..bdeacc95 --- /dev/null +++ b/crates/clazel-jit/src/compose.rs @@ -0,0 +1,152 @@ +//! **Composition.** The templates of a straight-line program, one after the +//! other, refine the program: [`lemma_prog_refines`] is the induction over +//! [`prog_instr`] (the left-nested `then` chain) that turns the per-template +//! refinements of [`crate::proofs`] into one for the whole program. +//! +//! This is composition over *sequencing* only. Structured control flow +//! (`block`, `loop`, `if`, `br`) needs jump templates, a relation at labels, +//! and a proof about the validator's targets rule; it is not in this slice. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// [`preserved`] is transitive. +pub proof fn lemma_preserved_trans(m: x64::State, m1: x64::State, m2: x64::State) + requires + preserved(m, m1), + preserved(m1, m2), + ensures + preserved(m, m2), +{ + lemma_abi_consts_c(); + assert(ctx_of(m1) == ctx_of(m)); + assert forall|b: int| #[trigger] m.mem.dom().contains(b) && !in_exit_area(ctx_of(m), b) + implies m2.mem[b] == m.mem[b] by { + assert(m1.mem.dom().contains(b)); + assert(m1.mem[b] == m.mem[b]); + assert(m2.mem[b] == m1.mem[b]); + } +} + +/// The constants the lemma above needs (`ctx_reg`, `sp_reg`). +pub proof fn lemma_abi_consts_c() + ensures + abi::ctx_reg() == 15, + abi::sp_reg() == 4, +{ +} + +/// A program's stack height after it is the one the static analysis computes. +pub proof fn lemma_prog_height( + ops: Seq, + nl: nat, + h0: nat, + lay: lir::Layout, + a: lir::St, + a2: lir::St, + fuel: nat, +) + requires + prog_ok(ops, nl, h0), + a.stack.len() == h0, + lir::eval(lay, prog_instr(ops), a, fuel) == lir::Outcome::Normal(a2), + ensures + a2.stack.len() == height_after(ops, h0), + decreases ops.len(), +{ + if ops.len() == 0 { + assert(a2 == a); + } else { + let pre = ops.drop_last(); + let last = ops.last(); + assert(fuel > 0); + match lir::eval(lay, prog_instr(pre), a, (fuel - 1) as nat) { + lir::Outcome::Normal(a1) => { + lemma_prog_height(pre, nl, h0, lay, a, a1, (fuel - 1) as nat); + super::proofs::lemma_op_height(last, nl, height_after(pre, h0), lay, a1, a2, (fuel - 1) as nat); + }, + _ => { + assert(false); + }, + } + } +} + +/// **A straight-line program's code refines it.** The templates of the +/// instructions of `ops`, each at the height the ones before it leave, run +/// in order from a state related to the start and reach one related to the +/// end of LIR's evaluation of [`prog_instr`]. +#[verifier::rlimit(500)] +pub proof fn lemma_prog_refines(ops: Seq, nl: nat, h0: nat) + requires + prog_ok(ops, nl, h0), + ensures + super::contract::refines(prog_instr(ops), nl, h0, super::templates::code_of(ops, nl, h0)), + decreases ops.len(), +{ + if ops.len() == 0 { + super::proofs::lemma_op_refines(Op::Nop, nl, h0); + assert(prog_instr(ops) == Op::Nop@); + assert(super::templates::code_of(ops, nl, h0) == super::templates::tmpl(Op::Nop, nl, h0)); + } else { + let pre = ops.drop_last(); + let last = ops.last(); + let hl = height_after(pre, h0); + let ca = super::templates::code_of(pre, nl, h0); + let cb = super::templates::tmpl(last, nl, hl); + lemma_prog_refines(pre, nl, h0); + super::proofs::lemma_op_refines(last, nl, hl); + super::runseq::lemma_code_len_append(ca, cb); + assert(super::templates::code_of(ops, nl, h0) == ca + cb); + assert forall| + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + m: x64::State, + fuel: nat, + | + #![trigger lir::eval(lay, prog_instr(ops), a, fuel), run_seq(cu, m, ca + cb)] + a.stack.len() == h0 && rel(lay, a, m, nl) && x64::canonical( + m.rip + code_len(ca + cb), + ) implies match lir::eval(lay, prog_instr(ops), a, fuel) { + lir::Outcome::Normal(a2) => super::contract::refines_post(lay, a2, m, nl, ca + cb, run_seq(cu, m, ca + cb)), + _ => true, + } by { + match lir::eval(lay, prog_instr(ops), a, fuel) { + lir::Outcome::Normal(a2) => { + assert(fuel > 0); + let f = (fuel - 1) as nat; + // prog_instr(ops) = then(prog_instr(pre), last@) + match lir::eval(lay, prog_instr(pre), a, f) { + lir::Outcome::Normal(a1) => { + assert(lir::eval(lay, last@, a1, f) == lir::Outcome::Normal(a2)); + assert(x64::wf(m)); + assert(x64::canonical(m.rip + code_len(ca))) by { + super::runseq::lemma_canonical_between(m.rip, m.rip + code_len(ca), m.rip + code_len(ca + cb)); + } + super::proofs::lemma_use_refines(prog_instr(pre), nl, h0, ca, lay, cu, a, m, f); + let m1 = run_seq(cu, m, ca).unwrap(); + lemma_prog_height(pre, nl, h0, lay, a, a1, f); + assert(a1.stack.len() == hl); + assert(x64::canonical(m1.rip + code_len(cb))); + super::proofs::lemma_use_refines(last@, nl, hl, cb, lay, cu, a1, m1, f); + let m2 = run_seq(cu, m1, cb).unwrap(); + super::runseq::lemma_run_seq_append(cu, m, ca, cb); + lemma_preserved_trans(m, m1, m2); + }, + _ => { + assert(false); + }, + } + }, + _ => {}, + } + } + } +} + +} // verus! diff --git a/crates/clazel-jit/src/emit.rs b/crates/clazel-jit/src/emit.rs new file mode 100644 index 00000000..7c9b79e3 --- /dev/null +++ b/crates/clazel-jit/src/emit.rs @@ -0,0 +1,786 @@ +//! The executable back end: [`X64Backend`] implements [`Backend`]. It +//! pushes, for each instruction of the program, exactly the instructions of +//! its template ([`tmpl`]), at the stack height the instructions before it +//! leave, and encodes them with `clazel-x64`'s proven encoder. Each function +//! is proven equal to the spec it implements, so the refinement proofs +//! ([`crate::compose::lemma_prog_refines`]) are about the bytes it returns. + +use super::api::Backend; +#[allow(unused_imports)] +use super::spec::*; +use clazel_x64::encoder::encode_exec; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +// ---------------------------------------------------------------------------- +// Checked arithmetic (the workspace denies the unchecked operators) +// ---------------------------------------------------------------------------- + +/// `a + b`, when it does not overflow. +fn add_u(a: usize, b: usize) -> (r: usize) + requires + a + b <= usize::MAX, + ensures + r == a + b, +{ + a.saturating_add(b) +} + +/// `a - b`, when it does not underflow. +fn sub_u(a: usize, b: usize) -> (r: usize) + requires + b <= a, + ensures + r == a - b, +{ + a.saturating_sub(b) +} + + +// ---------------------------------------------------------------------------- +// Instructions +// ---------------------------------------------------------------------------- + +/// The displacement of frame slot `j` from the context register. +fn slot_disp_exec(j: usize) -> (d: i32) + requires + j < 31, + ensures + d as int == slot_disp(j as nat), + slot_mem(j as nat).disp == d, +{ + proof { + super::tlemmas::lemma_abi_consts_t(); + super::steps::lemma_abi_consts(); + } + let d = j.saturating_mul(8).saturating_add(264); + d as i32 +} + +/// `mov dst, [r15 + 264 + 8 j]`. +fn ex_load(dst: u8, j: usize) -> (i: x64::Instr) + requires + j < 31, + ensures + i == super::templates::load_slot(dst, j as nat), +{ + proof { + super::tlemmas::lemma_abi_consts_t(); + crate::steps::lemma_abi_consts(); + } + x64::Instr::MovLoad { + sz: x64::Size::W64, + dst, + mem: x64::Mem { base: 15, index: None, disp: slot_disp_exec(j) }, + } +} + +/// `mov [r15 + 264 + 8 j], src`. +fn ex_store(j: usize, src: u8) -> (i: x64::Instr) + requires + j < 31, + ensures + i == super::templates::store_slot(j as nat, src), +{ + proof { + super::tlemmas::lemma_abi_consts_t(); + crate::steps::lemma_abi_consts(); + } + x64::Instr::MovStore { + sz: x64::Size::W64, + mem: x64::Mem { base: 15, index: None, disp: slot_disp_exec(j) }, + src, + } +} + +/// The instruction that loads a constant into `rax`. +fn ex_const(v: &lir::Val) -> (i: x64::Instr) + ensures + i == super::templates::const_instr(*v), +{ + match v { + lir::Val::I32(c) => x64::Instr::MovImm32 { dst: 0, imm_u32: *c }, + lir::Val::I64(c) => x64::Instr::MovImm64 { dst: 0, imm_u64: *c }, + lir::Val::F64(c) => x64::Instr::MovImm64 { dst: 0, imm_u64: *c }, + } +} + +/// The condition code of an integer comparison. +fn cc_exec(c: &lir::ICmp) -> (r: u8) + ensures + r == super::templates::cc_of(*c), +{ + match c { + lir::ICmp::Eq => 4, + lir::ICmp::Ne => 5, + lir::ICmp::LtS => 12, + lir::ICmp::LtU => 2, + lir::ICmp::GtS => 15, + lir::ICmp::GtU => 7, + lir::ICmp::LeS => 14, + lir::ICmp::LeU => 6, + lir::ICmp::GeS => 13, + lir::ICmp::GeU => 3, + } +} + +/// The instruction of an integer operator on `rax` and `rcx`. +fn int_op_exec(o: &lir::IBin, sz: x64::Size) -> (i: x64::Instr) + ensures + i == super::templates::int_op_instr(*o, sz), +{ + match o { + lir::IBin::Add => x64::Instr::AluRR { alu: x64::AluOp::Add, sz, dst: 0, src: 1 }, + lir::IBin::Sub => x64::Instr::AluRR { alu: x64::AluOp::Sub, sz, dst: 0, src: 1 }, + lir::IBin::And => x64::Instr::AluRR { alu: x64::AluOp::And, sz, dst: 0, src: 1 }, + lir::IBin::Or => x64::Instr::AluRR { alu: x64::AluOp::Or, sz, dst: 0, src: 1 }, + lir::IBin::Xor => x64::Instr::AluRR { alu: x64::AluOp::Xor, sz, dst: 0, src: 1 }, + lir::IBin::Shl => x64::Instr::ShiftCl { shift: x64::ShiftOp::Shl, sz, r: 0 }, + lir::IBin::ShrU => x64::Instr::ShiftCl { shift: x64::ShiftOp::Shr, sz, r: 0 }, + lir::IBin::ShrS => x64::Instr::ShiftCl { shift: x64::ShiftOp::Sar, sz, r: 0 }, + lir::IBin::Mul => x64::Instr::ImulRR { sz, dst: 0, src: 1 }, + lir::IBin::Rotl => x64::Instr::ImulRR { sz, dst: 0, src: 1 }, + lir::IBin::Rotr => x64::Instr::ImulRR { sz, dst: 0, src: 1 }, + } +} + +// ---------------------------------------------------------------------------- +// Which instructions have templates +// ---------------------------------------------------------------------------- + +/// `ibin_supported`. +fn ibin_supported_exec(o: &lir::IBin) -> (r: bool) + ensures + r == ibin_supported(*o), +{ + !matches!(o, lir::IBin::Rotl | lir::IBin::Rotr) +} + +/// `bin_supported`. +fn bin_supported_exec(b: &lir::BinOp) -> (r: bool) + ensures + r == bin_supported(*b), +{ + match b { + lir::BinOp::I32(o) => ibin_supported_exec(o), + lir::BinOp::I64(o) => ibin_supported_exec(o), + lir::BinOp::I32Cmp(_) => true, + lir::BinOp::I64Cmp(_) => true, + lir::BinOp::F64(_) => false, + lir::BinOp::F64Cmp(_) => false, + } +} + +/// `un_supported`. +fn un_supported_exec(u: &lir::UnOp) -> (r: bool) + ensures + r == un_supported(*u), +{ + match u { + lir::UnOp::I32Eqz => true, + lir::UnOp::I64Eqz => true, + lir::UnOp::F64Neg => true, + lir::UnOp::F64Abs => true, + lir::UnOp::F64Sqrt => false, + lir::UnOp::I32WrapI64 => true, + lir::UnOp::I64ExtendI32S => true, + lir::UnOp::I64ExtendI32U => true, + lir::UnOp::F64ConvertI32S => false, + lir::UnOp::F64ConvertI32U => false, + lir::UnOp::F64ConvertI64S => false, + lir::UnOp::F64ConvertI64U => false, + lir::UnOp::F64ReinterpretI64 => true, + lir::UnOp::I64ReinterpretF64 => true, + } +} + +/// `pops`. +fn pops_exec(op: &Op) -> (r: usize) + ensures + r == pops(*op), +{ + match op { + Op::Nop => 0, + Op::Const(_) => 0, + Op::LocalGet(_) => 0, + Op::LocalSet(_) => 1, + Op::LocalTee(_) => 1, + Op::Drop => 1, + Op::Select => 3, + Op::Bin(_) => 2, + Op::Un(_) => 1, + } +} + +/// `pushes`. +fn pushes_exec(op: &Op) -> (r: usize) + ensures + r == pushes(*op), +{ + match op { + Op::Nop => 0, + Op::Const(_) => 1, + Op::LocalGet(_) => 1, + Op::LocalSet(_) => 0, + Op::LocalTee(_) => 1, + Op::Drop => 0, + Op::Select => 1, + Op::Bin(_) => 1, + Op::Un(_) => 1, + } +} + +/// [`op_ok`], executable. +fn op_ok_exec(op: &Op, nl: usize, h: usize) -> (r: bool) + ensures + r == op_ok(*op, nl as nat, h as nat), +{ + proof { + super::tlemmas::lemma_abi_consts_t(); + } + if nl > 31 || h > sub_u(31, nl) { + return false; + } + let p = pops_exec(op); + let q = pushes_exec(op); + if p > h { + return false; + } + let h2 = add_u(sub_u(h, p), q); + if h2 > sub_u(31, nl) { + return false; + } + match op { + Op::LocalGet(x) => *x < nl, + Op::LocalSet(x) => *x < nl, + Op::LocalTee(x) => *x < nl, + Op::Bin(b) => bin_supported_exec(b), + Op::Un(u) => un_supported_exec(u), + _ => true, + } +} + +// ---------------------------------------------------------------------------- +// Templates +// ---------------------------------------------------------------------------- + +/// Append the template of `op` at height `h` with `nl` locals. +#[verifier::rlimit(500)] +fn emit_op(op: &Op, nl: usize, h: usize, out: &mut Vec) + requires + op_ok(*op, nl as nat, h as nat), + ensures + final(out)@ == old(out)@ + super::templates::tmpl(*op, nl as nat, h as nat), +{ + proof { + super::tlemmas::lemma_abi_consts_t(); + } + let ghost old_out = out@; + match op { + Op::Nop => { + proof { + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + Op::Drop => { + proof { + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + Op::Const(v) => { + let c = ex_const(v); + out.push(c); + out.push(ex_store(add_u(nl, h), 0)); + proof { + super::tlemmas::lemma_shape0(seq![super::templates::const_instr(*v)], (nl + h) as nat); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + Op::LocalGet(x) => { + out.push(ex_load(0, *x)); + out.push(ex_store(add_u(nl, h), 0)); + proof { + super::tlemmas::lemma_shape1(rax(), *x as nat, seq![], (nl + h) as nat); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + Op::LocalSet(x) => { + out.push(ex_load(0, sub_u(add_u(nl, h), 1))); + out.push(ex_store(*x, 0)); + proof { + super::tlemmas::lemma_shape1(rax(), (nl + h - 1) as nat, seq![], *x as nat); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + Op::LocalTee(x) => { + out.push(ex_load(0, sub_u(add_u(nl, h), 1))); + out.push(ex_store(*x, 0)); + proof { + super::tlemmas::lemma_shape1(rax(), (nl + h - 1) as nat, seq![], *x as nat); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + Op::Select => { + let t = sub_u(add_u(nl, h), 3); + out.push(ex_load(0, t)); + out.push(ex_load(1, add_u(t, 1))); + out.push(ex_load(2, add_u(t, 2))); + out.push(x64::Instr::TestRR { sz: x64::Size::W32, a: 2, b: 2 }); + out.push(x64::Instr::Cmovcc { cc: 4, sz: x64::Size::W64, dst: 0, src: 1 }); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape3( + rax(), + t as nat, + rcx(), + (t + 1) as nat, + rdx(), + (t + 2) as nat, + super::templates::select_mid(), + t as nat, + ); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + Op::Bin(b) => { + let t = sub_u(add_u(nl, h), 2); + match b { + lir::BinOp::I32(o) => { + out.push(ex_load(0, t)); + out.push(ex_load(1, add_u(t, 1))); + out.push(int_op_exec(o, x64::Size::W32)); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape2( + rax(), + t as nat, + rcx(), + (t + 1) as nat, + seq![super::templates::int_op_instr(*o, x64::Size::W32)], + t as nat, + ); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::BinOp::I64(o) => { + out.push(ex_load(0, t)); + out.push(ex_load(1, add_u(t, 1))); + out.push(int_op_exec(o, x64::Size::W64)); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape2( + rax(), + t as nat, + rcx(), + (t + 1) as nat, + seq![super::templates::int_op_instr(*o, x64::Size::W64)], + t as nat, + ); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::BinOp::I32Cmp(c) => { + out.push(ex_load(1, t)); + out.push(ex_load(2, add_u(t, 1))); + out.push(x64::Instr::MovImm32 { dst: 0, imm_u32: 0 }); + out.push( + x64::Instr::AluRR { alu: x64::AluOp::Cmp, sz: x64::Size::W32, dst: 1, src: 2 }, + ); + out.push(x64::Instr::Setcc { cc: cc_exec(c), dst: 0 }); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape2( + rcx(), + t as nat, + rdx(), + (t + 1) as nat, + super::templates::cmp_mid(*c, x64::Size::W32), + t as nat, + ); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::BinOp::I64Cmp(c) => { + out.push(ex_load(1, t)); + out.push(ex_load(2, add_u(t, 1))); + out.push(x64::Instr::MovImm32 { dst: 0, imm_u32: 0 }); + out.push( + x64::Instr::AluRR { alu: x64::AluOp::Cmp, sz: x64::Size::W64, dst: 1, src: 2 }, + ); + out.push(x64::Instr::Setcc { cc: cc_exec(c), dst: 0 }); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape2( + rcx(), + t as nat, + rdx(), + (t + 1) as nat, + super::templates::cmp_mid(*c, x64::Size::W64), + t as nat, + ); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::BinOp::F64(_) => { + proof { + assert(false); + } + }, + lir::BinOp::F64Cmp(_) => { + proof { + assert(false); + } + }, + } + }, + Op::Un(u) => { + let t = sub_u(add_u(nl, h), 1); + match u { + lir::UnOp::I32Eqz => { + out.push(ex_load(1, t)); + out.push(x64::Instr::MovImm32 { dst: 0, imm_u32: 0 }); + out.push(x64::Instr::TestRR { sz: x64::Size::W32, a: 1, b: 1 }); + out.push(x64::Instr::Setcc { cc: 4, dst: 0 }); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape1(rcx(), t as nat, super::templates::eqz_mid(x64::Size::W32), t as nat); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::UnOp::I64Eqz => { + out.push(ex_load(1, t)); + out.push(x64::Instr::MovImm32 { dst: 0, imm_u32: 0 }); + out.push(x64::Instr::TestRR { sz: x64::Size::W64, a: 1, b: 1 }); + out.push(x64::Instr::Setcc { cc: 4, dst: 0 }); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape1(rcx(), t as nat, super::templates::eqz_mid(x64::Size::W64), t as nat); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::UnOp::F64Neg => { + out.push(ex_load(0, t)); + out.push(x64::Instr::MovImm64 { dst: 1, imm_u64: 0x8000_0000_0000_0000 }); + out.push( + x64::Instr::AluRR { alu: x64::AluOp::Xor, sz: x64::Size::W64, dst: 0, src: 1 }, + ); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape1( + rax(), + t as nat, + super::templates::mask_mid(x64::AluOp::Xor, 0x8000_0000_0000_0000), + t as nat, + ); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::UnOp::F64Abs => { + out.push(ex_load(0, t)); + out.push(x64::Instr::MovImm64 { dst: 1, imm_u64: 0x7FFF_FFFF_FFFF_FFFF }); + out.push( + x64::Instr::AluRR { alu: x64::AluOp::And, sz: x64::Size::W64, dst: 0, src: 1 }, + ); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape1( + rax(), + t as nat, + super::templates::mask_mid(x64::AluOp::And, 0x7FFF_FFFF_FFFF_FFFF), + t as nat, + ); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::UnOp::I64ExtendI32S => { + out.push(ex_load(0, t)); + out.push(x64::Instr::MovImm32 { dst: 1, imm_u32: 0x8000_0000 }); + out.push( + x64::Instr::AluRR { alu: x64::AluOp::Xor, sz: x64::Size::W64, dst: 0, src: 1 }, + ); + out.push( + x64::Instr::AluRR { alu: x64::AluOp::Sub, sz: x64::Size::W64, dst: 0, src: 1 }, + ); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape1(rax(), t as nat, super::templates::exts_mid(), t as nat); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::UnOp::I32WrapI64 => { + out.push(ex_load(0, t)); + out.push(x64::Instr::MovRR { sz: x64::Size::W32, dst: 0, src: 0 }); + out.push(ex_store(t, 0)); + proof { + super::tlemmas::lemma_shape1(rax(), t as nat, super::templates::wrap_mid(), t as nat); + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::UnOp::I64ExtendI32U => { + proof { + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::UnOp::F64ReinterpretI64 => { + proof { + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::UnOp::I64ReinterpretF64 => { + proof { + assert(out@ =~= old_out + super::templates::tmpl(*op, nl as nat, h as nat)); + } + }, + lir::UnOp::F64Sqrt => { + proof { + assert(false); + } + }, + lir::UnOp::F64ConvertI32S => { + proof { + assert(false); + } + }, + lir::UnOp::F64ConvertI32U => { + proof { + assert(false); + } + }, + lir::UnOp::F64ConvertI64S => { + proof { + assert(false); + } + }, + lir::UnOp::F64ConvertI64U => { + proof { + assert(false); + } + }, + } + }, + } +} + +// ---------------------------------------------------------------------------- +// Programs +// ---------------------------------------------------------------------------- + +/// `prog_ok` of a prefix. +pub proof fn lemma_prog_ok_take(ops: Seq, k: int, nl: nat, h0: nat) + requires + prog_ok(ops, nl, h0), + 0 <= k <= ops.len(), + ensures + prog_ok(ops.take(k), nl, h0), + decreases ops.len(), +{ + if k == ops.len() { + assert(ops.take(k) =~= ops); + } else { + let pre = ops.drop_last(); + lemma_prog_ok_take(pre, k, nl, h0); + assert(ops.take(k) =~= pre.take(k)); + } +} + +/// The instruction at `k` has a template at the height before it. +pub proof fn lemma_prog_ok_op(ops: Seq, k: int, nl: nat, h0: nat) + requires + prog_ok(ops, nl, h0), + 0 <= k < ops.len(), + ensures + op_ok(ops[k], nl, height_after(ops.take(k), h0)), +{ + lemma_prog_ok_take(ops, k + 1, nl, h0); + let t = ops.take(k + 1); + assert(t.drop_last() =~= ops.take(k)); + assert(t.last() == ops[k]); +} + +/// [`Backend::emit_body`], and the proof that the code refines. +fn emit_body_impl(ops: &[Op], nl: usize) -> (r: Option>) + ensures + super::contract::emit_body_ensures(ops@, nl, match r { + Some(v) => Some(v@), + None => None, + }), +{ + if nl > 31 { + proof { + super::tlemmas::lemma_abi_consts_t(); + if prog_ok(ops@, nl as nat, 0) { + lemma_prog_ok_take(ops@, 0, nl as nat, 0); + assert(ops@.take(0) =~= Seq::::empty()); + } + } + return None; + } + let mut out: Vec = Vec::new(); + let mut h: usize = 0; + let mut i: usize = 0; + proof { + assert(ops@.take(0) =~= Seq::::empty()); + super::tlemmas::lemma_abi_consts_t(); + } + while i < ops.len() + invariant + i <= ops.len(), + nl <= 31, + prog_ok(ops@.take(i as int), nl as nat, 0), + h as nat == height_after(ops@.take(i as int), 0), + out@ == super::templates::code_of(ops@.take(i as int), nl as nat, 0), + decreases ops.len() - i, + { + proof { + super::tlemmas::lemma_abi_consts_t(); + } + let op = match ops.get(i) { + Some(op) => op, + None => { + proof { + assert(false); + } + return None; + }, + }; + let ok = op_ok_exec(op, nl, h); + if !ok { + proof { + if prog_ok(ops@, nl as nat, 0) { + lemma_prog_ok_op(ops@, i as int, nl as nat, 0); + } + } + return None; + } + emit_op(op, nl, h, &mut out); + proof { + let t = ops@.take(i as int + 1); + assert(t.drop_last() =~= ops@.take(i as int)); + assert(t.last() == ops@[i as int]); + assert(super::templates::code_of(t, nl as nat, 0) == super::templates::code_of(ops@.take(i as int), nl as nat, 0) + super::templates::tmpl( + ops@[i as int], + nl as nat, + height_after(ops@.take(i as int), 0), + )); + } + let p = pops_exec(op); + let q = pushes_exec(op); + proof { + assert(op == &ops@[i as int]); + } + h = add_u(sub_u(h, p), q); + i = add_u(i, 1); + } + proof { + assert(ops@.take(ops.len() as int) =~= ops@); + super::compose::lemma_prog_refines(ops@, nl as nat, 0); + super::tlemmas::lemma_code_of_valid(ops@, nl as nat, 0); + } + Some(out) +} + +/// The exit sequence appended to `code`. +fn emit_exit(code: &mut Vec, exit_code: u32) + ensures + final(code)@ == old(code)@ + exit_seq(exit_code), +{ + let ghost old_code = code@; + code.push(x64::Instr::MovImm32 { dst: 0, imm_u32: exit_code }); + code.push( + x64::Instr::MovStore { + sz: x64::Size::W64, + mem: x64::Mem { base: 15, index: None, disp: 256 }, + src: 0, + }, + ); + code.push(x64::Instr::Ret); + proof { + crate::steps::lemma_abi_consts(); + assert(code@ =~= old_code + exit_seq(exit_code)); + } +} + +/// [`Backend::emit_blob`]: the code and the exit sequence, encoded. +#[verifier::rlimit(500)] +fn emit_blob_impl(ops: &[Op], nl: usize, exit_code: u32) -> (r: Option>) + ensures + super::contract::emit_blob_ensures(ops@, nl, exit_code, match r { + Some(v) => Some(v@), + None => None, + }), +{ + match emit_body_impl(ops, nl) { + None => None, + Some(body) => { + let ghost body_seq = body@; + let mut code = body; + emit_exit(&mut code, exit_code); + proof { + super::tlemmas::lemma_exit_valid(exit_code); + assert(super::contract::all_valid_instrs(body_seq)); + assert forall|k: int| 0 <= k < code@.len() implies x64::valid_instr( + #[trigger] code@[k], + ) by { + if k < body_seq.len() { + assert(code@[k] == body_seq[k]); + } else { + assert(code@[k] == exit_seq(exit_code)[k - body_seq.len()]); + } + } + } + let mut bytes: Vec = Vec::new(); + let mut k: usize = 0; + proof { + assert(code@.take(0) =~= Seq::::empty()); + } + while k < code.len() + invariant + k <= code.len(), + bytes@ == clazel_codecheck::spec::enc_all(code@.take(k as int)), + forall|j: int| 0 <= j < code@.len() ==> x64::valid_instr(#[trigger] code@[j]), + decreases code.len() - k, + { + let ins = match code.get(k) { + Some(ins) => ins, + None => { + proof { + assert(false); + } + return None; + }, + }; + let e = encode_exec(ins); + bytes.extend_from_slice(e.as_slice()); + proof { + let t = code@.take(k as int + 1); + assert(t.drop_last() =~= code@.take(k as int)); + assert(t.last() == code@[k as int]); + assert(e@ =~= x64::encode(code@[k as int])); + } + k = add_u(k, 1); + } + proof { + assert(code@.take(code@.len() as int) =~= code@); + assert(code@ == body_seq + exit_seq(exit_code)); + } + Some(bytes) + }, + } +} + +/// The x86-64 back end. +pub struct X64Backend; + +impl Backend for X64Backend { + fn emit_body(ops: &[Op], nl: usize) -> (r: Option>) { + emit_body_impl(ops, nl) + } + + fn emit_blob(ops: &[Op], nl: usize, exit_code: u32) -> (r: Option>) { + emit_blob_impl(ops, nl, exit_code) + } +} + +} // verus! diff --git a/crates/clazel-jit/src/exit.rs b/crates/clazel-jit/src/exit.rs new file mode 100644 index 00000000..22880292 --- /dev/null +++ b/crates/clazel-jit/src/exit.rs @@ -0,0 +1,218 @@ +//! The exit sequence's refinement ([`exit_refines`]): `mov eax, c; mov [r15 + +//! 256], rax; ret`, for LIR's `exit c` with no operands. The first two +//! instructions put the code in the context's exit-code word; the `ret` pops +//! the return address the enter stub pushed. The frame, the regions and the +//! code are untouched. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// The memory operand of the exit-code word: `[r15 + 256]`. +pub open spec fn exit_mem() -> x64::Mem { + x64::Mem { base: abi::ctx_reg(), index: None, disp: abi::exit_code_off() as i32 } +} + +/// `mov [r15 + 256], src` writes the exit-code word: it reads back as `src`'s +/// value, every byte outside those 8 is as it was, and the registers and +/// flags are unchanged. +pub proof fn lemma_step_store_exit(cu: spec_fn(nat) -> nat, m: x64::State, src: u8) + requires + x64::wf(m), + ctx_ok(m), + src < 16, + exit_area_mapped(m.mem, ctx_of(m)), + x64::canonical( + m.rip + x64::instr_len( + x64::Instr::MovStore { sz: x64::Size::W64, mem: exit_mem(), src: src }, + ), + ), + ensures + x64::step( + cu, + m, + x64::Instr::MovStore { sz: x64::Size::W64, mem: exit_mem(), src: src }, + ) is Some, + ({ + let m1 = x64::step( + cu, + m, + x64::Instr::MovStore { sz: x64::Size::W64, mem: exit_mem(), src: src }, + ).unwrap(); + &&& m1 == x64::State { + mem: m1.mem, + rip: m.rip + x64::instr_len( + x64::Instr::MovStore { sz: x64::Size::W64, mem: exit_mem(), src: src }, + ), + ..m + } + &&& x64::read_mem(m1.mem, ctx_of(m) + abi::exit_code_off(), 8) == Some( + m.rgf[src as int] as int, + ) + &&& m1.mem.dom() =~= m.mem.dom() + &&& forall|b: int| + #![trigger m1.mem.dom().contains(b)] + m.mem.dom().contains(b) && (b < ctx_of(m) + abi::exit_code_off() || ctx_of(m) + + abi::exit_code_off() + 8 <= b) ==> m1.mem[b] == m.mem[b] + }), +{ + super::memlemmas::lemma_p2_consts(); + super::steps::lemma_abi_consts(); + let ctxb = ctx_of(m); + let addr = ctxb + 256; + assert((256int as i32) as int == 256); + assert(x64::eff_addr(m, exit_mem()) == addr) by { + assert(0 <= addr && addr < 0x8000_0000_0000 + 512); + assert(x64::loghead(64, addr) == addr); + assert(x64::logext(64, addr) == addr); + } + let w = m.rgf[src as int] as int; + assert(x64::rgfi_size(m, x64::Size::W64, src) == w); + assert forall|i: int| 0 <= i < 8 implies m.mem.dom().contains(#[trigger] (addr + i)) by { + assert(in_exit_area(ctxb, addr + i)); + } + super::memlemmas::lemma_write_mem_some(m.mem, addr, 8, w); + let m2 = x64::write_mem(m.mem, addr, 8, w).unwrap(); + super::memlemmas::lemma_write_mem_frame(m.mem, addr, 8, w, m2); + assert(0 <= w < vstd::arithmetic::power2::pow2(8 * 8) as int) by { + assert(vstd::arithmetic::power2::pow2(64) == 0x1_0000_0000_0000_0000); + } + super::memlemmas::lemma_read_after_write_same(m.mem, addr, 8, w, m2); + assert(x64::store_mem(m, exit_mem(), x64::Size::W64, w) == Some(x64::State { mem: m2, ..m })); +} + +/// **The exit sequence refines `exit c`.** +#[verifier::rlimit(500)] +pub proof fn lemma_exit_refines(c: u32, nl: nat) + ensures + super::contract::exit_refines(c, nl), +{ + super::memlemmas::lemma_p2_consts(); + super::steps::lemma_abi_consts(); + assert forall| + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + m: x64::State, + fuel: nat, + | + #![trigger lir::eval(lay, lir::Instr::Exit(c as nat, seq![]), a, fuel), run_seq(cu, m, exit_seq(c))] + rel(lay, a, m, nl) && stack_ok(m) && x64::canonical(m.rip + code_len(exit_seq(c))) + implies match lir::eval(lay, lir::Instr::Exit(c as nat, seq![]), a, fuel) { + lir::Outcome::Exit(code, _, a2) => match run_seq(cu, m, exit_seq(c)) { + Some(m2) => { + let rsp = x64::logext(64, m.rgf[abi::sp_reg() as int] as int); + rel(lay, a2, m2, nl) && preserved_mem(m, m2) && x64::read_mem( + m2.mem, + ctx_of(m) + abi::exit_code_off(), + 8, + ) == Some(code as int) && m2.rgf[abi::sp_reg() as int] as int == x64::loghead( + 64, + rsp + 8, + ) && match x64::read_mem(m.mem, rsp, 8) { + Some(raw) => m2.rip == x64::logext(64, raw), + None => false, + } + }, + None => false, + }, + _ => true, + } by { + match lir::eval(lay, lir::Instr::Exit(c as nat, seq![]), a, fuel) { + lir::Outcome::Exit(code, vals, a2) => { + assert(fuel > 0); + assert(code == c as nat); + assert(a2.stack =~= a.stack); + assert(a2.locals == a.locals && a2.mem == a.mem); + let i1 = x64::Instr::MovImm32 { dst: rax(), imm_u32: c }; + let i2 = x64::Instr::MovStore { sz: x64::Size::W64, mem: exit_mem(), src: rax() }; + let i3 = x64::Instr::Ret; + assert(exit_seq(c) == seq![i1, i2, i3]); + super::runseq::lemma_len3(i1, i2, i3); + assert(x64::wf(m)); + let ctxb = ctx_of(m); + // 1. mov eax, c + super::steps::lemma_step_imm(cu, m, i1); + let s1 = x64::State { + rgf: m.rgf.update(0, c as u64), + rip: m.rip + x64::instr_len(i1), + ..m + }; + assert(x64::canonical(s1.rip)); + assert(rel(lay, a, s1, nl)) by { + super::rel::lemma_rel_regs(lay, a, m, s1, nl); + } + // 2. mov [r15 + 256], rax + lemma_step_store_exit(cu, s1, 0); + let s2 = x64::step(cu, s1, i2).unwrap(); + assert(s1.rgf[0] == c as u64); + assert(x64::canonical(s2.rip)); + assert(x64::wf(s2)) by { + assert(s2.mem.dom() =~= m.mem.dom()); + } + // the frame's slots survive the store to the exit-code word + assert forall|j: nat| j < nl + a.stack.len() implies #[trigger] slot_holds( + s2.mem, + ctxb, + j, + lir::val_bits(slot_val(a, nl, j)), + ) by { + assert(slot_holds(m.mem, ctxb, j, lir::val_bits(slot_val(a, nl, j)))); + assert(j < max_slots()); + super::memlemmas::lemma_read_mem_congr(m.mem, s2.mem, ctxb + slot_disp(j), 8); + } + assert(mem_rel(lay, a.mem, s2.mem)) by { + assert forall|b: nat| #[trigger] in_regions(lay, b) implies s2.mem.dom().contains( + b as int, + ) && s2.mem[b as int] == lir::byte_at(a.mem, b) by { + assert(!in_exit_area(ctxb, b as int)); + assert(m.mem.dom().contains(b as int)); + } + } + assert(rel(lay, a2, s2, nl)) by { + assert(x64::wf(s2) && ctx_ok(s2)); + assert(ctx_of(s2) == ctxb); + assert(exit_area_mapped(s2.mem, ctxb)); + } + // 3. ret + let rsp = x64::logext(64, m.rgf[4] as int); + assert(s2.rgf[4] == m.rgf[4]); + assert(rsp + 8 <= ctxb + 256 || ctxb + 512 <= rsp); + match x64::read_mem(m.mem, rsp, 8) { + Some(raw) => { + super::memlemmas::lemma_read_mem_congr(m.mem, s2.mem, rsp, 8); + assert(x64::read_mem(s2.mem, rsp, 8) == Some(raw)); + let new_rsp = x64::logext(64, rsp + 8); + let tos = x64::logext(64, raw); + assert(x64::canonical(new_rsp) && x64::canonical(tos)); + let s3 = x64::step(cu, s2, i3).unwrap(); + assert(x64::step(cu, s2, i3) == Some( + x64::write_ip(x64::wr64(s2, 4, new_rsp), tos), + )); + let f = super::runseq::stepper(cu); + super::runseq::lemma_gen3(f, m, i1, i2, i3, s1, s2, s3); + super::runseq::lemma_run_seq_is_gen(cu, m, seq![i1, i2, i3]); + assert(s3.rgf.len() == 16); + assert(s3.rgf[15] == m.rgf[15]); + assert(s3.mem == s2.mem); + assert(x64::wf(s3)); + assert(rel(lay, a2, s3, nl)) by { + super::rel::lemma_rel_regs(lay, a2, s2, s3, nl); + } + assert(preserved_mem(m, s3)); + assert(x64::loghead(64, new_rsp) == x64::loghead(64, rsp + 8)); + }, + None => { + assert(false); + }, + } + }, + _ => {}, + } + } +} + +} // verus! diff --git a/crates/clazel-jit/src/flags.rs b/crates/clazel-jit/src/flags.rs new file mode 100644 index 00000000..ff886a6f --- /dev/null +++ b/crates/clazel-jit/src/flags.rs @@ -0,0 +1,782 @@ +//! The status flags: what `cmp`, `test` and `setcc` do with them, and that +//! the condition code a comparison template uses holds exactly when LIR's +//! comparison does. +//! +//! The machine keeps the flags as bits of a 32-bit word (`rflags`), changed +//! one flag at a time by `set_bit32`. The six flags the subset writes are at +//! bit positions 0 (`cf`), 2 (`pf`), 4 (`af`), 6 (`zf`), 7 (`sf`) and 11 +//! (`of`). The first lemmas say that changing one flag's bit changes no other +//! of the six; the rest compute the flags `cmp` and `test` leave. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// `k` is the bit position of one of the six flags the subset writes. +pub open spec fn flagpos(k: nat) -> bool { + k == 0 || k == 2 || k == 4 || k == 6 || k == 7 || k == 11 +} + +/// Setting the flag at bit 0: the new value there, the other five unchanged. +#[verifier::rlimit(2000)] +pub proof fn lemma_sb_0(w: u32, v: int) + ensures + x64::bit(x64::set_bit32(w, 0, v) as int, 0) == v % 2, + x64::bit(x64::set_bit32(w, 0, v) as int, 2) == x64::bit(w as int, 2), + x64::bit(x64::set_bit32(w, 0, v) as int, 4) == x64::bit(w as int, 4), + x64::bit(x64::set_bit32(w, 0, v) as int, 6) == x64::bit(w as int, 6), + x64::bit(x64::set_bit32(w, 0, v) as int, 7) == x64::bit(w as int, 7), + x64::bit(x64::set_bit32(w, 0, v) as int, 11) == x64::bit(w as int, 11), +{ + vstd::arithmetic::power2::lemma2_to64(); + let c = v % 2; + assert(0 <= c < 2); + assert(x64::p2(0) == 1); + assert(x64::p2(2) == 4); + assert(x64::p2(4) == 16); + assert(x64::p2(6) == 64); + assert(x64::p2(7) == 128); + assert(x64::p2(11) == 2048); + let q = (w as int) / 2; + let r = (w as int) % 1; + let b = x64::bit(w as int, 0); + assert(b == ((w as int) / 1) % 2); + assert(0 <= r < 1 && 0 <= b < 2); + assert((w as int) == 2 * q + b * 1 + r); + let n = (w as int) - b * 1 + c * 1; + assert(n == 2 * q + c * 1 + r); + assert(0 <= n < 0x1_0000_0000); + assert(x64::set_bit32(w, 0, v) as int == n); + assert(x64::bit(n, 0) == c); + assert(x64::bit(n, 2) == x64::bit(w as int, 2)); + assert(x64::bit(n, 4) == x64::bit(w as int, 4)); + assert(x64::bit(n, 6) == x64::bit(w as int, 6)); + assert(x64::bit(n, 7) == x64::bit(w as int, 7)); + assert(x64::bit(n, 11) == x64::bit(w as int, 11)); +} + +/// Setting the flag at bit 2: the new value there, the other five unchanged. +#[verifier::rlimit(2000)] +pub proof fn lemma_sb_2(w: u32, v: int) + ensures + x64::bit(x64::set_bit32(w, 2, v) as int, 0) == x64::bit(w as int, 0), + x64::bit(x64::set_bit32(w, 2, v) as int, 2) == v % 2, + x64::bit(x64::set_bit32(w, 2, v) as int, 4) == x64::bit(w as int, 4), + x64::bit(x64::set_bit32(w, 2, v) as int, 6) == x64::bit(w as int, 6), + x64::bit(x64::set_bit32(w, 2, v) as int, 7) == x64::bit(w as int, 7), + x64::bit(x64::set_bit32(w, 2, v) as int, 11) == x64::bit(w as int, 11), +{ + vstd::arithmetic::power2::lemma2_to64(); + let c = v % 2; + assert(0 <= c < 2); + assert(x64::p2(0) == 1); + assert(x64::p2(2) == 4); + assert(x64::p2(4) == 16); + assert(x64::p2(6) == 64); + assert(x64::p2(7) == 128); + assert(x64::p2(11) == 2048); + let q = (w as int) / 8; + let r = (w as int) % 4; + let b = x64::bit(w as int, 2); + assert(b == ((w as int) / 4) % 2); + assert(0 <= r < 4 && 0 <= b < 2); + assert((w as int) == 8 * q + b * 4 + r); + let n = (w as int) - b * 4 + c * 4; + assert(n == 8 * q + c * 4 + r); + assert(0 <= n < 0x1_0000_0000); + assert(x64::set_bit32(w, 2, v) as int == n); + assert(x64::bit(n, 0) == x64::bit(w as int, 0)); + assert(x64::bit(n, 2) == c); + assert(x64::bit(n, 4) == x64::bit(w as int, 4)); + assert(x64::bit(n, 6) == x64::bit(w as int, 6)); + assert(x64::bit(n, 7) == x64::bit(w as int, 7)); + assert(x64::bit(n, 11) == x64::bit(w as int, 11)); +} + +/// Setting the flag at bit 4: the new value there, the other five unchanged. +#[verifier::rlimit(2000)] +pub proof fn lemma_sb_4(w: u32, v: int) + ensures + x64::bit(x64::set_bit32(w, 4, v) as int, 0) == x64::bit(w as int, 0), + x64::bit(x64::set_bit32(w, 4, v) as int, 2) == x64::bit(w as int, 2), + x64::bit(x64::set_bit32(w, 4, v) as int, 4) == v % 2, + x64::bit(x64::set_bit32(w, 4, v) as int, 6) == x64::bit(w as int, 6), + x64::bit(x64::set_bit32(w, 4, v) as int, 7) == x64::bit(w as int, 7), + x64::bit(x64::set_bit32(w, 4, v) as int, 11) == x64::bit(w as int, 11), +{ + vstd::arithmetic::power2::lemma2_to64(); + let c = v % 2; + assert(0 <= c < 2); + assert(x64::p2(0) == 1); + assert(x64::p2(2) == 4); + assert(x64::p2(4) == 16); + assert(x64::p2(6) == 64); + assert(x64::p2(7) == 128); + assert(x64::p2(11) == 2048); + let q = (w as int) / 32; + let r = (w as int) % 16; + let b = x64::bit(w as int, 4); + assert(b == ((w as int) / 16) % 2); + assert(0 <= r < 16 && 0 <= b < 2); + assert((w as int) == 32 * q + b * 16 + r); + let n = (w as int) - b * 16 + c * 16; + assert(n == 32 * q + c * 16 + r); + assert(0 <= n < 0x1_0000_0000); + assert(x64::set_bit32(w, 4, v) as int == n); + assert(x64::bit(n, 0) == x64::bit(w as int, 0)); + assert(x64::bit(n, 2) == x64::bit(w as int, 2)); + assert(x64::bit(n, 4) == c); + assert(x64::bit(n, 6) == x64::bit(w as int, 6)); + assert(x64::bit(n, 7) == x64::bit(w as int, 7)); + assert(x64::bit(n, 11) == x64::bit(w as int, 11)); +} + +/// Setting the flag at bit 6: the new value there, the other five unchanged. +#[verifier::rlimit(2000)] +pub proof fn lemma_sb_6(w: u32, v: int) + ensures + x64::bit(x64::set_bit32(w, 6, v) as int, 0) == x64::bit(w as int, 0), + x64::bit(x64::set_bit32(w, 6, v) as int, 2) == x64::bit(w as int, 2), + x64::bit(x64::set_bit32(w, 6, v) as int, 4) == x64::bit(w as int, 4), + x64::bit(x64::set_bit32(w, 6, v) as int, 6) == v % 2, + x64::bit(x64::set_bit32(w, 6, v) as int, 7) == x64::bit(w as int, 7), + x64::bit(x64::set_bit32(w, 6, v) as int, 11) == x64::bit(w as int, 11), +{ + vstd::arithmetic::power2::lemma2_to64(); + let c = v % 2; + assert(0 <= c < 2); + assert(x64::p2(0) == 1); + assert(x64::p2(2) == 4); + assert(x64::p2(4) == 16); + assert(x64::p2(6) == 64); + assert(x64::p2(7) == 128); + assert(x64::p2(11) == 2048); + let q = (w as int) / 128; + let r = (w as int) % 64; + let b = x64::bit(w as int, 6); + assert(b == ((w as int) / 64) % 2); + assert(0 <= r < 64 && 0 <= b < 2); + assert((w as int) == 128 * q + b * 64 + r); + let n = (w as int) - b * 64 + c * 64; + assert(n == 128 * q + c * 64 + r); + assert(0 <= n < 0x1_0000_0000); + assert(x64::set_bit32(w, 6, v) as int == n); + assert(x64::bit(n, 0) == x64::bit(w as int, 0)); + assert(x64::bit(n, 2) == x64::bit(w as int, 2)); + assert(x64::bit(n, 4) == x64::bit(w as int, 4)); + assert(x64::bit(n, 6) == c); + assert(x64::bit(n, 7) == x64::bit(w as int, 7)); + assert(x64::bit(n, 11) == x64::bit(w as int, 11)); +} + +/// Setting the flag at bit 7: the new value there, the other five unchanged. +#[verifier::rlimit(2000)] +pub proof fn lemma_sb_7(w: u32, v: int) + ensures + x64::bit(x64::set_bit32(w, 7, v) as int, 0) == x64::bit(w as int, 0), + x64::bit(x64::set_bit32(w, 7, v) as int, 2) == x64::bit(w as int, 2), + x64::bit(x64::set_bit32(w, 7, v) as int, 4) == x64::bit(w as int, 4), + x64::bit(x64::set_bit32(w, 7, v) as int, 6) == x64::bit(w as int, 6), + x64::bit(x64::set_bit32(w, 7, v) as int, 7) == v % 2, + x64::bit(x64::set_bit32(w, 7, v) as int, 11) == x64::bit(w as int, 11), +{ + vstd::arithmetic::power2::lemma2_to64(); + let c = v % 2; + assert(0 <= c < 2); + assert(x64::p2(0) == 1); + assert(x64::p2(2) == 4); + assert(x64::p2(4) == 16); + assert(x64::p2(6) == 64); + assert(x64::p2(7) == 128); + assert(x64::p2(11) == 2048); + let q = (w as int) / 256; + let r = (w as int) % 128; + let b = x64::bit(w as int, 7); + assert(b == ((w as int) / 128) % 2); + assert(0 <= r < 128 && 0 <= b < 2); + assert((w as int) == 256 * q + b * 128 + r); + let n = (w as int) - b * 128 + c * 128; + assert(n == 256 * q + c * 128 + r); + assert(0 <= n < 0x1_0000_0000); + assert(x64::set_bit32(w, 7, v) as int == n); + assert(x64::bit(n, 0) == x64::bit(w as int, 0)); + assert(x64::bit(n, 2) == x64::bit(w as int, 2)); + assert(x64::bit(n, 4) == x64::bit(w as int, 4)); + assert(x64::bit(n, 6) == x64::bit(w as int, 6)); + assert(x64::bit(n, 7) == c); + assert(x64::bit(n, 11) == x64::bit(w as int, 11)); +} + +/// Setting the flag at bit 11: the new value there, the other five unchanged. +#[verifier::rlimit(2000)] +pub proof fn lemma_sb_11(w: u32, v: int) + ensures + x64::bit(x64::set_bit32(w, 11, v) as int, 0) == x64::bit(w as int, 0), + x64::bit(x64::set_bit32(w, 11, v) as int, 2) == x64::bit(w as int, 2), + x64::bit(x64::set_bit32(w, 11, v) as int, 4) == x64::bit(w as int, 4), + x64::bit(x64::set_bit32(w, 11, v) as int, 6) == x64::bit(w as int, 6), + x64::bit(x64::set_bit32(w, 11, v) as int, 7) == x64::bit(w as int, 7), + x64::bit(x64::set_bit32(w, 11, v) as int, 11) == v % 2, +{ + vstd::arithmetic::power2::lemma2_to64(); + let c = v % 2; + assert(0 <= c < 2); + assert(x64::p2(0) == 1); + assert(x64::p2(2) == 4); + assert(x64::p2(4) == 16); + assert(x64::p2(6) == 64); + assert(x64::p2(7) == 128); + assert(x64::p2(11) == 2048); + let q = (w as int) / 4096; + let r = (w as int) % 2048; + let b = x64::bit(w as int, 11); + assert(b == ((w as int) / 2048) % 2); + assert(0 <= r < 2048 && 0 <= b < 2); + assert((w as int) == 4096 * q + b * 2048 + r); + let n = (w as int) - b * 2048 + c * 2048; + assert(n == 4096 * q + c * 2048 + r); + assert(0 <= n < 0x1_0000_0000); + assert(x64::set_bit32(w, 11, v) as int == n); + assert(x64::bit(n, 0) == x64::bit(w as int, 0)); + assert(x64::bit(n, 2) == x64::bit(w as int, 2)); + assert(x64::bit(n, 4) == x64::bit(w as int, 4)); + assert(x64::bit(n, 6) == x64::bit(w as int, 6)); + assert(x64::bit(n, 7) == x64::bit(w as int, 7)); + assert(x64::bit(n, 11) == c); +} + +/// Setting the flag at `k` sets that bit and no other of the six. +pub proof fn lemma_set_bit32_bit(w: u32, k: nat, v: int, j: nat) + requires + flagpos(k), + flagpos(j), + ensures + x64::bit(x64::set_bit32(w, k, v) as int, j) == if j == k { + v % 2 + } else { + x64::bit(w as int, j) + }, +{ + lemma_sb_0(w, v); + lemma_sb_2(w, v); + lemma_sb_4(w, v); + lemma_sb_6(w, v); + lemma_sb_7(w, v); + lemma_sb_11(w, v); +} + +// ---------------------------------------------------------------------------- +// Reading the flags back out of `change_rflags` and `write_user_rflags` +// ---------------------------------------------------------------------------- + +/// What bit `j` of the flags is after the update `f`, when it was `old`: +/// the new value of the flag at `j` if `f` names one, else `old`. +pub open spec fn upd_bit(f: x64::FlagUpd, j: nat, old: int) -> int { + if j == 0 { + match f.cf { + Some(x) => x % 2, + None => old, + } + } else if j == 2 { + match f.pf { + Some(x) => x % 2, + None => old, + } + } else if j == 4 { + match f.af { + Some(x) => x % 2, + None => old, + } + } else if j == 6 { + match f.zf { + Some(x) => x % 2, + None => old, + } + } else if j == 7 { + match f.sf { + Some(x) => x % 2, + None => old, + } + } else if j == 11 { + match f.of { + Some(x) => x % 2, + None => old, + } + } else { + old + } +} + +/// One optional flag update changes only its own bit. +pub proof fn lemma_opt_set_bit_bit(w: u32, k: nat, v: Option, j: nat) + requires + flagpos(k), + flagpos(j), + ensures + x64::bit(x64::opt_set_bit(w, k, v) as int, j) == match v { + Some(x) => if j == k { + x % 2 + } else { + x64::bit(w as int, j) + }, + None => x64::bit(w as int, j), + }, +{ + match v { + Some(x) => { + lemma_set_bit32_bit(w, k, x, j); + }, + None => {}, + } +} + +/// `change_rflags` sets exactly the flags the update names. +pub proof fn lemma_change_rflags_bit(inp: u32, f: x64::FlagUpd, j: nat) + requires + flagpos(j), + ensures + x64::bit(x64::change_rflags(inp, f) as int, j) == upd_bit(f, j, x64::bit(inp as int, j)), +{ + let w1 = x64::opt_set_bit(inp, x64::cf_bit(), f.cf); + let w2 = x64::opt_set_bit(w1, x64::pf_bit(), f.pf); + let w3 = x64::opt_set_bit(w2, x64::af_bit(), f.af); + let w4 = x64::opt_set_bit(w3, x64::zf_bit(), f.zf); + let w5 = x64::opt_set_bit(w4, x64::sf_bit(), f.sf); + lemma_opt_set_bit_bit(inp, 0, f.cf, j); + lemma_opt_set_bit_bit(w1, 2, f.pf, j); + lemma_opt_set_bit_bit(w2, 4, f.af, j); + lemma_opt_set_bit_bit(w3, 6, f.zf, j); + lemma_opt_set_bit_bit(w4, 7, f.sf, j); + lemma_opt_set_bit_bit(w5, 11, f.of, j); +} + +/// One step of `write_user_rflags` changes only its own flag. +pub proof fn lemma_wfou_flag( + cu: spec_fn(nat) -> nat, + s: x64::State, + k: nat, + vec: u32, + mask: u32, + j: nat, +) + requires + flagpos(k), + flagpos(j), + ensures + x64::flgi(x64::write_flag_or_undefined(cu, s, k, vec, mask), j) == if j == k { + if x64::bit(mask as int, k) == 1 { + (cu(s.undef) % 2) as int + } else { + x64::bit(vec as int, k) + } + } else { + x64::flgi(s, j) + }, +{ + if x64::bit(mask as int, k) == 1 { + lemma_set_bit32_bit(s.rflags, k, (cu(s.undef) % 2) as int, j); + } else { + lemma_set_bit32_bit(s.rflags, k, x64::bit(vec as int, k), j); + } +} + +/// A flag whose bit is clear in the undefined mask is set from the vector by +/// `write_user_rflags`. +pub proof fn lemma_wur_flag(cu: spec_fn(nat) -> nat, s: x64::State, vec: u32, mask: u32, j: nat) + requires + flagpos(j), + x64::bit(mask as int, j) == 0, + ensures + x64::flgi(x64::write_user_rflags(cu, s, vec, mask), j) == x64::bit(vec as int, j), +{ + let s1 = x64::write_flag_or_undefined(cu, s, x64::cf_bit(), vec, mask); + let s2 = x64::write_flag_or_undefined(cu, s1, x64::pf_bit(), vec, mask); + let s3 = x64::write_flag_or_undefined(cu, s2, x64::af_bit(), vec, mask); + let s4 = x64::write_flag_or_undefined(cu, s3, x64::zf_bit(), vec, mask); + let s5 = x64::write_flag_or_undefined(cu, s4, x64::sf_bit(), vec, mask); + lemma_wfou_flag(cu, s, 0, vec, mask, j); + lemma_wfou_flag(cu, s1, 2, vec, mask, j); + lemma_wfou_flag(cu, s2, 4, vec, mask, j); + lemma_wfou_flag(cu, s3, 6, vec, mask, j); + lemma_wfou_flag(cu, s4, 7, vec, mask, j); + lemma_wfou_flag(cu, s5, 11, vec, mask, j); +} + +// ---------------------------------------------------------------------------- +// `cmp` and `test` +// ---------------------------------------------------------------------------- + +/// `cmp a, b` leaves the registers and memory alone and sets the flags of +/// `a - b`: `cf` is "a is below b" (unsigned), `zf` is "the difference is +/// 0", `sf` its top bit, `of` "the signed difference does not fit". +pub proof fn lemma_step_cmp( + cu: spec_fn(nat) -> nat, + m: x64::State, + sz: x64::Size, + a: u8, + b: u8, +) + requires + x64::wf(m), + a < 16, + b < 16, + x64::canonical( + m.rip + x64::instr_len( + x64::Instr::AluRR { alu: x64::AluOp::Cmp, sz: sz, dst: a, src: b }, + ), + ), + ensures + x64::step( + cu, + m, + x64::Instr::AluRR { alu: x64::AluOp::Cmp, sz: sz, dst: a, src: b }, + ) is Some, + ({ + let m1 = x64::step( + cu, + m, + x64::Instr::AluRR { alu: x64::AluOp::Cmp, sz: sz, dst: a, src: b }, + ).unwrap(); + let n = x64::nbits(sz); + let lx = x64::loghead(n, x64::rgfi_size(m, sz, a)); + let ly = x64::loghead(n, x64::rgfi_size(m, sz, b)); + let sraw = x64::logext(n, lx) - x64::logext(n, ly); + let res = x64::loghead(n, sraw); + &&& m1.rgf == m.rgf && m1.mem == m.mem && m1.xmm == m.xmm && m1.rip == m.rip + + x64::instr_len(x64::Instr::AluRR { alu: x64::AluOp::Cmp, sz: sz, dst: a, src: b }) + &&& x64::flgi(m1, x64::cf_bit()) == x64::bool_to_bit(lx < ly) + &&& x64::flgi(m1, x64::zf_bit()) == x64::zf_spec(res) + &&& x64::flgi(m1, x64::sf_bit()) == x64::sf_spec(n, res) % 2 + &&& x64::flgi(m1, x64::of_bit()) == x64::of_spec(n, sraw) + }), +{ + let n = x64::nbits(sz); + let x = x64::rgfi_size(m, sz, a); + let y = x64::rgfi_size(m, sz, b); + let r = x64::gpr_sub_spec(n, x, y, m.rflags); + assert(x64::gpr_arith_logic_spec(n, x64::AluOp::Cmp, x, y, m.rflags) == r); + super::alu::lemma_wur_frame(cu, m, r.rflags, r.undef); + assert(r.undef == 0); + assert(x64::bit(0, 0) == 0 && x64::bit(0, 6) == 0 && x64::bit(0, 7) == 0 && x64::bit(0, 11) + == 0) by { + vstd::arithmetic::power2::lemma2_to64(); + assert(x64::p2(0) == 1 && x64::p2(6) == 64 && x64::p2(7) == 128 && x64::p2(11) == 2048); + } + lemma_wur_flag(cu, m, r.rflags, r.undef, 0); + lemma_wur_flag(cu, m, r.rflags, r.undef, 6); + lemma_wur_flag(cu, m, r.rflags, r.undef, 7); + lemma_wur_flag(cu, m, r.rflags, r.undef, 11); + let lx = x64::loghead(n, x); + let ly = x64::loghead(n, y); + let sraw = x64::logext(n, lx) - x64::logext(n, ly); + let res = x64::loghead(n, sraw); + let f = x64::FlagUpd { + cf: Some(x64::bool_to_bit(lx < ly)), + pf: Some(x64::pf_spec(res)), + af: Some(x64::sub_af_spec(lx, ly)), + zf: Some(x64::zf_spec(res)), + sf: Some(x64::sf_spec(n, res)), + of: Some(x64::of_spec(n, sraw)), + }; + assert(r.rflags == x64::change_rflags(m.rflags, f)); + lemma_change_rflags_bit(m.rflags, f, 0); + lemma_change_rflags_bit(m.rflags, f, 6); + lemma_change_rflags_bit(m.rflags, f, 7); + lemma_change_rflags_bit(m.rflags, f, 11); +} + +/// Bit 6 of `0x10` is clear. +pub proof fn lemma_bit_0x10() + ensures + x64::bit(16, 6) == 0, +{ + vstd::arithmetic::power2::lemma2_to64(); + assert(x64::p2(6) == 64); +} + +/// The flags of an `and`: `cf` and `of` cleared, `pf zf sf` from the result, +/// `af` undefined (mask `0x10`). +pub proof fn lemma_and_spec_shape(n: nat, x: int, y: int, rfl: u32) + ensures + x64::gpr_and_spec(n, x, y, rfl).undef == 0x10u32, + x64::gpr_and_spec(n, x, y, rfl).rflags == x64::change_rflags( + rfl, + x64::FlagUpd { + cf: Some(0), + pf: Some(x64::pf_spec(x64::gpr_and_spec(n, x, y, rfl).result)), + af: None, + zf: Some(x64::zf_spec(x64::gpr_and_spec(n, x, y, rfl).result)), + sf: Some(x64::sf_spec(n, x64::gpr_and_spec(n, x, y, rfl).result)), + of: Some(0), + }, + ), +{ +} + +/// `test a, b` leaves the registers and memory alone and sets `zf` to "the +/// bitwise and of the operands is 0". +pub proof fn lemma_step_test( + cu: spec_fn(nat) -> nat, + m: x64::State, + sz: x64::Size, + a: u8, + b: u8, +) + requires + x64::wf(m), + a < 16, + b < 16, + x64::canonical( + m.rip + x64::instr_len(x64::Instr::TestRR { sz: sz, a: a, b: b }), + ), + ensures + x64::step(cu, m, x64::Instr::TestRR { sz: sz, a: a, b: b }) is Some, + ({ + let m1 = x64::step(cu, m, x64::Instr::TestRR { sz: sz, a: a, b: b }).unwrap(); + let n = x64::nbits(sz); + let r = x64::gpr_and_spec( + n, + x64::rgfi_size(m, sz, a), + x64::rgfi_size(m, sz, b), + m.rflags, + ); + &&& m1.rgf == m.rgf && m1.mem == m.mem && m1.xmm == m.xmm && m1.rip == m.rip + + x64::instr_len(x64::Instr::TestRR { sz: sz, a: a, b: b }) + &&& x64::flgi(m1, x64::zf_bit()) == x64::zf_spec(r.result) + }), +{ + let n = x64::nbits(sz); + let x = x64::rgfi_size(m, sz, a); + let y = x64::rgfi_size(m, sz, b); + lemma_and_spec_shape(n, x, y, m.rflags); + let r = x64::gpr_and_spec(n, x, y, m.rflags); + super::alu::lemma_wur_frame(cu, m, r.rflags, r.undef); + lemma_bit_0x10(); + assert(r.undef as int == 16); + assert(x64::bit(r.undef as int, 6) == 0); + lemma_wur_flag(cu, m, r.rflags, r.undef, 6); + let f = x64::FlagUpd { + cf: Some(0), + pf: Some(x64::pf_spec(r.result)), + af: None, + zf: Some(x64::zf_spec(r.result)), + sf: Some(x64::sf_spec(n, r.result)), + of: Some(0), + }; + lemma_change_rflags_bit(m.rflags, f, 6); +} + +// ---------------------------------------------------------------------------- +// Condition codes +// ---------------------------------------------------------------------------- + +/// The flags of `a - b` at 32 bits: `zf` is "equal", `sf != of` is "signed less". +pub proof fn lemma_cmp_arith32(lx: int, ly: int) + requires + 0 <= lx < 0x1_0000_0000, + 0 <= ly < 0x1_0000_0000, + ensures + ({ + let sraw = x64::logext(32, lx) - x64::logext(32, ly); + let res = x64::loghead(32, sraw); + &&& (x64::zf_spec(res) == 1) <==> (lx == ly) + &&& ((x64::sf_spec(32, res) % 2 != x64::of_spec(32, sraw)) <==> (lir::signed_of( + 32, + lx, + ) < lir::signed_of(32, ly))) + &&& lir::signed_of(32, lx) == x64::logext(32, lx) + &&& lir::signed_of(32, ly) == x64::logext(32, ly) + }), +{ + super::memlemmas::lemma_p2_consts(); + vstd::arithmetic::power2::lemma2_to64(); + assert(x64::p2(32) == 0x1_0000_0000); + assert(x64::p2(31) == 0x8000_0000); + assert(lir::pow2(32) == 0x1_0000_0000); + assert(lir::pow2(32) / 2 == 0x8000_0000); + assert(x64::loghead(32, lx) == lx && x64::loghead(32, ly) == ly); + let sx = if lx >= 0x8000_0000 { lx - 0x1_0000_0000 } else { lx }; + let sy = if ly >= 0x8000_0000 { ly - 0x1_0000_0000 } else { ly }; + assert(x64::logext(32, lx) == sx && x64::logext(32, ly) == sy); + assert(lir::signed_of(32, lx) == sx && lir::signed_of(32, ly) == sy); + let sraw = sx - sy; + let res = sraw % 0x1_0000_0000; + assert(x64::loghead(32, sraw) == res); + assert(x64::bit(res, 31) == (res / 0x8000_0000) % 2); + assert(x64::sf_spec(32, res) == (res / 0x8000_0000) % 2); + assert(x64::zf_spec(res) == 1 <==> res == 0); + assert((sraw % 0x1_0000_0000 == 0) <==> (lx == ly)); + assert(x64::of_spec(32, sraw) == if -0x8000_0000 <= sraw && sraw < 0x8000_0000 { 0int } else { 1int }); + assert(((res / 0x8000_0000) % 2 != (if -0x8000_0000 <= sraw && sraw < 0x8000_0000 { 0int } else { 1int })) <==> (sx < sy)); +} + +/// The flags of `a - b` at 64 bits: `zf` is "equal", `sf != of` is "signed less". +pub proof fn lemma_cmp_arith64(lx: int, ly: int) + requires + 0 <= lx < 0x1_0000_0000_0000_0000, + 0 <= ly < 0x1_0000_0000_0000_0000, + ensures + ({ + let sraw = x64::logext(64, lx) - x64::logext(64, ly); + let res = x64::loghead(64, sraw); + &&& (x64::zf_spec(res) == 1) <==> (lx == ly) + &&& ((x64::sf_spec(64, res) % 2 != x64::of_spec(64, sraw)) <==> (lir::signed_of( + 64, + lx, + ) < lir::signed_of(64, ly))) + &&& lir::signed_of(64, lx) == x64::logext(64, lx) + &&& lir::signed_of(64, ly) == x64::logext(64, ly) + }), +{ + super::memlemmas::lemma_p2_consts(); + vstd::arithmetic::power2::lemma2_to64(); + assert(x64::p2(64) == 0x1_0000_0000_0000_0000); + assert(x64::p2(63) == 0x8000_0000_0000_0000); + assert(lir::pow2(64) == 0x1_0000_0000_0000_0000); + assert(lir::pow2(64) / 2 == 0x8000_0000_0000_0000); + assert(x64::loghead(64, lx) == lx && x64::loghead(64, ly) == ly); + let sx = if lx >= 0x8000_0000_0000_0000 { lx - 0x1_0000_0000_0000_0000 } else { lx }; + let sy = if ly >= 0x8000_0000_0000_0000 { ly - 0x1_0000_0000_0000_0000 } else { ly }; + assert(x64::logext(64, lx) == sx && x64::logext(64, ly) == sy); + assert(lir::signed_of(64, lx) == sx && lir::signed_of(64, ly) == sy); + let sraw = sx - sy; + let res = sraw % 0x1_0000_0000_0000_0000; + assert(x64::loghead(64, sraw) == res); + assert(x64::bit(res, 63) == (res / 0x8000_0000_0000_0000) % 2); + assert(x64::sf_spec(64, res) == (res / 0x8000_0000_0000_0000) % 2); + assert(x64::zf_spec(res) == 1 <==> res == 0); + assert((sraw % 0x1_0000_0000_0000_0000 == 0) <==> (lx == ly)); + assert(x64::of_spec(64, sraw) == if -0x8000_0000_0000_0000 <= sraw && sraw < 0x8000_0000_0000_0000 { 0int } else { 1int }); + assert(((res / 0x8000_0000_0000_0000) % 2 != (if -0x8000_0000_0000_0000 <= sraw && sraw < 0x8000_0000_0000_0000 { 0int } else { 1int })) <==> (sx < sy)); +} + +/// The arithmetic of the flags of `a - b`, at 32 or 64 bits. +pub proof fn lemma_cmp_arith(n: nat, lx: int, ly: int) + requires + n == 32 || n == 64, + 0 <= lx < x64::p2(n), + 0 <= ly < x64::p2(n), + ensures + ({ + let sraw = x64::logext(n, lx) - x64::logext(n, ly); + let res = x64::loghead(n, sraw); + &&& (x64::zf_spec(res) == 1) <==> (lx == ly) + &&& ((x64::sf_spec(n, res) % 2 != x64::of_spec(n, sraw)) <==> (lir::signed_of( + n, + lx, + ) < lir::signed_of(n, ly))) + &&& lir::signed_of(n, lx) == x64::logext(n, lx) + &&& lir::signed_of(n, ly) == x64::logext(n, ly) + }), +{ + super::memlemmas::lemma_p2_consts(); + vstd::arithmetic::power2::lemma2_to64(); + if n == 32 { + lemma_cmp_arith32(lx, ly); + } else { + lemma_cmp_arith64(lx, ly); + } +} + +/// Given the flags `cmp lx, ly` leaves, the condition code of the comparison +/// template holds exactly when LIR's comparison does. +pub proof fn lemma_cc_icmp(s: x64::State, op: lir::ICmp, n: nat, lx: int, ly: int) + requires + n == 32 || n == 64, + 0 <= lx < x64::p2(n), + 0 <= ly < x64::p2(n), + ({ + let sraw = x64::logext(n, lx) - x64::logext(n, ly); + let res = x64::loghead(n, sraw); + &&& x64::flgi(s, x64::cf_bit()) == x64::bool_to_bit(lx < ly) + &&& x64::flgi(s, x64::zf_bit()) == x64::zf_spec(res) + &&& x64::flgi(s, x64::sf_bit()) == x64::sf_spec(n, res) % 2 + &&& x64::flgi(s, x64::of_bit()) == x64::of_spec(n, sraw) + }), + ensures + x64::jcc_cmovcc_setcc_spec(s, super::templates::cc_of(op)) == lir::icmp(op, n, lx, ly), +{ + lemma_cmp_arith(n, lx, ly); + assert(x64::cf_bit() == 0 && x64::zf_bit() == 6 && x64::sf_bit() == 7 && x64::of_bit() == 11); +} + +/// `setcc dst` sets the low byte of `dst` to 1 or 0 by the condition, keeping +/// the other 56 bits. +pub proof fn lemma_step_setcc(cu: spec_fn(nat) -> nat, m: x64::State, cc: u8, dst: u8) + requires + x64::wf(m), + cc < 16, + dst < 16, + x64::canonical(m.rip + x64::instr_len(x64::Instr::Setcc { cc: cc, dst: dst })), + ensures + x64::step(cu, m, x64::Instr::Setcc { cc: cc, dst: dst }) == Some( + x64::State { + rgf: m.rgf.update( + dst as int, + ((m.rgf[dst as int] as int) - (m.rgf[dst as int] as int) % 256 + if x64::jcc_cmovcc_setcc_spec( + m, + cc, + ) { + 1int + } else { + 0int + }) as u64, + ), + rip: m.rip + x64::instr_len(x64::Instr::Setcc { cc: cc, dst: dst }), + ..m + }, + ), +{ + super::memlemmas::lemma_p2_consts(); + let old = m.rgf[dst as int] as int; + let v: int = if x64::jcc_cmovcc_setcc_spec(m, cc) { + 1 + } else { + 0 + }; + assert(x64::loghead(8, v) == v); + assert(old - old % 256 + v < 0x1_0000_0000_0000_0000); + assert(x64::loghead(64, old - old % 256 + v) == old - old % 256 + v); +} + +/// `cmovcc dst, src` (64-bit): `dst := src` when the condition holds, else +/// unchanged. +pub proof fn lemma_step_cmov64(cu: spec_fn(nat) -> nat, m: x64::State, cc: u8, dst: u8, src: u8) + requires + x64::wf(m), + cc < 16, + dst < 16, + src < 16, + x64::canonical( + m.rip + x64::instr_len( + x64::Instr::Cmovcc { cc: cc, sz: x64::Size::W64, dst: dst, src: src }, + ), + ), + ensures + x64::step( + cu, + m, + x64::Instr::Cmovcc { cc: cc, sz: x64::Size::W64, dst: dst, src: src }, + ) == Some( + x64::State { + rgf: if x64::jcc_cmovcc_setcc_spec(m, cc) { + m.rgf.update(dst as int, m.rgf[src as int]) + } else { + m.rgf + }, + rip: m.rip + x64::instr_len( + x64::Instr::Cmovcc { cc: cc, sz: x64::Size::W64, dst: dst, src: src }, + ), + ..m + }, + ), +{ + super::memlemmas::lemma_p2_consts(); + let v = m.rgf[src as int] as int; + assert(x64::loghead(64, v) == v); +} + +} // verus! diff --git a/crates/clazel-jit/src/lib.rs b/crates/clazel-jit/src/lib.rs index 3802c9f3..26539075 100644 --- a/crates/clazel-jit/src/lib.rs +++ b/crates/clazel-jit/src/lib.rs @@ -4,8 +4,11 @@ //! fixed template over the scratch registers `rax`, `rcx` and `rdx`, so each //! template's proof is local. //! -//! This is the first slice of J.9, and it is written contract first (CLAUDE.md -//! rule 3). +//! This is the first slice of J.9: straight-line integer code. It was written +//! contract first (CLAUDE.md rule 3): [`spec`], [`contract`] and [`api`] came +//! in their own commit, before any template. +//! +//! # The statements //! //! - [`spec`]: **what the back end is about.** The state relation between a //! LIR state and an x86-64 machine state, the frame layout (the codecheck @@ -16,14 +19,75 @@ //! related to LIR's `eval`), and the emitter's contracts. //! - [`api`]: the contract-only trait [`api::Backend`]. //! -//! # Status +//! # The templates and their proofs +//! +//! - [`templates`]: the templates, as spec functions (`tmpl`, `code_of`). +//! - [`emit`]: the executable back end, [`emit::X64Backend`], proven equal to +//! the templates and, through `clazel-x64`'s encoder, to their bytes. +//! - Proofs, bottom up: [`memlemmas`] (byte memory), [`steps`], [`alu`] and +//! [`flags`] (one `x64::step` of each instruction form the templates use), +//! [`runseq`] (running a list), [`mid`] (each template's register-only +//! middle computes LIR's result), [`rel`], [`skel`] and [`agree`] (the +//! loads-middle-store skeleton preserves the state relation), [`proofs`] +//! (the refinement of each template, `lemma_op_refines`), [`compose`] (the +//! program, `lemma_prog_refines`), [`exit`] (the exit sequence), +//! [`tlemmas`] (templates are in the subset, and are what the emitter +//! pushes). +//! +//! # What is proven (Verus, no axiom, no assumption) +//! +//! - **Each template refines its LIR instruction** ([`contract::refines`]), +//! for: `nop`, `drop`, `t.const`, `local.get`, `local.set`, `local.tee`, +//! `select`; `i32` and `i64` `add`, `sub`, `mul`, `and`, `or`, `xor`, +//! `shl`, `shr_s`, `shr_u`, and the ten comparisons; `i32.eqz`, +//! `i64.eqz`, `i32.wrap_i64`, `i64.extend_i32_s`, `i64.extend_i32_u`, +//! `f64.neg`, `f64.abs` and the two `reinterpret`s (the last four are bit +//! operations). +//! - **A straight-line program of them refines** the left-nested `then` +//! chain ([`compose::lemma_prog_refines`]). +//! - **The exit sequence refines `exit c`** with no operands +//! ([`contract::exit_refines`], [`exit::lemma_exit_refines`]). +//! - **The emitter returns exactly the template code, and its encoding** +//! ([`contract::emit_body_ensures`], [`contract::emit_blob_ensures`]), +//! and refuses (`None`) exactly the programs [`spec::prog_ok`] refuses. +//! +//! # What is not //! -//! Tier 0, and nothing is proven yet: this commit holds the statements only. -//! The templates, their proofs, the emitter and the validator test follow. +//! - **That the validator accepts every blob** is checked by +//! `tests/validator.rs` (every template, 3000 generated programs), not +//! proven. +//! - **Not covered by any template:** the memory instructions +//! (`bounds_check`, `load`, `store`); structured control flow (`block`, +//! `loop`, `if`, `br`, `br_if`, `br_table`) and so composition over it; +//! `exit` with operands; `f64` arithmetic, comparison and conversion +//! (LIR's `f64` operators are uninterpreted functions, so a refinement to +//! SSE would need an axiom this crate does not add); rotates (the subset +//! has no rotate instruction); a frame beyond 31 slots (it needs the +//! region frame and the bounds-check sequence on every access). +//! - **No tier is claimed.** `tier` stays 0 until CI's full verification of +//! this crate is green (CLAUDE.md rule 7), and the crate has no mutation +//! file, no independent transcription and no conformance suite, which +//! tier 2 requires. The proofs are about the spec of `clazel-x64` and the +//! semantics of `clazel-lir`, whose faithfulness is their crates' claim. //! //! Tier: see `[package.metadata.clazel]` in `Cargo.toml` and //! `docs/VERIFICATION.md`. +pub mod agree; +pub mod alu; pub mod api; +pub mod compose; pub mod contract; +pub mod emit; +pub mod exit; +pub mod flags; +pub mod memlemmas; +pub mod mid; +pub mod proofs; +pub mod rel; +pub mod runseq; +pub mod skel; pub mod spec; +pub mod steps; +pub mod templates; +pub mod tlemmas; diff --git a/crates/clazel-jit/src/memlemmas.rs b/crates/clazel-jit/src/memlemmas.rs new file mode 100644 index 00000000..b073f250 --- /dev/null +++ b/crates/clazel-jit/src/memlemmas.rs @@ -0,0 +1,178 @@ +//! Facts about `clazel-x64`'s byte-addressed memory (`read_mem`, +//! `write_mem`), and about the 8-byte frame slots built on them. They are +//! what every template's proof uses to say "this store changed this slot and +//! no other byte". + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// The concrete values of the powers of two the proofs use. +pub proof fn lemma_p2_consts() + ensures + x64::p2(8) == 256, + x64::p2(32) == 0x1_0000_0000, + x64::p2(47) == 0x8000_0000_0000, + x64::p2(63) == 0x8000_0000_0000_0000, + x64::p2(64) == 0x1_0000_0000_0000_0000, +{ + vstd::arithmetic::power2::lemma2_to64(); + vstd::arithmetic::power2::lemma2_to64_rest(); +} + +/// A write that succeeds touches only the bytes it writes, and maps nothing +/// new: the domain is unchanged and every byte outside `[addr, addr + n)` keeps +/// its value. +pub proof fn lemma_write_mem_frame(m: Map, addr: int, n: nat, v: int, m2: Map) + requires + x64::write_mem(m, addr, n, v) == Some(m2), + ensures + m2.dom() =~= m.dom(), + forall|b: int| + #![trigger m2.dom().contains(b)] + m.dom().contains(b) && (b < addr || addr + n <= b) ==> m2[b] == m[b], + decreases n, +{ + if n > 0 { + match x64::write_mem(m, addr + 1, (n - 1) as nat, v / 256) { + Some(m3) => { + lemma_write_mem_frame(m, addr + 1, (n - 1) as nat, v / 256, m3); + assert(m2 == m3.insert(addr, (v % 256) as u8)); + assert(m.dom().contains(addr)); + assert(m2.dom() =~= m.dom()); + }, + None => {}, + } + } +} + +/// A write succeeds when every byte it writes is mapped. +pub proof fn lemma_write_mem_some(m: Map, addr: int, n: nat, v: int) + requires + forall|i: int| 0 <= i < n ==> m.dom().contains(#[trigger] (addr + i)), + ensures + x64::write_mem(m, addr, n, v) is Some, + decreases n, +{ + if n > 0 { + assert(m.dom().contains(addr + 0)); + assert forall|i: int| 0 <= i < n - 1 implies m.dom().contains(#[trigger] (addr + 1 + i)) by { + assert(m.dom().contains(addr + (i + 1))); + } + lemma_write_mem_some(m, addr + 1, (n - 1) as nat, v / 256); + } +} + +/// Inserting at an address outside the range read does not change the read. +pub proof fn lemma_read_mem_insert_other(m: Map, a: int, n: nat, b: int, x: u8) + requires + b < a || a + n <= b, + ensures + x64::read_mem(m.insert(b, x), a, n) == x64::read_mem(m, a, n), + decreases n, +{ + if n > 0 { + lemma_read_mem_insert_other(m, a + 1, (n - 1) as nat, b, x); + assert(m.insert(b, x).dom().contains(a) == m.dom().contains(a)); + if m.dom().contains(a) { + assert(m.insert(b, x)[a] == m[a]); + } + } +} + +/// Two memories that agree on every byte of a range read the same there. +pub proof fn lemma_read_mem_congr(m: Map, m2: Map, a: int, n: nat) + requires + forall|i: int| + 0 <= i < n ==> (m.dom().contains(#[trigger] (a + i)) == m2.dom().contains(a + i)) && ( + m.dom().contains(a + i) ==> m[a + i] == m2[a + i]), + ensures + x64::read_mem(m, a, n) == x64::read_mem(m2, a, n), + decreases n, +{ + if n > 0 { + assert forall|i: int| 0 <= i < n - 1 implies (m.dom().contains(#[trigger] (a + 1 + i)) + == m2.dom().contains(a + 1 + i)) && (m.dom().contains(a + 1 + i) ==> m[a + 1 + i] + == m2[a + 1 + i]) by { + assert(a + (i + 1) == a + 1 + i); + } + lemma_read_mem_congr(m, m2, a + 1, (n - 1) as nat); + assert(a + 0 == a); + } +} + +/// Reading back what was just written: the `n` bytes at `addr` read as `v`, +/// for `v` below `2^(8n)`. +pub proof fn lemma_read_after_write_same( + m: Map, + addr: int, + n: nat, + v: int, + m2: Map, +) + requires + x64::write_mem(m, addr, n, v) == Some(m2), + 0 <= v < vstd::arithmetic::power2::pow2(8 * n) as int, + ensures + x64::read_mem(m2, addr, n) == Some(v), + decreases n, +{ + lemma_p2_consts(); + if n == 0 { + vstd::arithmetic::power2::lemma2_to64(); + assert(v == 0); + } else { + match x64::write_mem(m, addr + 1, (n - 1) as nat, v / 256) { + Some(m3) => { + let n1 = (n - 1) as nat; + assert(vstd::arithmetic::power2::pow2(8 * n) == 256 * vstd::arithmetic::power2::pow2( + 8 * n1, + )) by { + vstd::arithmetic::power2::lemma_pow2_adds(8, 8 * n1); + assert(8 * n == 8 + 8 * n1); + } + assert(0 <= v / 256 < vstd::arithmetic::power2::pow2(8 * n1) as int) by { + vstd::arithmetic::power2::lemma_pow2_pos(8 * n1); + } + lemma_read_after_write_same(m, addr + 1, (n - 1) as nat, v / 256, m3); + assert(m2 == m3.insert(addr, (v % 256) as u8)); + lemma_write_mem_frame(m, addr + 1, (n - 1) as nat, v / 256, m3); + lemma_read_mem_insert_other(m3, addr + 1, (n - 1) as nat, addr, (v % 256) as u8); + assert(m3.dom().contains(addr)); + assert(m2.dom().contains(addr)); + assert(m2[addr] == (v % 256) as u8); + assert(v == v % 256 + 256 * (v / 256)); + }, + None => {}, + } + } +} + +/// A read of a range disjoint from a successful write sees the old bytes. +pub proof fn lemma_read_after_write_disjoint( + m: Map, + addr: int, + n: nat, + v: int, + m2: Map, + b: int, + k: nat, +) + requires + x64::write_mem(m, addr, n, v) == Some(m2), + b + k <= addr || addr + n <= b, + ensures + x64::read_mem(m2, b, k) == x64::read_mem(m, b, k), +{ + lemma_write_mem_frame(m, addr, n, v, m2); + assert forall|i: int| 0 <= i < k implies (m.dom().contains(#[trigger] (b + i)) + == m2.dom().contains(b + i)) && (m.dom().contains(b + i) ==> m[b + i] == m2[b + i]) by { + assert(m2.dom().contains(b + i) == m.dom().contains(b + i)); + } + lemma_read_mem_congr(m, m2, b, k); +} + +} // verus! diff --git a/crates/clazel-jit/src/mid.rs b/crates/clazel-jit/src/mid.rs new file mode 100644 index 00000000..f8577798 --- /dev/null +++ b/crates/clazel-jit/src/mid.rs @@ -0,0 +1,531 @@ +//! The register-only middle of each template: from a machine state whose +//! scratch registers hold the operands, running the template's computation +//! leaves the LIR result in `rax` ([`mid_post`]). One lemma per shape, each a +//! chain of the single-step lemmas of [`crate::steps`], [`crate::alu`] and +//! [`crate::flags`]. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// The integer operators with a one-instruction middle. +pub open spec fn int_op_ok(o: lir::IBin) -> bool { + ibin_supported(o) +} + +/// Writing a register with a 32-bit result leaves the zero-extended word, and +/// changes that register only. +pub proof fn lemma_set_rgfi(m: x64::State, sz: x64::Size, dst: u8, v: int) + requires + m.rgf.len() == 16, + dst < 16, + 0 <= v, + sz is W32 ==> v < 0x1_0000_0000, + v < 0x1_0000_0000_0000_0000, + ensures + x64::set_rgfi_size(m, sz, dst, v).rgf == m.rgf.update(dst as int, v as u64), +{ + super::memlemmas::lemma_p2_consts(); + assert(x64::loghead(32, v) == v || sz is W64); + assert(x64::loghead(64, v) == v); +} + +/// `op rax, rcx` for the integer operators of the first slice, 32-bit: leaves +/// LIR's result (`ibin32`) in `rax`. +#[verifier::rlimit(1000)] +pub proof fn lemma_mid_int32(cu: spec_fn(nat) -> nat, s: x64::State, o: lir::IBin, x: u32, y: u32) + requires + x64::wf(s), + int_op_ok(o), + s.rgf[0] == x as u64, + s.rgf[1] == y as u64, + x64::canonical(s.rip + x64::instr_len(super::templates::int_op_instr(o, x64::Size::W32))), + ensures + run_seq(cu, s, seq![super::templates::int_op_instr(o, x64::Size::W32)]) is Some, + super::alu::mid_post( + s, + run_seq(cu, s, seq![super::templates::int_op_instr(o, x64::Size::W32)]).unwrap(), + rax(), + lir::ibin32(o, x, y) as nat, + code_len(seq![super::templates::int_op_instr(o, x64::Size::W32)]), + ), +{ + super::memlemmas::lemma_p2_consts(); + let i = super::templates::int_op_instr(o, x64::Size::W32); + super::runseq::lemma_run_seq_one(cu, s, i); + super::runseq::lemma_code_len_one(i); + assert(x64::rgfi_size(s, x64::Size::W32, 0) == x as int); + assert(x64::rgfi_size(s, x64::Size::W32, 1) == y as int); + let m1 = x64::step(cu, s, i).unwrap(); + if super::templates::alu_of(o) is Some { + let alu = super::templates::alu_of(o).unwrap(); + super::alu::lemma_step_alu_rr(cu, s, alu, x64::Size::W32, 0, 1); + super::alu::lemma_val32_alu(o, x, y, s.rflags); + let r = x64::gpr_arith_logic_spec(32, alu, x as int, y as int, s.rflags); + lemma_set_rgfi(s, x64::Size::W32, 0, r.result); + } else if super::templates::shift_of(o) is Some { + let sh = super::templates::shift_of(o).unwrap(); + super::alu::lemma_step_shift_cl(cu, s, sh, x64::Size::W32, 0); + super::alu::lemma_val32_shift(o, x, y, s.rflags); + assert(x64::rr64(s, 1) == y as int); + let cnt = x64::shift_count(x64::Size::W32, x64::loghead(8, y as int)); + let res = x64::shift_spec(sh, 32, x as int, cnt, s.rflags).result; + lemma_set_rgfi(s, x64::Size::W32, 0, res); + } else { + assert(o == lir::IBin::Mul); + super::alu::lemma_step_imul_rr(cu, s, x64::Size::W32, 0, 1); + super::alu::lemma_val32_mul(x, y); + let (low, cf) = x64::imul_spec(32, y as int, x as int); + lemma_set_rgfi(s, x64::Size::W32, 0, low); + } +} + +/// `op rax, rcx` for the integer operators of the first slice, 64-bit. +#[verifier::rlimit(1000)] +pub proof fn lemma_mid_int64(cu: spec_fn(nat) -> nat, s: x64::State, o: lir::IBin, x: u64, y: u64) + requires + x64::wf(s), + int_op_ok(o), + s.rgf[0] == x, + s.rgf[1] == y, + x64::canonical(s.rip + x64::instr_len(super::templates::int_op_instr(o, x64::Size::W64))), + ensures + run_seq(cu, s, seq![super::templates::int_op_instr(o, x64::Size::W64)]) is Some, + super::alu::mid_post( + s, + run_seq(cu, s, seq![super::templates::int_op_instr(o, x64::Size::W64)]).unwrap(), + rax(), + lir::ibin64(o, x, y) as nat, + code_len(seq![super::templates::int_op_instr(o, x64::Size::W64)]), + ), +{ + super::memlemmas::lemma_p2_consts(); + let i = super::templates::int_op_instr(o, x64::Size::W64); + super::runseq::lemma_run_seq_one(cu, s, i); + super::runseq::lemma_code_len_one(i); + assert(x64::rgfi_size(s, x64::Size::W64, 0) == x as int); + assert(x64::rgfi_size(s, x64::Size::W64, 1) == y as int); + let m1 = x64::step(cu, s, i).unwrap(); + if super::templates::alu_of(o) is Some { + let alu = super::templates::alu_of(o).unwrap(); + super::alu::lemma_step_alu_rr(cu, s, alu, x64::Size::W64, 0, 1); + super::alu::lemma_val64_alu(o, x, y, s.rflags); + let r = x64::gpr_arith_logic_spec(64, alu, x as int, y as int, s.rflags); + lemma_set_rgfi(s, x64::Size::W64, 0, r.result); + } else if super::templates::shift_of(o) is Some { + let sh = super::templates::shift_of(o).unwrap(); + super::alu::lemma_step_shift_cl(cu, s, sh, x64::Size::W64, 0); + super::alu::lemma_val64_shift(o, x, y, s.rflags); + assert(x64::rr64(s, 1) == y as int); + let cnt = x64::shift_count(x64::Size::W64, x64::loghead(8, y as int)); + let res = x64::shift_spec(sh, 64, x as int, cnt, s.rflags).result; + lemma_set_rgfi(s, x64::Size::W64, 0, res); + } else { + assert(o == lir::IBin::Mul); + super::alu::lemma_step_imul_rr(cu, s, x64::Size::W64, 0, 1); + super::alu::lemma_val64_mul(x, y); + let (low, cf) = x64::imul_spec(64, y as int, x as int); + lemma_set_rgfi(s, x64::Size::W64, 0, low); + } +} + +/// A state with the same memory as a well-formed one, 16 registers of each +/// kind and a canonical `rip` is well formed. +pub proof fn lemma_wf_from(s: x64::State, s2: x64::State) + requires + x64::wf(s), + s2.rgf.len() == 16, + s2.xmm.len() == 16, + s2.mem == s.mem, + x64::canonical(s2.rip), + ensures + x64::wf(s2), +{ +} + +/// The `rip` after some of a run's instructions is canonical, when the end of +/// the whole run is. +pub proof fn lemma_rip_between(s: x64::State, ip: int, end: int) + requires + x64::wf(s), + x64::canonical(end), + s.rip <= ip <= end, + ensures + x64::canonical(ip), +{ +} + +/// `mov eax, 0; cmp rcx, rdx; setcc al` leaves 0 or 1 in `rax`: LIR's +/// comparison result. +#[verifier::rlimit(100)] +pub proof fn lemma_mid_cmp( + cu: spec_fn(nat) -> nat, + s: x64::State, + op: lir::ICmp, + sz: x64::Size, + x: u64, + y: u64, +) + requires + x64::wf(s), + s.rgf[1] == x, + s.rgf[2] == y, + sz is W32 ==> x < 0x1_0000_0000 && y < 0x1_0000_0000, + x64::canonical(s.rip + code_len(super::templates::cmp_mid(op, sz))), + ensures + run_seq(cu, s, super::templates::cmp_mid(op, sz)) is Some, + super::alu::mid_post( + s, + run_seq(cu, s, super::templates::cmp_mid(op, sz)).unwrap(), + rax(), + lir::bool_i32(lir::icmp(op, x64::nbits(sz), x as int, y as int)) as nat, + code_len(super::templates::cmp_mid(op, sz)), + ), +{ + super::memlemmas::lemma_p2_consts(); + let n = x64::nbits(sz); + let i1 = x64::Instr::MovImm32 { dst: rax(), imm_u32: 0 }; + let i2 = x64::Instr::AluRR { alu: x64::AluOp::Cmp, sz: sz, dst: rcx(), src: rdx() }; + let i3 = x64::Instr::Setcc { cc: super::templates::cc_of(op), dst: rax() }; + super::runseq::lemma_len3(i1, i2, i3); + let total = code_len(super::templates::cmp_mid(op, sz)); + assert(super::templates::cmp_mid(op, sz) == seq![i1, i2, i3]); + // 1. mov eax, 0 + super::steps::lemma_step_imm(cu, s, i1); + let s1 = x64::State { + rgf: s.rgf.update(0, 0u32 as u64), + rip: s.rip + x64::instr_len(i1), + ..s + }; + assert(x64::step(cu, s, i1) == Some(s1)); + assert(x64::canonical(s1.rip)); + lemma_wf_from(s, s1); + // 2. cmp rcx, rdx + super::flags::lemma_step_cmp(cu, s1, sz, 1, 2); + let s2 = x64::step(cu, s1, i2).unwrap(); + assert(x64::canonical(s2.rip)); + lemma_wf_from(s, s2); + assert(s1.rgf[1] == x && s1.rgf[2] == y); + assert(x64::rgfi_size(s1, sz, 1) == x as int); + assert(x64::rgfi_size(s1, sz, 2) == y as int); + assert(x64::loghead(n, x as int) == x as int); + assert(x64::loghead(n, y as int) == y as int); + super::flags::lemma_cc_icmp(s2, op, n, x as int, y as int); + // 3. setcc al + super::flags::lemma_step_setcc(cu, s2, super::templates::cc_of(op), 0); + let s3 = x64::step(cu, s2, i3).unwrap(); + assert(s2.rgf[0] == 0); + let f = super::runseq::stepper(cu); + super::runseq::lemma_gen3(f, s, i1, i2, i3, s1, s2, s3); + super::runseq::lemma_run_seq_is_gen(cu, s, seq![i1, i2, i3]); + assert(s3.rgf[0] as nat == lir::bool_i32(lir::icmp(op, n, x as int, y as int)) as nat); +} + +/// `mov eax, 0; test rcx, rcx; sete al` leaves `x == 0` in `rax`. +#[verifier::rlimit(100)] +pub proof fn lemma_mid_eqz(cu: spec_fn(nat) -> nat, s: x64::State, sz: x64::Size, x: u64) + requires + x64::wf(s), + s.rgf[1] == x, + sz is W32 ==> x < 0x1_0000_0000, + x64::canonical(s.rip + code_len(super::templates::eqz_mid(sz))), + ensures + run_seq(cu, s, super::templates::eqz_mid(sz)) is Some, + super::alu::mid_post( + s, + run_seq(cu, s, super::templates::eqz_mid(sz)).unwrap(), + rax(), + lir::bool_i32(x == 0) as nat, + code_len(super::templates::eqz_mid(sz)), + ), +{ + super::memlemmas::lemma_p2_consts(); + let n = x64::nbits(sz); + let i1 = x64::Instr::MovImm32 { dst: rax(), imm_u32: 0 }; + let i2 = x64::Instr::TestRR { sz: sz, a: rcx(), b: rcx() }; + let i3 = x64::Instr::Setcc { cc: 4, dst: rax() }; + super::runseq::lemma_len3(i1, i2, i3); + assert(super::templates::eqz_mid(sz) == seq![i1, i2, i3]); + super::steps::lemma_step_imm(cu, s, i1); + let s1 = x64::State { + rgf: s.rgf.update(0, 0u32 as u64), + rip: s.rip + x64::instr_len(i1), + ..s + }; + assert(x64::canonical(s1.rip)); + lemma_wf_from(s, s1); + super::flags::lemma_step_test(cu, s1, sz, 1, 1); + let s2 = x64::step(cu, s1, i2).unwrap(); + assert(x64::canonical(s2.rip)); + lemma_wf_from(s, s2); + assert(x64::rgfi_size(s1, sz, 1) == x as int); + assert(x64::loghead(n, x as int) == x as int); + assert((x & x) == x) by (bit_vector); + assert(((x as u64) & (x as u64)) as int == x as int); + super::flags::lemma_step_setcc(cu, s2, 4, 0); + let s3 = x64::step(cu, s2, i3).unwrap(); + assert(s2.rgf[0] == 0); + assert(x64::zf_bit() == 6); + let f = super::runseq::stepper(cu); + super::runseq::lemma_gen3(f, s, i1, i2, i3, s1, s2, s3); + super::runseq::lemma_run_seq_is_gen(cu, s, seq![i1, i2, i3]); +} + +/// `mov rcx, mask; xor/and rax, rcx` leaves `x ^ mask` or `x & mask` in `rax`. +#[verifier::rlimit(100)] +pub proof fn lemma_mid_mask( + cu: spec_fn(nat) -> nat, + s: x64::State, + alu: x64::AluOp, + mask: u64, + x: u64, +) + requires + x64::wf(s), + alu is Xor || alu is And, + s.rgf[0] == x, + x64::canonical(s.rip + code_len(super::templates::mask_mid(alu, mask))), + ensures + run_seq(cu, s, super::templates::mask_mid(alu, mask)) is Some, + super::alu::mid_post( + s, + run_seq(cu, s, super::templates::mask_mid(alu, mask)).unwrap(), + rax(), + (if alu is Xor { + x ^ mask + } else { + x & mask + }) as nat, + code_len(super::templates::mask_mid(alu, mask)), + ), +{ + super::memlemmas::lemma_p2_consts(); + let i1 = x64::Instr::MovImm64 { dst: rcx(), imm_u64: mask }; + let i2 = x64::Instr::AluRR { alu: alu, sz: x64::Size::W64, dst: rax(), src: rcx() }; + super::runseq::lemma_len2(i1, i2); + assert(super::templates::mask_mid(alu, mask) == seq![i1, i2]); + super::steps::lemma_step_imm(cu, s, i1); + let s1 = x64::State { + rgf: s.rgf.update(1, mask), + rip: s.rip + x64::instr_len(i1), + ..s + }; + assert(x64::canonical(s1.rip)); + lemma_wf_from(s, s1); + super::alu::lemma_step_alu_rr(cu, s1, alu, x64::Size::W64, 0, 1); + let s2 = x64::step(cu, s1, i2).unwrap(); + assert(x64::rgfi_size(s1, x64::Size::W64, 0) == x as int); + assert(x64::rgfi_size(s1, x64::Size::W64, 1) == mask as int); + assert(x64::loghead(64, x as int) == x as int); + assert(x64::loghead(64, mask as int) == mask as int); + let r = x64::gpr_arith_logic_spec(64, alu, x as int, mask as int, s1.rflags); + if alu is Xor { + assert(r.result == ((x as u64) ^ (mask as u64)) as int); + } else { + assert(r.result == ((x as u64) & (mask as u64)) as int); + } + lemma_set_rgfi(s1, x64::Size::W64, 0, r.result); + let f = super::runseq::stepper(cu); + super::runseq::lemma_gen2(f, s, i1, i2, s1, s2); + super::runseq::lemma_run_seq_is_gen(cu, s, seq![i1, i2]); +} + +/// `mov ecx, 0x80000000; xor rax, rcx; sub rax, rcx` sign-extends the low 32 +/// bits of `rax` to 64: LIR's `i64.extend_i32_s`. +#[verifier::rlimit(100)] +pub proof fn lemma_mid_exts(cu: spec_fn(nat) -> nat, s: x64::State, x: u32) + requires + x64::wf(s), + s.rgf[0] == x as u64, + x64::canonical(s.rip + code_len(super::templates::exts_mid())), + ensures + run_seq(cu, s, super::templates::exts_mid()) is Some, + super::alu::mid_post( + s, + run_seq(cu, s, super::templates::exts_mid()).unwrap(), + rax(), + lir::wrap(64, lir::signed_of(32, x as int)) as u64 as nat, + code_len(super::templates::exts_mid()), + ), +{ + super::memlemmas::lemma_p2_consts(); + vstd::arithmetic::power2::lemma2_to64(); + let i1 = x64::Instr::MovImm32 { dst: rcx(), imm_u32: 0x8000_0000 }; + let i2 = x64::Instr::AluRR { + alu: x64::AluOp::Xor, + sz: x64::Size::W64, + dst: rax(), + src: rcx(), + }; + let i3 = x64::Instr::AluRR { + alu: x64::AluOp::Sub, + sz: x64::Size::W64, + dst: rax(), + src: rcx(), + }; + super::runseq::lemma_len3(i1, i2, i3); + assert(super::templates::exts_mid() == seq![i1, i2, i3]); + super::steps::lemma_step_imm(cu, s, i1); + let s1 = x64::State { + rgf: s.rgf.update(1, 0x8000_0000u32 as u64), + rip: s.rip + x64::instr_len(i1), + ..s + }; + assert(x64::canonical(s1.rip)); + lemma_wf_from(s, s1); + // xor + super::alu::lemma_step_alu_rr(cu, s1, x64::AluOp::Xor, x64::Size::W64, 0, 1); + let s2 = x64::step(cu, s1, i2).unwrap(); + assert(x64::rgfi_size(s1, x64::Size::W64, 0) == x as int); + assert(x64::rgfi_size(s1, x64::Size::W64, 1) == 0x8000_0000); + assert(x64::loghead(64, x as int) == x as int); + assert(x64::loghead(64, 0x8000_0000) == 0x8000_0000); + let rx = x64::gpr_arith_logic_spec(64, x64::AluOp::Xor, x as int, 0x8000_0000, s1.rflags); + assert(rx.result == ((x as u64) ^ 0x8000_0000u64) as int); + let v: u64 = (x as u64) ^ 0x8000_0000u64; + assert(((x as u64) ^ 0x8000_0000u64) == if x < 0x8000_0000 { + (x as u64) + 0x8000_0000 + } else { + (x as u64) - 0x8000_0000 + }) by (bit_vector); + assert(v == if x < 0x8000_0000 { + (x as u64) + 0x8000_0000 + } else { + (x as u64) - 0x8000_0000 + }); + lemma_set_rgfi(s1, x64::Size::W64, 0, rx.result); + assert(s2.rgf[0] == v); + assert(s2.rgf[1] == 0x8000_0000u64); + lemma_wf_from(s, s2); + // sub + super::alu::lemma_step_alu_rr(cu, s2, x64::AluOp::Sub, x64::Size::W64, 0, 1); + let s3 = x64::step(cu, s2, i3).unwrap(); + assert(x64::rgfi_size(s2, x64::Size::W64, 0) == v as int); + assert(x64::rgfi_size(s2, x64::Size::W64, 1) == 0x8000_0000); + let rs = x64::gpr_sub_spec(64, v as int, 0x8000_0000, s2.rflags); + assert(x64::loghead(64, v as int) == v as int); + assert(x64::loghead(64, 0x8000_0000) == 0x8000_0000); + assert(v < 0x1_0000_0000); + assert(x64::logext(64, v as int) == v as int); + assert(x64::logext(64, 0x8000_0000) == 0x8000_0000); + assert(rs.result == (v as int - 0x8000_0000) % 0x1_0000_0000_0000_0000); + assert(x64::gpr_arith_logic_spec(64, x64::AluOp::Sub, v as int, 0x8000_0000, s2.rflags) + == rs); + let sg = lir::signed_of(32, x as int); + assert(lir::pow2(32) == 0x1_0000_0000); + assert(lir::pow2(32) / 2 == 0x8000_0000); + assert(sg == if x < 0x8000_0000 { + x as int + } else { + x as int - 0x1_0000_0000 + }); + assert(lir::pow2(64) == 0x1_0000_0000_0000_0000); + assert(rs.result == lir::wrap(64, sg)); + lemma_set_rgfi(s2, x64::Size::W64, 0, rs.result); + let f = super::runseq::stepper(cu); + super::runseq::lemma_gen3(f, s, i1, i2, i3, s1, s2, s3); + super::runseq::lemma_run_seq_is_gen(cu, s, seq![i1, i2, i3]); +} + +/// `mov eax, eax` leaves the low 32 bits of `rax`: LIR's `i32.wrap_i64`. +#[verifier::rlimit(100)] +pub proof fn lemma_mid_wrap(cu: spec_fn(nat) -> nat, s: x64::State, x: u64) + requires + x64::wf(s), + s.rgf[0] == x, + x64::canonical(s.rip + code_len(super::templates::wrap_mid())), + ensures + run_seq(cu, s, super::templates::wrap_mid()) is Some, + super::alu::mid_post( + s, + run_seq(cu, s, super::templates::wrap_mid()).unwrap(), + rax(), + ((x & 0xFFFF_FFFF) as u32) as nat, + code_len(super::templates::wrap_mid()), + ), +{ + super::memlemmas::lemma_p2_consts(); + let i = x64::Instr::MovRR { sz: x64::Size::W32, dst: rax(), src: rax() }; + assert(super::templates::wrap_mid() == seq![i]); + super::runseq::lemma_run_seq_one(cu, s, i); + super::runseq::lemma_code_len_one(i); + super::steps::lemma_step_mov_rr32(cu, s, 0, 0); + assert((x & 0xFFFF_FFFFu64) as u32 as u64 == x % 0x1_0000_0000u64) by (bit_vector); +} + +/// `test edx, edx; cmove rax, rcx` leaves the first value if the condition is +/// nonzero, else the second: LIR's `select`. +#[verifier::rlimit(100)] +pub proof fn lemma_mid_select( + cu: spec_fn(nat) -> nat, + s: x64::State, + v1: u64, + v2: u64, + c: u32, +) + requires + x64::wf(s), + s.rgf[0] == v1, + s.rgf[1] == v2, + s.rgf[2] == c as u64, + x64::canonical(s.rip + code_len(super::templates::select_mid())), + ensures + run_seq(cu, s, super::templates::select_mid()) is Some, + super::alu::mid_post( + s, + run_seq(cu, s, super::templates::select_mid()).unwrap(), + rax(), + (if c != 0 { + v1 + } else { + v2 + }) as nat, + code_len(super::templates::select_mid()), + ), +{ + super::memlemmas::lemma_p2_consts(); + let i1 = x64::Instr::TestRR { sz: x64::Size::W32, a: rdx(), b: rdx() }; + let i2 = x64::Instr::Cmovcc { cc: 4, sz: x64::Size::W64, dst: rax(), src: rcx() }; + super::runseq::lemma_len2(i1, i2); + assert(super::templates::select_mid() == seq![i1, i2]); + super::flags::lemma_step_test(cu, s, x64::Size::W32, 2, 2); + let s1 = x64::step(cu, s, i1).unwrap(); + assert(x64::canonical(s1.rip)); + lemma_wf_from(s, s1); + assert(x64::rgfi_size(s, x64::Size::W32, 2) == c as int); + assert(x64::loghead(32, c as int) == c as int); + assert((c & c) == c) by (bit_vector); + assert(((c as u64) & (c as u64)) as int == c as int); + assert(x64::zf_bit() == 6); + super::flags::lemma_step_cmov64(cu, s1, 4, 0, 1); + let s2 = x64::step(cu, s1, i2).unwrap(); + let f = super::runseq::stepper(cu); + super::runseq::lemma_gen2(f, s, i1, i2, s1, s2); + super::runseq::lemma_run_seq_is_gen(cu, s, seq![i1, i2]); +} + +/// A constant's load puts its word in `rax`. +pub proof fn lemma_mid_const(cu: spec_fn(nat) -> nat, s: x64::State, v: lir::Val) + requires + x64::wf(s), + x64::canonical(s.rip + code_len(seq![super::templates::const_instr(v)])), + ensures + run_seq(cu, s, seq![super::templates::const_instr(v)]) is Some, + super::alu::mid_post( + s, + run_seq(cu, s, seq![super::templates::const_instr(v)]).unwrap(), + rax(), + lir::val_bits(v), + code_len(seq![super::templates::const_instr(v)]), + ), +{ + let i = super::templates::const_instr(v); + super::runseq::lemma_run_seq_one(cu, s, i); + super::runseq::lemma_code_len_one(i); + super::steps::lemma_step_imm(cu, s, i); +} + +} // verus! diff --git a/crates/clazel-jit/src/proofs.rs b/crates/clazel-jit/src/proofs.rs new file mode 100644 index 00000000..ff47291f --- /dev/null +++ b/crates/clazel-jit/src/proofs.rs @@ -0,0 +1,1407 @@ +//! **The per-template refinement proofs.** For each instruction of the first +//! slice, [`lemma_op_refines`] proves [`refines`] of its template +//! ([`tmpl`]): running the x86-64 code from a related state reaches a state +//! related to what LIR's [`lir::eval`] says the instruction does. +//! +//! Each case unpacks LIR's semantics for the instruction (the operand +//! values, the new state), shows which slots change ([`crate::agree`]), proves +//! the template's register-only middle correct ([`crate::mid`]), and applies +//! the skeleton ([`crate::skel`]). + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// The common hypotheses of a case: the LIR state has height `h`, the machine +/// state is related to it, the code ends at a canonical address, and LIR +/// falls through to `a2`. +pub open spec fn case_pre( + lay: lir::Layout, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + code: Seq, + i: lir::Instr, + fuel: nat, +) -> bool { + a.stack.len() == h && rel(lay, a, m, nl) && x64::canonical(m.rip + code_len(code)) + && lir::eval(lay, i, a, fuel) == lir::Outcome::Normal(a2) +} + +/// A word in a slot, as the `u64` register value. +pub proof fn lemma_bits_u64(v: lir::Val) + ensures + lir::val_bits(v) < 0x1_0000_0000_0000_0000, + v is I32 ==> lir::val_bits(v) < 0x1_0000_0000, +{ + match v { + lir::Val::I32(x) => {}, + lir::Val::I64(x) => {}, + lir::Val::F64(x) => {}, + } +} + +// ---------------------------------------------------------------------------- +// Constants, locals, drop and nop +// ---------------------------------------------------------------------------- + +/// `t.const v`. +#[verifier::rlimit(200)] +pub proof fn lemma_case_const( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + v: lir::Val, + fuel: nat, +) + requires + op_ok(Op::Const(v), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Const(v), nl, h), Op::Const(v)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Const(v), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Const(v), nl, h)), + ), +{ + assert(a2 == a.with_stack(a.stack.push(v))); + super::agree::lemma_agree_push(a, a2, nl, h, v); + let mid = seq![super::templates::const_instr(v)]; + let ls = Seq::<(u8, nat)>::empty(); + assert(super::templates::tmpl(Op::Const(v), nl, h) == super::templates::shape(ls, mid, nl + h)); + assert(super::skel::loads_ok(ls, nl, a.stack.len())); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, lir::val_bits(v))) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + lir::val_bits(v), + s, + ) by { + super::mid::lemma_mid_const(cu, s, v); + } + } + super::steps::lemma_abi_consts(); + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, nl + h, lir::val_bits(v)); +} + +/// `local.get x`. +#[verifier::rlimit(200)] +pub proof fn lemma_case_local_get( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + x: usize, + fuel: nat, +) + requires + op_ok(Op::LocalGet(x), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::LocalGet(x), nl, h), Op::LocalGet(x)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::LocalGet(x), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::LocalGet(x), nl, h)), + ), +{ + let xn = x as nat; + assert(xn < a.locals.len()); + let v = a.locals[xn as int]; + assert(a2 == a.with_stack(a.stack.push(v))); + super::agree::lemma_agree_push(a, a2, nl, h, v); + let mid = Seq::::empty(); + let ls = seq![(rax(), xn)]; + assert(super::templates::tmpl(Op::LocalGet(x), nl, h) == super::templates::shape(ls, mid, nl + h)); + assert(slot_val(a, nl, xn) == v); + assert(super::skel::loads_ok(ls, nl, a.stack.len())) by { + assert(super::rel::scratch(rax())) by { + super::steps::lemma_abi_consts(); + } + assert forall|k: int| 0 <= k < ls.len() implies super::rel::scratch((#[trigger] ls[k]).0) && ls[k].1 + < nl + a.stack.len() by { + assert(k == 0); + } + } + assert(super::skel::mid_prop(cu, a, nl, ls, mid, lir::val_bits(v))) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + lir::val_bits(v), + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == lir::val_bits(slot_val(a, nl, xn))); + assert(code_len(mid) == 0); + assert(run_seq(cu, s, mid) == Some(s)); + } + } + super::steps::lemma_abi_consts(); + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, nl + h, lir::val_bits(v)); +} + +/// `local.set x` and `local.tee x`: the top's word goes to local `x`. +#[verifier::rlimit(200)] +pub proof fn lemma_case_local_set_tee( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + op: Op, + x: usize, + fuel: nat, +) + requires + op == Op::LocalSet(x) || op == Op::LocalTee(x), + op_ok(op, nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(op, nl, h), op@, fuel), + ensures + super::contract::refines_post(lay, a2, m, nl, super::templates::tmpl(op, nl, h), run_seq(cu, m, super::templates::tmpl(op, nl, h))), +{ + let xn = x as nat; + let top = (nl + h - 1) as nat; + if op == Op::LocalSet(x) { + assert(a2 == (lir::St { + stack: a.stack.drop_last(), + locals: a.locals.update(xn as int, a.stack.last()), + mem: a.mem, + })); + super::agree::lemma_agree_set(a, a2, nl, h, xn); + } else { + assert(a2 == a.with_locals(a.locals.update(xn as int, a.stack.last()))); + super::agree::lemma_agree_tee(a, a2, nl, h, xn); + } + let mid = Seq::::empty(); + let ls = seq![(rax(), top)]; + let w = lir::val_bits(slot_val(a, nl, top)); + assert(super::templates::tmpl(op, nl, h) == super::templates::shape(ls, mid, xn)); + super::steps::lemma_abi_consts(); + assert(super::skel::loads_ok(ls, nl, a.stack.len())) by { + assert(super::rel::scratch(rax())); + assert forall|k: int| 0 <= k < ls.len() implies super::rel::scratch((#[trigger] ls[k]).0) && ls[k].1 + < nl + a.stack.len() by { + assert(k == 0); + } + } + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal(cu, mid, w, s) by { + assert(s.rgf[ls[0].0 as int] as nat == lir::val_bits(slot_val(a, nl, top))); + assert(code_len(mid) == 0); + assert(run_seq(cu, s, mid) == Some(s)); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, xn, w); +} + +/// `drop` and `nop`: no code. LIR changes only the stack, and the machine's +/// frame already holds every slot that is left. +pub proof fn lemma_case_drop_nop( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + op: Op, + fuel: nat, +) + requires + op is Drop || op is Nop, + op_ok(op, nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(op, nl, h), op@, fuel), + ensures + super::contract::refines_post(lay, a2, m, nl, super::templates::tmpl(op, nl, h), run_seq(cu, m, super::templates::tmpl(op, nl, h))), +{ + assert(super::templates::tmpl(op, nl, h) == Seq::::empty()); + assert(run_seq(cu, m, super::templates::tmpl(op, nl, h)) == Some(m)); + assert(code_len(super::templates::tmpl(op, nl, h)) == 0); + if op is Drop { + assert(a2 == a.with_stack(a.stack.drop_last())); + super::agree::lemma_agree_drop(a, a2, nl, h); + } else { + assert(a2 == a); + super::agree::lemma_agree_refl(a, nl); + } + super::rel::lemma_rel_agree(lay, a, a2, m, nl); + super::agree::lemma_preserved_refl(m); +} + +// ---------------------------------------------------------------------------- +// Loads +// ---------------------------------------------------------------------------- + +/// `rax`, `rcx` and `rdx` are scratch registers. +pub proof fn lemma_scratch_regs() + ensures + super::rel::scratch(rax()), + super::rel::scratch(rcx()), + super::rel::scratch(rdx()), + rax() != rcx() && rax() != rdx() && rcx() != rdx(), +{ + super::steps::lemma_abi_consts(); +} + +/// One load of a scratch register from an existing slot. +pub proof fn lemma_loads_ok1(r: u8, j: nat, nl: nat, n: nat) + requires + super::rel::scratch(r), + j < nl + n, + ensures + super::skel::loads_ok(seq![(r, j)], nl, n), +{ + let ls = seq![(r, j)]; + assert forall|k: int| 0 <= k < ls.len() implies super::rel::scratch((#[trigger] ls[k]).0) && ls[k].1 < nl + + n by { + assert(k == 0); + } +} + +/// Two loads into distinct scratch registers from existing slots. +pub proof fn lemma_loads_ok2(r1: u8, j1: nat, r2: u8, j2: nat, nl: nat, n: nat) + requires + super::rel::scratch(r1), + super::rel::scratch(r2), + r1 != r2, + j1 < nl + n, + j2 < nl + n, + ensures + super::skel::loads_ok(seq![(r1, j1), (r2, j2)], nl, n), +{ + let ls = seq![(r1, j1), (r2, j2)]; + assert forall|k: int| 0 <= k < ls.len() implies super::rel::scratch((#[trigger] ls[k]).0) && ls[k].1 < nl + + n by { + assert(k == 0 || k == 1); + } + assert forall|k1: int, k2: int| + 0 <= k1 < k2 < ls.len() implies (#[trigger] ls[k1]).0 != (#[trigger] ls[k2]).0 by { + assert(k1 == 0 && k2 == 1); + } +} + +/// Three loads into distinct scratch registers from existing slots. +pub proof fn lemma_loads_ok3( + r1: u8, + j1: nat, + r2: u8, + j2: nat, + r3: u8, + j3: nat, + nl: nat, + n: nat, +) + requires + super::rel::scratch(r1), + super::rel::scratch(r2), + super::rel::scratch(r3), + r1 != r2 && r1 != r3 && r2 != r3, + j1 < nl + n, + j2 < nl + n, + j3 < nl + n, + ensures + super::skel::loads_ok(seq![(r1, j1), (r2, j2), (r3, j3)], nl, n), +{ + let ls = seq![(r1, j1), (r2, j2), (r3, j3)]; + assert forall|k: int| 0 <= k < ls.len() implies super::rel::scratch((#[trigger] ls[k]).0) && ls[k].1 < nl + + n by { + assert(k == 0 || k == 1 || k == 2); + } + assert forall|k1: int, k2: int| + 0 <= k1 < k2 < ls.len() implies (#[trigger] ls[k1]).0 != (#[trigger] ls[k2]).0 by { + assert(k1 == 0 || k1 == 1); + } +} + +// ---------------------------------------------------------------------------- +// select +// ---------------------------------------------------------------------------- + +/// `select`: `c == 0` picks the second value. +#[verifier::rlimit(300)] +pub proof fn lemma_case_select( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + fuel: nat, +) + requires + op_ok(Op::Select, nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Select, nl, h), Op::Select@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Select, nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Select, nl, h)), + ), +{ + lemma_scratch_regs(); + let t = (nl + h - 3) as nat; + let v1 = a.stack[(h - 3) as int]; + let v2 = a.stack[(h - 2) as int]; + match a.stack[(h - 1) as int] { + lir::Val::I32(c) => { + let r = if c != 0 { + v1 + } else { + v2 + }; + assert(a2 == a.with_stack(lir::below(a.stack, 3).push(r))); + super::agree::lemma_agree_replace(a, a2, nl, h, 3, r); + let ls = seq![(rax(), t), (rcx(), t + 1), (rdx(), t + 2)]; + let mid = super::templates::select_mid(); + let w = lir::val_bits(r); + assert(super::templates::tmpl(Op::Select, nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok3(rax(), t, rcx(), t + 1, rdx(), t + 2, nl, a.stack.len()); + assert(slot_val(a, nl, t) == v1); + assert(slot_val(a, nl, t + 1) == v2); + assert(slot_val(a, nl, t + 2) == lir::Val::I32(c)); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == lir::val_bits(v1)); + assert(s.rgf[ls[1].0 as int] as nat == lir::val_bits(v2)); + assert(s.rgf[ls[2].0 as int] as nat == c as nat); + super::mid::lemma_mid_select( + cu, + s, + lir::val_bits(v1) as u64, + lir::val_bits(v2) as u64, + c, + ); + assert(w == (if c != 0 { + lir::val_bits(v1) + } else { + lir::val_bits(v2) + })); + } + } + super::steps::lemma_abi_consts(); + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + + +// ---------------------------------------------------------------------------- +// Binary instructions +// ---------------------------------------------------------------------------- + +/// A 32-bit integer arithmetic, logic or shift instruction. +#[verifier::rlimit(500)] +pub proof fn lemma_case_bin_i32( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + o: lir::IBin, + fuel: nat, +) + requires + op_ok(Op::Bin(lir::BinOp::I32(o)), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Bin(lir::BinOp::I32(o)), nl, h), Op::Bin(lir::BinOp::I32(o))@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Bin(lir::BinOp::I32(o)), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Bin(lir::BinOp::I32(o)), nl, h)), + ), +{ + lemma_scratch_regs(); + super::steps::lemma_abi_consts(); + let t = (nl + h - 2) as nat; + match (a.stack[(h - 2) as int], a.stack[(h - 1) as int]) { + (lir::Val::I32(x), lir::Val::I32(y)) => { + let v = lir::Val::I32(lir::ibin32(o, x, y)); + assert(a2 == a.with_stack(lir::below(a.stack, 2).push(v))); + super::agree::lemma_agree_replace(a, a2, nl, h, 2, v); + let ls = seq![(rax(), t), (rcx(), t + 1)]; + let mid = seq![super::templates::int_op_instr(o, x64::Size::W32)]; + let w = lir::val_bits(v); + assert(super::templates::tmpl(Op::Bin(lir::BinOp::I32(o)), nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok2(ls[0].0, t, ls[1].0, t + 1, nl, a.stack.len()); + assert(slot_val(a, nl, t) == a.stack[(h - 2) as int]); + assert(slot_val(a, nl, t + 1) == a.stack[(h - 1) as int]); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == x as nat); + assert(s.rgf[ls[1].0 as int] as nat == y as nat); + assert(s.rgf[0] == x as u64); + assert(s.rgf[1] == y as u64); + super::runseq::lemma_code_len_one(super::templates::int_op_instr(o, x64::Size::W32)); + super::mid::lemma_mid_int32(cu, s, o, x, y); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + +/// A 64-bit integer arithmetic, logic or shift instruction. +#[verifier::rlimit(500)] +pub proof fn lemma_case_bin_i64( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + o: lir::IBin, + fuel: nat, +) + requires + op_ok(Op::Bin(lir::BinOp::I64(o)), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Bin(lir::BinOp::I64(o)), nl, h), Op::Bin(lir::BinOp::I64(o))@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Bin(lir::BinOp::I64(o)), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Bin(lir::BinOp::I64(o)), nl, h)), + ), +{ + lemma_scratch_regs(); + super::steps::lemma_abi_consts(); + let t = (nl + h - 2) as nat; + match (a.stack[(h - 2) as int], a.stack[(h - 1) as int]) { + (lir::Val::I64(x), lir::Val::I64(y)) => { + let v = lir::Val::I64(lir::ibin64(o, x, y)); + assert(a2 == a.with_stack(lir::below(a.stack, 2).push(v))); + super::agree::lemma_agree_replace(a, a2, nl, h, 2, v); + let ls = seq![(rax(), t), (rcx(), t + 1)]; + let mid = seq![super::templates::int_op_instr(o, x64::Size::W64)]; + let w = lir::val_bits(v); + assert(super::templates::tmpl(Op::Bin(lir::BinOp::I64(o)), nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok2(ls[0].0, t, ls[1].0, t + 1, nl, a.stack.len()); + assert(slot_val(a, nl, t) == a.stack[(h - 2) as int]); + assert(slot_val(a, nl, t + 1) == a.stack[(h - 1) as int]); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == x as nat); + assert(s.rgf[ls[1].0 as int] as nat == y as nat); + assert(s.rgf[0] == x); + assert(s.rgf[1] == y); + super::runseq::lemma_code_len_one(super::templates::int_op_instr(o, x64::Size::W64)); + super::mid::lemma_mid_int64(cu, s, o, x, y); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + +/// A 32-bit integer comparison. +#[verifier::rlimit(500)] +pub proof fn lemma_case_cmp_i32( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + c: lir::ICmp, + fuel: nat, +) + requires + op_ok(Op::Bin(lir::BinOp::I32Cmp(c)), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Bin(lir::BinOp::I32Cmp(c)), nl, h), Op::Bin(lir::BinOp::I32Cmp(c))@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Bin(lir::BinOp::I32Cmp(c)), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Bin(lir::BinOp::I32Cmp(c)), nl, h)), + ), +{ + lemma_scratch_regs(); + super::steps::lemma_abi_consts(); + let t = (nl + h - 2) as nat; + match (a.stack[(h - 2) as int], a.stack[(h - 1) as int]) { + (lir::Val::I32(x), lir::Val::I32(y)) => { + let v = lir::Val::I32(lir::bool_i32(lir::icmp(c, 32, x as int, y as int))); + assert(a2 == a.with_stack(lir::below(a.stack, 2).push(v))); + super::agree::lemma_agree_replace(a, a2, nl, h, 2, v); + let ls = seq![(rcx(), t), (rdx(), t + 1)]; + let mid = super::templates::cmp_mid(c, x64::Size::W32); + let w = lir::val_bits(v); + assert(super::templates::tmpl(Op::Bin(lir::BinOp::I32Cmp(c)), nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok2(ls[0].0, t, ls[1].0, t + 1, nl, a.stack.len()); + assert(slot_val(a, nl, t) == a.stack[(h - 2) as int]); + assert(slot_val(a, nl, t + 1) == a.stack[(h - 1) as int]); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == x as nat); + assert(s.rgf[ls[1].0 as int] as nat == y as nat); + assert(s.rgf[1] == x as u64); + assert(s.rgf[2] == y as u64); + assert(x64::nbits(x64::Size::W32) == 32); + super::mid::lemma_mid_cmp(cu, s, c, x64::Size::W32, x as u64, y as u64); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + +/// A 64-bit integer comparison. +#[verifier::rlimit(500)] +pub proof fn lemma_case_cmp_i64( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + c: lir::ICmp, + fuel: nat, +) + requires + op_ok(Op::Bin(lir::BinOp::I64Cmp(c)), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Bin(lir::BinOp::I64Cmp(c)), nl, h), Op::Bin(lir::BinOp::I64Cmp(c))@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Bin(lir::BinOp::I64Cmp(c)), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Bin(lir::BinOp::I64Cmp(c)), nl, h)), + ), +{ + lemma_scratch_regs(); + super::steps::lemma_abi_consts(); + let t = (nl + h - 2) as nat; + match (a.stack[(h - 2) as int], a.stack[(h - 1) as int]) { + (lir::Val::I64(x), lir::Val::I64(y)) => { + let v = lir::Val::I32(lir::bool_i32(lir::icmp(c, 64, x as int, y as int))); + assert(a2 == a.with_stack(lir::below(a.stack, 2).push(v))); + super::agree::lemma_agree_replace(a, a2, nl, h, 2, v); + let ls = seq![(rcx(), t), (rdx(), t + 1)]; + let mid = super::templates::cmp_mid(c, x64::Size::W64); + let w = lir::val_bits(v); + assert(super::templates::tmpl(Op::Bin(lir::BinOp::I64Cmp(c)), nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok2(ls[0].0, t, ls[1].0, t + 1, nl, a.stack.len()); + assert(slot_val(a, nl, t) == a.stack[(h - 2) as int]); + assert(slot_val(a, nl, t + 1) == a.stack[(h - 1) as int]); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == x as nat); + assert(s.rgf[ls[1].0 as int] as nat == y as nat); + assert(s.rgf[1] == x); + assert(s.rgf[2] == y); + assert(x64::nbits(x64::Size::W64) == 64); + super::mid::lemma_mid_cmp(cu, s, c, x64::Size::W64, x, y); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + +/// `i32.eqz`. +#[verifier::rlimit(500)] +pub proof fn lemma_case_eqz_i32( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + fuel: nat, +) + requires + op_ok(Op::Un(lir::UnOp::I32Eqz), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Un(lir::UnOp::I32Eqz), nl, h), Op::Un(lir::UnOp::I32Eqz)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Un(lir::UnOp::I32Eqz), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::I32Eqz), nl, h)), + ), +{ + lemma_scratch_regs(); + super::steps::lemma_abi_consts(); + let t = (nl + h - 1) as nat; + match a.stack[(h - 1) as int] { + lir::Val::I32(x) => { + let v = lir::Val::I32(lir::bool_i32(x == 0)); + assert(a2 == a.with_stack(lir::below(a.stack, 1).push(v))); + super::agree::lemma_agree_replace(a, a2, nl, h, 1, v); + let ls = seq![(rcx(), t)]; + let mid = super::templates::eqz_mid(x64::Size::W32); + let w = lir::val_bits(v); + assert(super::templates::tmpl(Op::Un(lir::UnOp::I32Eqz), nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok1(ls[0].0, t, nl, a.stack.len()); + assert(slot_val(a, nl, t) == a.stack[(h - 1) as int]); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == x as nat); + assert(s.rgf[1] == x as u64); + super::mid::lemma_mid_eqz(cu, s, x64::Size::W32, x as u64); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + +/// `i64.eqz`. +#[verifier::rlimit(500)] +pub proof fn lemma_case_eqz_i64( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + fuel: nat, +) + requires + op_ok(Op::Un(lir::UnOp::I64Eqz), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Un(lir::UnOp::I64Eqz), nl, h), Op::Un(lir::UnOp::I64Eqz)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Un(lir::UnOp::I64Eqz), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::I64Eqz), nl, h)), + ), +{ + lemma_scratch_regs(); + super::steps::lemma_abi_consts(); + let t = (nl + h - 1) as nat; + match a.stack[(h - 1) as int] { + lir::Val::I64(x) => { + let v = lir::Val::I32(lir::bool_i32(x == 0)); + assert(a2 == a.with_stack(lir::below(a.stack, 1).push(v))); + super::agree::lemma_agree_replace(a, a2, nl, h, 1, v); + let ls = seq![(rcx(), t)]; + let mid = super::templates::eqz_mid(x64::Size::W64); + let w = lir::val_bits(v); + assert(super::templates::tmpl(Op::Un(lir::UnOp::I64Eqz), nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok1(ls[0].0, t, nl, a.stack.len()); + assert(slot_val(a, nl, t) == a.stack[(h - 1) as int]); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == x as nat); + assert(s.rgf[1] == x); + super::mid::lemma_mid_eqz(cu, s, x64::Size::W64, x); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + +/// `f64.neg`: flip the sign bit of the word. +#[verifier::rlimit(500)] +pub proof fn lemma_case_f64_neg( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + fuel: nat, +) + requires + op_ok(Op::Un(lir::UnOp::F64Neg), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Un(lir::UnOp::F64Neg), nl, h), Op::Un(lir::UnOp::F64Neg)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Un(lir::UnOp::F64Neg), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::F64Neg), nl, h)), + ), +{ + lemma_scratch_regs(); + super::steps::lemma_abi_consts(); + let t = (nl + h - 1) as nat; + match a.stack[(h - 1) as int] { + lir::Val::F64(x) => { + let v = lir::Val::F64(x ^ 0x8000_0000_0000_0000); + assert(a2 == a.with_stack(lir::below(a.stack, 1).push(v))); + super::agree::lemma_agree_replace(a, a2, nl, h, 1, v); + let ls = seq![(rax(), t)]; + let mid = super::templates::mask_mid(x64::AluOp::Xor, 0x8000_0000_0000_0000); + let w = lir::val_bits(v); + assert(super::templates::tmpl(Op::Un(lir::UnOp::F64Neg), nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok1(ls[0].0, t, nl, a.stack.len()); + assert(slot_val(a, nl, t) == a.stack[(h - 1) as int]); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == x as nat); + assert(s.rgf[0] == x); + super::mid::lemma_mid_mask(cu, s, x64::AluOp::Xor, 0x8000_0000_0000_0000, x); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + +/// `f64.abs`: clear the sign bit of the word. +#[verifier::rlimit(500)] +pub proof fn lemma_case_f64_abs( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + fuel: nat, +) + requires + op_ok(Op::Un(lir::UnOp::F64Abs), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Un(lir::UnOp::F64Abs), nl, h), Op::Un(lir::UnOp::F64Abs)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Un(lir::UnOp::F64Abs), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::F64Abs), nl, h)), + ), +{ + lemma_scratch_regs(); + super::steps::lemma_abi_consts(); + let t = (nl + h - 1) as nat; + match a.stack[(h - 1) as int] { + lir::Val::F64(x) => { + let v = lir::Val::F64(x & 0x7FFF_FFFF_FFFF_FFFF); + assert(a2 == a.with_stack(lir::below(a.stack, 1).push(v))); + super::agree::lemma_agree_replace(a, a2, nl, h, 1, v); + let ls = seq![(rax(), t)]; + let mid = super::templates::mask_mid(x64::AluOp::And, 0x7FFF_FFFF_FFFF_FFFF); + let w = lir::val_bits(v); + assert(super::templates::tmpl(Op::Un(lir::UnOp::F64Abs), nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok1(ls[0].0, t, nl, a.stack.len()); + assert(slot_val(a, nl, t) == a.stack[(h - 1) as int]); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == x as nat); + assert(s.rgf[0] == x); + super::mid::lemma_mid_mask(cu, s, x64::AluOp::And, 0x7FFF_FFFF_FFFF_FFFF, x); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + +/// `i32.wrap_i64`. +#[verifier::rlimit(500)] +pub proof fn lemma_case_wrap( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + fuel: nat, +) + requires + op_ok(Op::Un(lir::UnOp::I32WrapI64), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Un(lir::UnOp::I32WrapI64), nl, h), Op::Un(lir::UnOp::I32WrapI64)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Un(lir::UnOp::I32WrapI64), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::I32WrapI64), nl, h)), + ), +{ + lemma_scratch_regs(); + super::steps::lemma_abi_consts(); + let t = (nl + h - 1) as nat; + match a.stack[(h - 1) as int] { + lir::Val::I64(x) => { + let v = lir::Val::I32((x & 0xFFFF_FFFF) as u32); + assert(a2 == a.with_stack(lir::below(a.stack, 1).push(v))); + super::agree::lemma_agree_replace(a, a2, nl, h, 1, v); + let ls = seq![(rax(), t)]; + let mid = super::templates::wrap_mid(); + let w = lir::val_bits(v); + assert(super::templates::tmpl(Op::Un(lir::UnOp::I32WrapI64), nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok1(ls[0].0, t, nl, a.stack.len()); + assert(slot_val(a, nl, t) == a.stack[(h - 1) as int]); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == x as nat); + assert(s.rgf[0] == x); + super::mid::lemma_mid_wrap(cu, s, x); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + +/// `i64.extend_i32_s`. +#[verifier::rlimit(500)] +pub proof fn lemma_case_extend_s( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + fuel: nat, +) + requires + op_ok(Op::Un(lir::UnOp::I64ExtendI32S), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Un(lir::UnOp::I64ExtendI32S), nl, h), Op::Un(lir::UnOp::I64ExtendI32S)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Un(lir::UnOp::I64ExtendI32S), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::I64ExtendI32S), nl, h)), + ), +{ + lemma_scratch_regs(); + super::steps::lemma_abi_consts(); + let t = (nl + h - 1) as nat; + match a.stack[(h - 1) as int] { + lir::Val::I32(x) => { + let v = lir::Val::I64(lir::wrap(64, lir::signed_of(32, x as int)) as u64); + assert(a2 == a.with_stack(lir::below(a.stack, 1).push(v))); + super::agree::lemma_agree_replace(a, a2, nl, h, 1, v); + let ls = seq![(rax(), t)]; + let mid = super::templates::exts_mid(); + let w = lir::val_bits(v); + assert(super::templates::tmpl(Op::Un(lir::UnOp::I64ExtendI32S), nl, h) == super::templates::shape(ls, mid, t)); + lemma_loads_ok1(ls[0].0, t, nl, a.stack.len()); + assert(slot_val(a, nl, t) == a.stack[(h - 1) as int]); + assert(super::skel::mid_prop(cu, a, nl, ls, mid, w)) by { + assert forall|s: x64::State| super::skel::mid_pre(a, nl, ls, mid, s) implies super::skel::mid_goal( + cu, + mid, + w, + s, + ) by { + assert(s.rgf[ls[0].0 as int] as nat == x as nat); + assert(s.rgf[0] == x as u64); + super::mid::lemma_mid_exts(cu, s, x); + } + } + super::skel::lemma_shape(cu, lay, a, a2, m, nl, ls, mid, t, w); + }, + _ => { + assert(false); + }, + } +} + +/// `i64.extend_i32_u`: the word is already zero-extended. +pub proof fn lemma_case_extend_u( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + fuel: nat, +) + requires + op_ok(Op::Un(lir::UnOp::I64ExtendI32U), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Un(lir::UnOp::I64ExtendI32U), nl, h), Op::Un(lir::UnOp::I64ExtendI32U)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Un(lir::UnOp::I64ExtendI32U), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::I64ExtendI32U), nl, h)), + ), +{ + match a.stack[(h - 1) as int] { + lir::Val::I32(x) => { + let v = lir::Val::I64(x as u64); + assert(a2 == a.with_stack(lir::below(a.stack, 1).push(v))); + assert(super::templates::tmpl(Op::Un(lir::UnOp::I64ExtendI32U), nl, h) == Seq::::empty()); + assert(run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::I64ExtendI32U), nl, h)) == Some(m)); + assert(code_len(super::templates::tmpl(Op::Un(lir::UnOp::I64ExtendI32U), nl, h)) == 0); + assert(a.stack.last() == a.stack[(h - 1) as int]); + super::agree::lemma_agree_same_word(a, a2, nl, h, v); + super::rel::lemma_rel_agree(lay, a, a2, m, nl); + super::agree::lemma_preserved_refl(m); + }, + _ => { + assert(false); + }, + } +} + +/// `f64.reinterpret_i64`: the same bits. +pub proof fn lemma_case_reinterpret_i64( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + fuel: nat, +) + requires + op_ok(Op::Un(lir::UnOp::F64ReinterpretI64), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Un(lir::UnOp::F64ReinterpretI64), nl, h), Op::Un(lir::UnOp::F64ReinterpretI64)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Un(lir::UnOp::F64ReinterpretI64), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::F64ReinterpretI64), nl, h)), + ), +{ + match a.stack[(h - 1) as int] { + lir::Val::I64(x) => { + let v = lir::Val::F64(x); + assert(a2 == a.with_stack(lir::below(a.stack, 1).push(v))); + assert(super::templates::tmpl(Op::Un(lir::UnOp::F64ReinterpretI64), nl, h) == Seq::::empty()); + assert(run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::F64ReinterpretI64), nl, h)) == Some(m)); + assert(code_len(super::templates::tmpl(Op::Un(lir::UnOp::F64ReinterpretI64), nl, h)) == 0); + assert(a.stack.last() == a.stack[(h - 1) as int]); + super::agree::lemma_agree_same_word(a, a2, nl, h, v); + super::rel::lemma_rel_agree(lay, a, a2, m, nl); + super::agree::lemma_preserved_refl(m); + }, + _ => { + assert(false); + }, + } +} + +/// `i64.reinterpret_f64`: the same bits. +pub proof fn lemma_case_reinterpret_f64( + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + h: nat, + fuel: nat, +) + requires + op_ok(Op::Un(lir::UnOp::I64ReinterpretF64), nl, h), + case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(Op::Un(lir::UnOp::I64ReinterpretF64), nl, h), Op::Un(lir::UnOp::I64ReinterpretF64)@, fuel), + ensures + super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(Op::Un(lir::UnOp::I64ReinterpretF64), nl, h), + run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::I64ReinterpretF64), nl, h)), + ), +{ + match a.stack[(h - 1) as int] { + lir::Val::F64(x) => { + let v = lir::Val::I64(x); + assert(a2 == a.with_stack(lir::below(a.stack, 1).push(v))); + assert(super::templates::tmpl(Op::Un(lir::UnOp::I64ReinterpretF64), nl, h) == Seq::::empty()); + assert(run_seq(cu, m, super::templates::tmpl(Op::Un(lir::UnOp::I64ReinterpretF64), nl, h)) == Some(m)); + assert(code_len(super::templates::tmpl(Op::Un(lir::UnOp::I64ReinterpretF64), nl, h)) == 0); + assert(a.stack.last() == a.stack[(h - 1) as int]); + super::agree::lemma_agree_same_word(a, a2, nl, h, v); + super::rel::lemma_rel_agree(lay, a, a2, m, nl); + super::agree::lemma_preserved_refl(m); + }, + _ => { + assert(false); + }, + } +} + +// ---------------------------------------------------------------------------- +// Every instruction of the slice +// ---------------------------------------------------------------------------- + +/// Instantiating [`refines`] at one state. +pub proof fn lemma_use_refines( + i: lir::Instr, + nl: nat, + h: nat, + code: Seq, + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + m: x64::State, + fuel: nat, +) + requires + super::contract::refines(i, nl, h, code), + ensures + a.stack.len() == h && rel(lay, a, m, nl) && x64::canonical(m.rip + code_len(code)) + ==> match lir::eval(lay, i, a, fuel) { + lir::Outcome::Normal(a2) => super::contract::refines_post(lay, a2, m, nl, code, run_seq(cu, m, code)), + _ => true, + }, +{ +} + +/// **The refinement of every template of the slice.** An instruction with a +/// template ([`op_ok`]) is refined by it ([`refines`]). +#[verifier::rlimit(1000)] +pub proof fn lemma_op_refines(op: Op, nl: nat, h: nat) + requires + op_ok(op, nl, h), + ensures + super::contract::refines(op@, nl, h, super::templates::tmpl(op, nl, h)), +{ + assert forall| + lay: lir::Layout, + cu: spec_fn(nat) -> nat, + a: lir::St, + m: x64::State, + fuel: nat, + | + #![trigger lir::eval(lay, op@, a, fuel), run_seq(cu, m, super::templates::tmpl(op, nl, h))] + a.stack.len() == h && rel(lay, a, m, nl) && x64::canonical(m.rip + code_len(super::templates::tmpl(op, nl, h))) + implies match lir::eval(lay, op@, a, fuel) { + lir::Outcome::Normal(a2) => super::contract::refines_post( + lay, + a2, + m, + nl, + super::templates::tmpl(op, nl, h), + run_seq(cu, m, super::templates::tmpl(op, nl, h)), + ), + _ => true, + } by { + match lir::eval(lay, op@, a, fuel) { + lir::Outcome::Normal(a2) => { + assert(case_pre(lay, a, a2, m, nl, h, super::templates::tmpl(op, nl, h), op@, fuel)); + match op { + Op::Nop => lemma_case_drop_nop(lay, cu, a, a2, m, nl, h, op, fuel), + Op::Drop => lemma_case_drop_nop(lay, cu, a, a2, m, nl, h, op, fuel), + Op::Const(v) => lemma_case_const(lay, cu, a, a2, m, nl, h, v, fuel), + Op::LocalGet(x) => lemma_case_local_get(lay, cu, a, a2, m, nl, h, x, fuel), + Op::LocalSet(x) => lemma_case_local_set_tee( + lay, + cu, + a, + a2, + m, + nl, + h, + op, + x, + fuel, + ), + Op::LocalTee(x) => lemma_case_local_set_tee( + lay, + cu, + a, + a2, + m, + nl, + h, + op, + x, + fuel, + ), + Op::Select => lemma_case_select(lay, cu, a, a2, m, nl, h, fuel), + Op::Bin(b) => match b { + lir::BinOp::I32(o) => lemma_case_bin_i32(lay, cu, a, a2, m, nl, h, o, fuel), + lir::BinOp::I64(o) => lemma_case_bin_i64(lay, cu, a, a2, m, nl, h, o, fuel), + lir::BinOp::I32Cmp(c) => lemma_case_cmp_i32( + lay, + cu, + a, + a2, + m, + nl, + h, + c, + fuel, + ), + lir::BinOp::I64Cmp(c) => lemma_case_cmp_i64( + lay, + cu, + a, + a2, + m, + nl, + h, + c, + fuel, + ), + lir::BinOp::F64(_) => { + assert(false); + }, + lir::BinOp::F64Cmp(_) => { + assert(false); + }, + }, + Op::Un(u) => match u { + lir::UnOp::I32Eqz => lemma_case_eqz_i32(lay, cu, a, a2, m, nl, h, fuel), + lir::UnOp::I64Eqz => lemma_case_eqz_i64(lay, cu, a, a2, m, nl, h, fuel), + lir::UnOp::F64Neg => lemma_case_f64_neg(lay, cu, a, a2, m, nl, h, fuel), + lir::UnOp::F64Abs => lemma_case_f64_abs(lay, cu, a, a2, m, nl, h, fuel), + lir::UnOp::I32WrapI64 => lemma_case_wrap(lay, cu, a, a2, m, nl, h, fuel), + lir::UnOp::I64ExtendI32S => lemma_case_extend_s( + lay, + cu, + a, + a2, + m, + nl, + h, + fuel, + ), + lir::UnOp::I64ExtendI32U => lemma_case_extend_u( + lay, + cu, + a, + a2, + m, + nl, + h, + fuel, + ), + lir::UnOp::F64ReinterpretI64 => lemma_case_reinterpret_i64( + lay, + cu, + a, + a2, + m, + nl, + h, + fuel, + ), + lir::UnOp::I64ReinterpretF64 => lemma_case_reinterpret_f64( + lay, + cu, + a, + a2, + m, + nl, + h, + fuel, + ), + lir::UnOp::F64Sqrt => { + assert(false); + }, + lir::UnOp::F64ConvertI32S => { + assert(false); + }, + lir::UnOp::F64ConvertI32U => { + assert(false); + }, + lir::UnOp::F64ConvertI64S => { + assert(false); + }, + lir::UnOp::F64ConvertI64U => { + assert(false); + }, + }, + } + }, + _ => {}, + } + } +} + +/// An instruction with a template changes the operand stack's height as +/// `pops` and `pushes` say, keeps the locals' count and memory. +pub proof fn lemma_op_height( + op: Op, + nl: nat, + h: nat, + lay: lir::Layout, + a: lir::St, + a2: lir::St, + fuel: nat, +) + requires + op_ok(op, nl, h), + a.stack.len() == h, + lir::eval(lay, op@, a, fuel) == lir::Outcome::Normal(a2), + ensures + a2.stack.len() == height_after_op(op, h), +{ + assert(fuel > 0); + match op { + Op::Nop => {}, + Op::Drop => {}, + Op::Const(v) => {}, + Op::LocalGet(x) => {}, + Op::LocalSet(x) => {}, + Op::LocalTee(x) => {}, + Op::Select => { + match a.stack[(h - 1) as int] { + lir::Val::I32(c) => { + assert(a2.stack.len() == (h - 3) + 1); + }, + _ => { + assert(false); + }, + } + }, + Op::Bin(b) => { + match lir::bin_eval(b, a.stack[(h - 2) as int], a.stack[(h - 1) as int]) { + Some(v) => { + assert(a2.stack.len() == (h - 2) + 1); + }, + None => { + assert(false); + }, + } + }, + Op::Un(u) => { + match lir::un_eval(u, a.stack[(h - 1) as int]) { + Some(v) => { + assert(a2.stack.len() == (h - 1) + 1); + }, + None => { + assert(false); + }, + } + }, + } +} + +} // verus! diff --git a/crates/clazel-jit/src/rel.rs b/crates/clazel-jit/src/rel.rs new file mode 100644 index 00000000..42aeace9 --- /dev/null +++ b/crates/clazel-jit/src/rel.rs @@ -0,0 +1,229 @@ +//! Lemmas about the state relation [`rel`]: it survives a change that only +//! touches scratch registers, a load into a scratch register, and a store to +//! one frame slot (when the LIR state changes at that slot only). + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// A register a template may write: not the context register, not `rsp`. +pub open spec fn scratch(r: u8) -> bool { + r < 16 && r != abi::ctx_reg() && r != abi::sp_reg() +} + +/// `rel` does not mention registers other than `r15`, nor the flags, `rip` +/// (beyond being canonical) or the XMM registers: a state with the same +/// memory and context register is related to what `m` was. +pub proof fn lemma_rel_regs( + lay: lir::Layout, + a: lir::St, + m: x64::State, + m3: x64::State, + nl: nat, +) + requires + rel(lay, a, m, nl), + m3.mem == m.mem, + m3.rgf.len() == 16, + m3.xmm.len() == 16, + m3.rgf[abi::ctx_reg() as int] == m.rgf[abi::ctx_reg() as int], + x64::canonical(m3.rip), + ensures + rel(lay, a, m3, nl), +{ + super::steps::lemma_abi_consts(); + assert(ctx_of(m3) == ctx_of(m)); + assert(x64::wf(m3)); + assert(ctx_ok(m3)); +} + +/// `mov r, [slot j]` for a scratch register `r`: loads the slot's word, and the +/// state stays related to the same LIR state. +pub proof fn lemma_load_rel( + cu: spec_fn(nat) -> nat, + lay: lir::Layout, + a: lir::St, + m: x64::State, + r: u8, + j: nat, + nl: nat, +) + requires + rel(lay, a, m, nl), + scratch(r), + j < nl + a.stack.len(), + x64::canonical(m.rip + x64::instr_len(super::templates::load_slot(r, j))), + ensures + x64::step(cu, m, super::templates::load_slot(r, j)) is Some, + ({ + let m1 = x64::step(cu, m, super::templates::load_slot(r, j)).unwrap(); + &&& m1 == x64::State { + rgf: m.rgf.update(r as int, lir::val_bits(slot_val(a, nl, j)) as u64), + rip: m.rip + x64::instr_len(super::templates::load_slot(r, j)), + ..m + } + &&& rel(lay, a, m1, nl) + &&& m1.rgf[r as int] as nat == lir::val_bits(slot_val(a, nl, j)) + }), +{ + super::steps::lemma_abi_consts(); + super::memlemmas::lemma_p2_consts(); + let v = lir::val_bits(slot_val(a, nl, j)); + assert(slot_holds(m.mem, ctx_of(m), j, v)); + assert(v < 0x1_0000_0000_0000_0000) by { + match slot_val(a, nl, j) { + lir::Val::I32(x) => {}, + lir::Val::I64(x) => {}, + lir::Val::F64(x) => {}, + } + } + assert(j < max_slots()); + super::steps::lemma_step_load_slot(cu, m, r, j, v); + let m1 = x64::step(cu, m, super::templates::load_slot(r, j)).unwrap(); + assert(m1.rgf.len() == 16); + lemma_rel_regs(lay, a, m, m1, nl); + assert(m1.rgf[r as int] == v as u64); +} + +/// The LIR state `a2` has the slots of `a` except at `ts`: same locals count, +/// same memory, a frame that fits, and every other slot holds the same word. +pub open spec fn slots_agree_except(a: lir::St, a2: lir::St, nl: nat, ts: nat) -> bool { + a2.locals.len() == nl && nl + a2.stack.len() <= max_slots() && a2.mem == a.mem && ts < nl + + a2.stack.len() && forall|j: nat| + #![trigger lir::val_bits(slot_val(a2, nl, j))] + j < nl + a2.stack.len() && j != ts ==> j < nl + a.stack.len() && lir::val_bits( + slot_val(a2, nl, j), + ) == lir::val_bits(slot_val(a, nl, j)) +} + +/// As [`slots_agree_except`], with no exception: the slots of `a2` are all +/// slots of `a`, with the same words. +pub open spec fn slots_agree(a: lir::St, a2: lir::St, nl: nat) -> bool { + a2.locals.len() == nl && nl + a2.stack.len() <= max_slots() && a2.mem == a.mem && forall| + j: nat, + | + #![trigger lir::val_bits(slot_val(a2, nl, j))] + j < nl + a2.stack.len() ==> j < nl + a.stack.len() && lir::val_bits(slot_val(a2, nl, j)) + == lir::val_bits(slot_val(a, nl, j)) +} + +/// If the slots of `a2` are slots of `a` with the same words, `a2` is related +/// to whatever `a` was. +pub proof fn lemma_rel_agree(lay: lir::Layout, a: lir::St, a2: lir::St, m: x64::State, nl: nat) + requires + rel(lay, a, m, nl), + slots_agree(a, a2, nl), + ensures + rel(lay, a2, m, nl), +{ + assert forall|j: nat| j < nl + a2.stack.len() implies #[trigger] slot_holds( + m.mem, + ctx_of(m), + j, + lir::val_bits(slot_val(a2, nl, j)), + ) by { + assert(lir::val_bits(slot_val(a2, nl, j)) >= 0); + assert(j < nl + a.stack.len()); + assert(slot_holds(m.mem, ctx_of(m), j, lir::val_bits(slot_val(a, nl, j)))); + } +} + +/// The exit area is within the context. +pub proof fn lemma_slot_in_exit_area(ctxb: int, j: nat, b: int) + requires + j < max_slots(), + ctxb + slot_disp(j) <= b < ctxb + slot_disp(j) + 8, + ensures + in_exit_area(ctxb, b), +{ + super::steps::lemma_abi_consts(); +} + +/// `mov [slot ts], rd` finishes a template: from a state `m3` related to the +/// LIR state `a` (the template's registers computed, memory untouched since +/// `m0`, where the template began), with `rd` holding the word `w` that `a2` +/// keeps in slot `ts`, the store leaves a state related to `a2`, and `m0` +/// and the result differ in the exit area only ([`preserved`]). +pub proof fn lemma_store_finish( + cu: spec_fn(nat) -> nat, + lay: lir::Layout, + a: lir::St, + a2: lir::St, + m0: x64::State, + m3: x64::State, + nl: nat, + ts: nat, + rd: u8, + w: nat, +) + requires + rel(lay, a, m3, nl), + rel(lay, a, m0, nl), + m3.mem == m0.mem, + m3.rgf[abi::sp_reg() as int] == m0.rgf[abi::sp_reg() as int], + m3.rgf[abi::ctx_reg() as int] == m0.rgf[abi::ctx_reg() as int], + slots_agree_except(a, a2, nl, ts), + w == lir::val_bits(slot_val(a2, nl, ts)), + ts < max_slots(), + rd < 16, + m3.rgf[rd as int] as nat == w, + x64::canonical(m3.rip + x64::instr_len(super::templates::store_slot(ts, rd))), + ensures + x64::step(cu, m3, super::templates::store_slot(ts, rd)) is Some, + ({ + let m4 = x64::step(cu, m3, super::templates::store_slot(ts, rd)).unwrap(); + &&& rel(lay, a2, m4, nl) + &&& m4.rip == m3.rip + x64::instr_len(super::templates::store_slot(ts, rd)) + &&& preserved(m0, m4) + }), +{ + super::steps::lemma_abi_consts(); + let ctxb = ctx_of(m3); + assert(ctx_of(m0) == ctxb); + super::steps::lemma_step_store_slot(cu, m3, rd, ts); + let m4 = x64::step(cu, m3, super::templates::store_slot(ts, rd)).unwrap(); + assert(m4.rgf == m3.rgf && m4.xmm == m3.xmm); + assert(x64::wf(m4)) by { + assert(m4.mem.dom() =~= m3.mem.dom()); + } + assert(ctx_of(m4) == ctxb); + assert(ctx_ok(m4)); + assert(exit_area_mapped(m4.mem, ctxb)); + // every slot of a2 + assert forall|j: nat| j < nl + a2.stack.len() implies #[trigger] slot_holds( + m4.mem, + ctxb, + j, + lir::val_bits(slot_val(a2, nl, j)), + ) by { + assert(lir::val_bits(slot_val(a2, nl, j)) >= 0); + if j == ts { + } else { + assert(j < nl + a.stack.len()); + assert(slot_holds(m3.mem, ctxb, j, lir::val_bits(slot_val(a, nl, j)))); + assert(j < max_slots()); + } + } + // memory outside the exit area is untouched + assert forall|b: int| #[trigger] m0.mem.dom().contains(b) && !in_exit_area(ctxb, b) implies m4.mem[b] + == m0.mem[b] by { + if b < ctxb + slot_disp(ts) || ctxb + slot_disp(ts) + 8 <= b { + } else { + lemma_slot_in_exit_area(ctxb, ts, b); + } + } + assert(mem_rel(lay, a2.mem, m4.mem)) by { + assert forall|b: nat| #[trigger] in_regions(lay, b) implies m4.mem.dom().contains(b as int) + && m4.mem[b as int] == lir::byte_at(a2.mem, b) by { + assert(!in_exit_area(ctxb, b as int)); + assert(m3.mem.dom().contains(b as int) && m3.mem[b as int] == lir::byte_at(a.mem, b)); + assert(m0.mem.dom().contains(b as int)); + } + } + assert(preserved_mem(m0, m4)); +} + +} // verus! diff --git a/crates/clazel-jit/src/runseq.rs b/crates/clazel-jit/src/runseq.rs new file mode 100644 index 00000000..39c8b46c --- /dev/null +++ b/crates/clazel-jit/src/runseq.rs @@ -0,0 +1,353 @@ +//! Facts about [`run_seq`], [`code_len`] and the machine states a run passes +//! through: running a concatenation is running one list and then the other, +//! lengths add, and `rip` stays canonical along the way. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// `code_len` of a concatenation. +pub proof fn lemma_code_len_append(a: Seq, b: Seq) + ensures + code_len(a + b) == code_len(a) + code_len(b), + decreases a.len(), +{ + if a.len() > 0 { + assert((a + b).skip(1) =~= a.skip(1) + b); + assert((a + b)[0] == a[0]); + lemma_code_len_append(a.skip(1), b); + } else { + assert(a + b =~= b); + } +} + +/// Running `a + b` is running `a`, then `b` from where `a` ended (and a +/// fault in `a` is a fault). +pub proof fn lemma_run_seq_append( + cu: spec_fn(nat) -> nat, + s: x64::State, + a: Seq, + b: Seq, +) + ensures + run_seq(cu, s, a + b) == match run_seq(cu, s, a) { + Some(s1) => run_seq(cu, s1, b), + None => None, + }, + decreases a.len(), +{ + if a.len() == 0 { + assert(a + b =~= b); + } else { + assert((a + b).skip(1) =~= a.skip(1) + b); + assert((a + b)[0] == a[0]); + match x64::step(cu, s, a[0]) { + Some(s1) => { + lemma_run_seq_append(cu, s1, a.skip(1), b); + }, + None => {}, + } + } +} + +/// A one-instruction run is the step. +pub proof fn lemma_run_seq_one(cu: spec_fn(nat) -> nat, s: x64::State, i: x64::Instr) + ensures + run_seq(cu, s, seq![i]) == x64::step(cu, s, i), +{ + let e = Seq::::empty(); + assert(seq![i].len() == 1); + assert(seq![i][0] == i); + assert(seq![i].skip(1) =~= e); + match x64::step(cu, s, i) { + Some(s1) => { + assert(run_seq(cu, s1, e) == Some(s1)); + }, + None => {}, + } +} + +/// The code length of a one-instruction list. +pub proof fn lemma_code_len_one(i: x64::Instr) + ensures + code_len(seq![i]) == x64::instr_len(i), +{ + let e = Seq::::empty(); + assert(seq![i].len() == 1); + assert(seq![i][0] == i); + assert(seq![i].skip(1) =~= e); + assert(code_len(e) == 0); +} + +/// An address between two canonical addresses is canonical. +pub proof fn lemma_canonical_between(lo: int, mid: int, hi: int) + requires + x64::canonical(lo), + x64::canonical(hi), + lo <= mid <= hi, + ensures + x64::canonical(mid), +{ +} + +/// Running an instruction followed by more: the step, then the rest. +pub proof fn lemma_run_seq_cons( + cu: spec_fn(nat) -> nat, + s: x64::State, + i: x64::Instr, + rest: Seq, +) + ensures + run_seq(cu, s, seq![i] + rest) == match x64::step(cu, s, i) { + Some(s1) => run_seq(cu, s1, rest), + None => None, + }, + code_len(seq![i] + rest) == x64::instr_len(i) + code_len(rest), +{ + let code = seq![i] + rest; + assert(code.len() > 0); + assert(code[0] == i); + assert(code.skip(1) =~= rest); +} + +/// [`run_seq`] with the step function abstracted: the lemmas about long +/// instruction lists are proven for an arbitrary `f`, so the solver does not +/// unfold `x64::step` on instructions it knows nothing about. +pub open spec fn run_gen( + f: spec_fn(x64::State, x64::Instr) -> Option, + s: x64::State, + code: Seq, +) -> Option + decreases code.len(), +{ + if code.len() == 0 { + Some(s) + } else { + match f(s, code[0]) { + Some(s1) => run_gen(f, s1, code.skip(1)), + None => None, + } + } +} + +/// The machine's step as a function value. +pub open spec fn stepper(cu: spec_fn(nat) -> nat) -> spec_fn(x64::State, x64::Instr) -> Option< + x64::State, +> { + |s1: x64::State, i: x64::Instr| x64::step(cu, s1, i) +} + +/// `run_seq` is `run_gen` for the machine's step. +pub proof fn lemma_run_seq_is_gen(cu: spec_fn(nat) -> nat, s: x64::State, code: Seq) + ensures + run_seq(cu, s, code) == run_gen(stepper(cu), s, code), + decreases code.len(), +{ + if code.len() > 0 { + match x64::step(cu, s, code[0]) { + Some(s1) => { + lemma_run_seq_is_gen(cu, s1, code.skip(1)); + }, + None => {}, + } + } +} + +/// A list is its head consed on its tail. Generic in the element type, so the +/// solver does not unfold `Instr`. +pub proof fn lemma_seq_cons(whole: Seq, x: A, rest: Seq) + requires + whole.len() == rest.len() + 1, + whole[0] == x, + forall|k: int| 0 <= k < rest.len() ==> #[trigger] whole[k + 1] == rest[k], + ensures + whole =~= seq![x] + rest, +{ + assert forall|k: int| 0 <= k < whole.len() implies whole[k] == (seq![x] + rest)[k] by { + if k > 0 { + assert(whole[(k - 1) + 1] == rest[k - 1]); + } + } +} + +/// The code length of a list is its head's length and its tail's. +pub proof fn lemma_code_len_cons(i: x64::Instr, rest: Seq) + ensures + code_len(seq![i] + rest) == x64::instr_len(i) + code_len(rest), +{ + let code = seq![i] + rest; + assert(code.len() > 0); + assert(code[0] == i); + assert(code.skip(1) =~= rest); +} + +/// `run_gen` of a list is the head's step, then the tail. +pub proof fn lemma_run_gen_cons( + f: spec_fn(x64::State, x64::Instr) -> Option, + s: x64::State, + i: x64::Instr, + rest: Seq, +) + ensures + run_gen(f, s, seq![i] + rest) == match f(s, i) { + Some(s1) => run_gen(f, s1, rest), + None => None, + }, +{ + let code = seq![i] + rest; + assert(code.len() > 0); + assert(code[0] == i); + assert(code.skip(1) =~= rest); +} + +/// `run_gen` of a list of 1 instruction whose steps are known. +pub proof fn lemma_gen1(f: spec_fn(x64::State, x64::Instr) -> Option, s: x64::State, a: x64::Instr, s1: x64::State) + requires + f(s, a) == Some(s1), + ensures + run_gen(f, s, seq![a]) == Some(s1), +{ + let e = Seq::::empty(); + lemma_seq_cons(seq![a], a, e); + lemma_run_gen_cons(f, s, a, e); +} + +/// The code length of a list of 1 instruction. +pub proof fn lemma_len1(a: x64::Instr) + ensures + code_len(seq![a]) == x64::instr_len(a), +{ + let e = Seq::::empty(); + lemma_seq_cons(seq![a], a, e); + lemma_code_len_cons(a, e); +} + +/// `run_gen` of a list of 2 instructions whose steps are known. +pub proof fn lemma_gen2(f: spec_fn(x64::State, x64::Instr) -> Option, s: x64::State, a: x64::Instr, b: x64::Instr, s1: x64::State, s2: x64::State) + requires + f(s, a) == Some(s1), + f(s1, b) == Some(s2), + ensures + run_gen(f, s, seq![a, b]) == Some(s2), +{ + lemma_gen1(f, s1, b, s2); + lemma_seq_cons(seq![a, b], a, seq![b]); + lemma_run_gen_cons(f, s, a, seq![b]); +} + +/// The code length of a list of 2 instructions. +pub proof fn lemma_len2(a: x64::Instr, b: x64::Instr) + ensures + code_len(seq![a, b]) == x64::instr_len(a) + x64::instr_len(b), +{ + lemma_len1(b); + lemma_seq_cons(seq![a, b], a, seq![b]); + lemma_code_len_cons(a, seq![b]); +} + +/// `run_gen` of a list of 3 instructions whose steps are known. +pub proof fn lemma_gen3(f: spec_fn(x64::State, x64::Instr) -> Option, s: x64::State, a: x64::Instr, b: x64::Instr, c: x64::Instr, s1: x64::State, s2: x64::State, s3: x64::State) + requires + f(s, a) == Some(s1), + f(s1, b) == Some(s2), + f(s2, c) == Some(s3), + ensures + run_gen(f, s, seq![a, b, c]) == Some(s3), +{ + lemma_gen2(f, s1, b, c, s2, s3); + lemma_seq_cons(seq![a, b, c], a, seq![b, c]); + lemma_run_gen_cons(f, s, a, seq![b, c]); +} + +/// The code length of a list of 3 instructions. +pub proof fn lemma_len3(a: x64::Instr, b: x64::Instr, c: x64::Instr) + ensures + code_len(seq![a, b, c]) == x64::instr_len(a) + x64::instr_len(b) + x64::instr_len(c), +{ + lemma_len2(b, c); + lemma_seq_cons(seq![a, b, c], a, seq![b, c]); + lemma_code_len_cons(a, seq![b, c]); +} + +/// `run_gen` of a list of 4 instructions whose steps are known. +pub proof fn lemma_gen4(f: spec_fn(x64::State, x64::Instr) -> Option, s: x64::State, a: x64::Instr, b: x64::Instr, c: x64::Instr, d: x64::Instr, s1: x64::State, s2: x64::State, s3: x64::State, s4: x64::State) + requires + f(s, a) == Some(s1), + f(s1, b) == Some(s2), + f(s2, c) == Some(s3), + f(s3, d) == Some(s4), + ensures + run_gen(f, s, seq![a, b, c, d]) == Some(s4), +{ + lemma_gen3(f, s1, b, c, d, s2, s3, s4); + lemma_seq_cons(seq![a, b, c, d], a, seq![b, c, d]); + lemma_run_gen_cons(f, s, a, seq![b, c, d]); +} + +/// The code length of a list of 4 instructions. +pub proof fn lemma_len4(a: x64::Instr, b: x64::Instr, c: x64::Instr, d: x64::Instr) + ensures + code_len(seq![a, b, c, d]) == x64::instr_len(a) + x64::instr_len(b) + x64::instr_len(c) + x64::instr_len(d), +{ + lemma_len3(b, c, d); + lemma_seq_cons(seq![a, b, c, d], a, seq![b, c, d]); + lemma_code_len_cons(a, seq![b, c, d]); +} + +/// `run_gen` of a list of 5 instructions whose steps are known. +pub proof fn lemma_gen5(f: spec_fn(x64::State, x64::Instr) -> Option, s: x64::State, a: x64::Instr, b: x64::Instr, c: x64::Instr, d: x64::Instr, e: x64::Instr, s1: x64::State, s2: x64::State, s3: x64::State, s4: x64::State, s5: x64::State) + requires + f(s, a) == Some(s1), + f(s1, b) == Some(s2), + f(s2, c) == Some(s3), + f(s3, d) == Some(s4), + f(s4, e) == Some(s5), + ensures + run_gen(f, s, seq![a, b, c, d, e]) == Some(s5), +{ + lemma_gen4(f, s1, b, c, d, e, s2, s3, s4, s5); + lemma_seq_cons(seq![a, b, c, d, e], a, seq![b, c, d, e]); + lemma_run_gen_cons(f, s, a, seq![b, c, d, e]); +} + +/// The code length of a list of 5 instructions. +pub proof fn lemma_len5(a: x64::Instr, b: x64::Instr, c: x64::Instr, d: x64::Instr, e: x64::Instr) + ensures + code_len(seq![a, b, c, d, e]) == x64::instr_len(a) + x64::instr_len(b) + x64::instr_len(c) + x64::instr_len(d) + x64::instr_len(e), +{ + lemma_len4(b, c, d, e); + lemma_seq_cons(seq![a, b, c, d, e], a, seq![b, c, d, e]); + lemma_code_len_cons(a, seq![b, c, d, e]); +} + +/// `run_gen` of a list of 6 instructions whose steps are known. +pub proof fn lemma_gen6(f: spec_fn(x64::State, x64::Instr) -> Option, s: x64::State, a: x64::Instr, b: x64::Instr, c: x64::Instr, d: x64::Instr, e: x64::Instr, g: x64::Instr, s1: x64::State, s2: x64::State, s3: x64::State, s4: x64::State, s5: x64::State, s6: x64::State) + requires + f(s, a) == Some(s1), + f(s1, b) == Some(s2), + f(s2, c) == Some(s3), + f(s3, d) == Some(s4), + f(s4, e) == Some(s5), + f(s5, g) == Some(s6), + ensures + run_gen(f, s, seq![a, b, c, d, e, g]) == Some(s6), +{ + lemma_gen5(f, s1, b, c, d, e, g, s2, s3, s4, s5, s6); + lemma_seq_cons(seq![a, b, c, d, e, g], a, seq![b, c, d, e, g]); + lemma_run_gen_cons(f, s, a, seq![b, c, d, e, g]); +} + +/// The code length of a list of 6 instructions. +pub proof fn lemma_len6(a: x64::Instr, b: x64::Instr, c: x64::Instr, d: x64::Instr, e: x64::Instr, g: x64::Instr) + ensures + code_len(seq![a, b, c, d, e, g]) == x64::instr_len(a) + x64::instr_len(b) + x64::instr_len(c) + x64::instr_len(d) + x64::instr_len(e) + x64::instr_len(g), +{ + lemma_len5(b, c, d, e, g); + lemma_seq_cons(seq![a, b, c, d, e, g], a, seq![b, c, d, e, g]); + lemma_code_len_cons(a, seq![b, c, d, e, g]); +} + +} // verus! diff --git a/crates/clazel-jit/src/skel.rs b/crates/clazel-jit/src/skel.rs new file mode 100644 index 00000000..d6ecdee2 --- /dev/null +++ b/crates/clazel-jit/src/skel.rs @@ -0,0 +1,209 @@ +//! The skeleton every storing template shares: *loads, a register-only middle, +//! one store*. [`lemma_loads`] runs the loads, and [`lemma_shape`] puts the +//! three parts together: given a middle that leaves the result word in `rax` +//! (the hypothesis, proven per template in [`crate::mid`]), the whole template +//! takes a state related to `a` to a state related to the next LIR state `a2`. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// The loads in `ls` read distinct scratch registers from existing slots. +pub open spec fn loads_ok(ls: Seq<(u8, nat)>, nl: nat, n: nat) -> bool { + (forall|k: int| + 0 <= k < ls.len() ==> super::rel::scratch((#[trigger] ls[k]).0) && ls[k].1 < nl + n) && (forall| + k1: int, + k2: int, + | + 0 <= k1 < k2 < ls.len() ==> (#[trigger] ls[k1]).0 != (#[trigger] ls[k2]).0) +} + +/// What the middle of a template is started from: a well-formed state whose +/// registers hold the words the loads `ls` would have put there. +pub open spec fn mid_pre( + a: lir::St, + nl: nat, + ls: Seq<(u8, nat)>, + mid: Seq, + s: x64::State, +) -> bool { + x64::wf(s) && s.rgf.len() == 16 && (forall|k: int| + 0 <= k < ls.len() ==> (#[trigger] s.rgf[ls[k].0 as int]) as nat == lir::val_bits( + slot_val(a, nl, ls[k].1), + )) && x64::canonical(s.rip + code_len(mid)) +} + +/// What the middle must do from there: not fault, and leave `w` in `rax` +/// changing only scratch registers and `rip` ([`mid_post`]). +pub open spec fn mid_goal( + cu: spec_fn(nat) -> nat, + mid: Seq, + w: nat, + s: x64::State, +) -> bool { + run_seq(cu, s, mid) is Some && super::alu::mid_post( + s, + run_seq(cu, s, mid).unwrap(), + rax(), + w, + code_len(mid), + ) +} + +/// The middle does what it must from every state it can be started from. +pub open spec fn mid_prop( + cu: spec_fn(nat) -> nat, + a: lir::St, + nl: nat, + ls: Seq<(u8, nat)>, + mid: Seq, + w: nat, +) -> bool { + forall|s: x64::State| + #![trigger mid_goal(cu, mid, w, s)] + mid_pre(a, nl, ls, mid, s) ==> mid_goal(cu, mid, w, s) +} + +/// Running the loads `ls`: each register holds its slot's word, and the state +/// is still related to `a`, with the same memory. +#[verifier::rlimit(1000)] +pub proof fn lemma_loads( + cu: spec_fn(nat) -> nat, + lay: lir::Layout, + a: lir::St, + m: x64::State, + ls: Seq<(u8, nat)>, + nl: nat, +) + requires + rel(lay, a, m, nl), + loads_ok(ls, nl, a.stack.len()), + x64::canonical(m.rip + code_len(super::templates::loads_seq(ls))), + ensures + run_seq(cu, m, super::templates::loads_seq(ls)) is Some, + ({ + let m1 = run_seq(cu, m, super::templates::loads_seq(ls)).unwrap(); + &&& rel(lay, a, m1, nl) + &&& m1.rip == m.rip + code_len(super::templates::loads_seq(ls)) + &&& m1.mem == m.mem + &&& m1.rgf.len() == 16 + &&& m1.xmm.len() == 16 + &&& m1.rgf[abi::ctx_reg() as int] == m.rgf[abi::ctx_reg() as int] + &&& m1.rgf[abi::sp_reg() as int] == m.rgf[abi::sp_reg() as int] + &&& forall|k: int| + 0 <= k < ls.len() ==> (#[trigger] m1.rgf[ls[k].0 as int]) as nat == lir::val_bits( + slot_val(a, nl, ls[k].1), + ) + }), + decreases ls.len(), +{ + super::steps::lemma_abi_consts(); + if ls.len() == 0 { + assert(super::templates::loads_seq(ls) =~= seq![]); + assert(code_len(Seq::::empty()) == 0); + } else { + let pre = ls.drop_last(); + let last = ls.last(); + let a_code = super::templates::loads_seq(pre); + let b_code = seq![super::templates::load_slot(last.0, last.1)]; + assert(super::templates::loads_seq(ls) == a_code + b_code); + super::runseq::lemma_code_len_append(a_code, b_code); + super::runseq::lemma_code_len_one(super::templates::load_slot(last.0, last.1)); + assert(loads_ok(pre, nl, a.stack.len())) by { + assert forall|k: int| 0 <= k < pre.len() implies super::rel::scratch((#[trigger] pre[k]).0) + && pre[k].1 < nl + a.stack.len() by { + assert(pre[k] == ls[k]); + } + assert forall|k1: int, k2: int| + 0 <= k1 < k2 < pre.len() implies (#[trigger] pre[k1]).0 != (#[trigger] pre[k2]).0 by { + assert(pre[k1] == ls[k1] && pre[k2] == ls[k2]); + } + } + lemma_loads(cu, lay, a, m, pre, nl); + let m1 = run_seq(cu, m, a_code).unwrap(); + super::runseq::lemma_run_seq_append(cu, m, a_code, b_code); + assert(super::rel::scratch(last.0) && last.1 < nl + a.stack.len()); + super::rel::lemma_load_rel(cu, lay, a, m1, last.0, last.1, nl); + super::runseq::lemma_run_seq_one(cu, m1, super::templates::load_slot(last.0, last.1)); + let m2 = x64::step(cu, m1, super::templates::load_slot(last.0, last.1)).unwrap(); + assert(m2.rgf.len() == 16); + assert forall|k: int| 0 <= k < ls.len() implies (#[trigger] m2.rgf[ls[k].0 as int]) as nat + == lir::val_bits(slot_val(a, nl, ls[k].1)) by { + if k < ls.len() - 1 { + assert(pre[k] == ls[k]); + assert(ls[k].0 != last.0); + } + } + } +} + +/// **The skeleton.** A template made of loads `ls`, a register-only middle +/// `mid` and a store of `rax` to slot `ts` takes a state related to `a` to one +/// related to `a2`, if: +/// +/// - `a2` differs from `a` in slot `ts` only, where it holds `w` +/// ([`slots_agree_except`]); +/// - the middle, started from any well-formed state whose registers hold the +/// loaded words, leaves `w` in `rax` and changes only scratch registers and +/// `rip` ([`mid_post`]). +pub proof fn lemma_shape( + cu: spec_fn(nat) -> nat, + lay: lir::Layout, + a: lir::St, + a2: lir::St, + m: x64::State, + nl: nat, + ls: Seq<(u8, nat)>, + mid: Seq, + ts: nat, + w: nat, +) + requires + rel(lay, a, m, nl), + loads_ok(ls, nl, a.stack.len()), + x64::canonical(m.rip + code_len(super::templates::shape(ls, mid, ts))), + ts < max_slots(), + super::rel::slots_agree_except(a, a2, nl, ts), + w == lir::val_bits(slot_val(a2, nl, ts)), + mid_prop(cu, a, nl, ls, mid, w), + ensures + run_seq(cu, m, super::templates::shape(ls, mid, ts)) is Some, + ({ + let m4 = run_seq(cu, m, super::templates::shape(ls, mid, ts)).unwrap(); + &&& rel(lay, a2, m4, nl) + &&& m4.rip == m.rip + code_len(super::templates::shape(ls, mid, ts)) + &&& preserved(m, m4) + }), +{ + super::steps::lemma_abi_consts(); + let ld = super::templates::loads_seq(ls); + let st = seq![super::templates::store_slot(ts, rax())]; + super::runseq::lemma_code_len_append(ld, mid); + super::runseq::lemma_code_len_append(ld + mid, st); + super::runseq::lemma_code_len_one(super::templates::store_slot(ts, rax())); + assert(super::templates::shape(ls, mid, ts) == (ld + mid) + st); + lemma_loads(cu, lay, a, m, ls, nl); + let m1 = run_seq(cu, m, ld).unwrap(); + // the middle + assert(x64::wf(m1)); + assert(x64::canonical(m1.rip + code_len(mid))); + assert(mid_pre(a, nl, ls, mid, m1)); + assert(mid_goal(cu, mid, w, m1)); + let m3 = run_seq(cu, m1, mid).unwrap(); + super::runseq::lemma_run_seq_append(cu, m, ld, mid); + super::runseq::lemma_run_seq_append(cu, m, ld + mid, st); + assert(x64::canonical(m3.rip)) by { + super::mid::lemma_rip_between(m, m3.rip, m.rip + code_len(super::templates::shape(ls, mid, ts))); + } + super::rel::lemma_rel_regs(lay, a, m1, m3, nl); + // the store + assert(m3.rip + x64::instr_len(super::templates::store_slot(ts, rax())) <= m.rip + code_len(super::templates::shape(ls, mid, ts))); + assert(x64::canonical(m3.rip + x64::instr_len(super::templates::store_slot(ts, rax())))); + super::rel::lemma_store_finish(cu, lay, a, a2, m, m3, nl, ts, rax(), w); + super::runseq::lemma_run_seq_one(cu, m3, super::templates::store_slot(ts, rax())); +} + +} // verus! diff --git a/crates/clazel-jit/src/spec.rs b/crates/clazel-jit/src/spec.rs index 965356e9..d0c070d8 100644 --- a/crates/clazel-jit/src/spec.rs +++ b/crates/clazel-jit/src/spec.rs @@ -225,10 +225,11 @@ pub open spec fn un_supported(u: lir::UnOp) -> bool { } /// The instruction has a template, and is well formed at a stack of height -/// `h` with `nl` locals: its operands exist, its local index is in range, -/// and everything it reads or writes is one of the 31 frame slots. +/// `h` with `nl` locals: the frame holds the stack as it is (`nl + h` slots) +/// and as it will be, its operands exist, its local index is in range, and so +/// everything it reads or writes is one of the 31 frame slots. pub open spec fn op_ok(op: Op, nl: nat, h: nat) -> bool { - pops(op) <= h && nl + height_after_op(op, h) <= max_slots() && match op { + nl + h <= max_slots() && pops(op) <= h && nl + height_after_op(op, h) <= max_slots() && match op { Op::LocalGet(x) => x < nl, Op::LocalSet(x) => x < nl, Op::LocalTee(x) => x < nl, diff --git a/crates/clazel-jit/src/steps.rs b/crates/clazel-jit/src/steps.rs new file mode 100644 index 00000000..ffcfe830 --- /dev/null +++ b/crates/clazel-jit/src/steps.rs @@ -0,0 +1,199 @@ +//! What one `x64::step` does, for each instruction form the templates use: +//! a load from or store to a frame slot, an immediate move, a register move, +//! and the arithmetic, logic, shift, multiply, compare, test, set and +//! conditional-move forms. Each lemma computes the state `step` returns, in +//! terms of the state it is given, so a template's proof is a chain of them. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// The ABI constants the lemmas need, evaluated. +pub proof fn lemma_abi_consts() + ensures + abi::ctx_reg() == 15, + abi::sp_reg() == 4, + abi::exit_code_off() == 256, + abi::ctx_size() == 512, + frame_off() == 264, + max_slots() == 31, +{ +} + +/// The address of frame slot `j`, formed by the effective-address rule from the +/// context register, is the context plus the slot's displacement, with no +/// wrap-around. +pub proof fn lemma_slot_ea(m: x64::State, j: nat) + requires + ctx_ok(m), + j < max_slots(), + ensures + x64::eff_addr(m, slot_mem(j)) == ctx_of(m) + slot_disp(j), + (slot_disp(j) as i32) as int == slot_disp(j), + 0 <= slot_disp(j) < 512, +{ + super::memlemmas::lemma_p2_consts(); + lemma_abi_consts(); + let d = slot_disp(j); + assert(d == 264 + 8 * j); + assert((d as i32) as int == d); + let x = ctx_of(m) + d; + assert(0 <= x && x < 0x8000_0000_0000 + 512); + assert(x64::loghead(64, x) == x); + assert(x64::logext(64, x) == x); + assert(x64::eff_addr(m, slot_mem(j)) == x64::logext(64, ctx_of(m) + 0 + d)); +} + +/// `mov dst, [slot j]` puts the slot's word in `dst` and advances `rip`. +pub proof fn lemma_step_load_slot( + cu: spec_fn(nat) -> nat, + m: x64::State, + dst: u8, + j: nat, + v: nat, +) + requires + x64::wf(m), + ctx_ok(m), + dst < 16, + j < max_slots(), + slot_holds(m.mem, ctx_of(m), j, v), + v < 0x1_0000_0000_0000_0000, + x64::canonical(m.rip + x64::instr_len(super::templates::load_slot(dst, j))), + ensures + x64::step(cu, m, super::templates::load_slot(dst, j)) == Some( + x64::State { + rgf: m.rgf.update(dst as int, v as u64), + rip: m.rip + x64::instr_len(super::templates::load_slot(dst, j)), + ..m + }, + ), +{ + super::memlemmas::lemma_p2_consts(); + lemma_slot_ea(m, j); + let i = super::templates::load_slot(dst, j); + assert(x64::read_operand_mem(m, x64::Size::W64, slot_mem(j)) == Some(v as int)); + assert(x64::loghead(64, v as int) == v as int); + assert(x64::wr64(m, dst, v as int) == x64::State { rgf: m.rgf.update(dst as int, v as u64), ..m }); +} + +/// `mov [slot j], src` writes the word in `src` to the slot, and to no other +/// byte of memory: every other slot, and every byte outside the slot, is as +/// it was. Registers, flags and the XMM registers are unchanged. +pub proof fn lemma_step_store_slot(cu: spec_fn(nat) -> nat, m: x64::State, src: u8, j: nat) + requires + x64::wf(m), + ctx_ok(m), + src < 16, + j < max_slots(), + exit_area_mapped(m.mem, ctx_of(m)), + x64::canonical(m.rip + x64::instr_len(super::templates::store_slot(j, src))), + ensures + x64::step(cu, m, super::templates::store_slot(j, src)) is Some, + ({ + let m1 = x64::step(cu, m, super::templates::store_slot(j, src)).unwrap(); + &&& m1 == x64::State { mem: m1.mem, rip: m.rip + x64::instr_len(super::templates::store_slot(j, src)), ..m } + &&& slot_holds(m1.mem, ctx_of(m), j, m.rgf[src as int] as nat) + &&& forall|k: nat, w: nat| + k < max_slots() && k != j && #[trigger] slot_holds(m.mem, ctx_of(m), k, w) + ==> slot_holds(m1.mem, ctx_of(m), k, w) + &&& m1.mem.dom() =~= m.mem.dom() + &&& forall|b: int| + #![trigger m1.mem.dom().contains(b)] + m.mem.dom().contains(b) && (b < ctx_of(m) + slot_disp(j) || ctx_of(m) + + slot_disp(j) + 8 <= b) ==> m1.mem[b] == m.mem[b] + }), +{ + super::memlemmas::lemma_p2_consts(); + lemma_slot_ea(m, j); + let ctxb = ctx_of(m); + let addr = ctxb + slot_disp(j); + let w = m.rgf[src as int] as int; + assert(x64::rgfi_size(m, x64::Size::W64, src) == w); + assert forall|i: int| 0 <= i < 8 implies m.mem.dom().contains(#[trigger] (addr + i)) by { + assert(in_exit_area(ctxb, addr + i)); + } + super::memlemmas::lemma_write_mem_some(m.mem, addr, 8, w); + let m2 = x64::write_mem(m.mem, addr, 8, w).unwrap(); + super::memlemmas::lemma_write_mem_frame(m.mem, addr, 8, w, m2); + assert(0 <= w < vstd::arithmetic::power2::pow2(8 * 8) as int) by { + assert(vstd::arithmetic::power2::pow2(64) == 0x1_0000_0000_0000_0000); + } + super::memlemmas::lemma_read_after_write_same(m.mem, addr, 8, w, m2); + assert(x64::store_mem(m, slot_mem(j), x64::Size::W64, w) == Some(x64::State { mem: m2, ..m })); + let m1 = x64::step(cu, m, super::templates::store_slot(j, src)).unwrap(); + assert(m1.mem == m2); + assert forall|k: nat, v: nat| + k < max_slots() && k != j && #[trigger] slot_holds(m.mem, ctxb, k, v) implies slot_holds( + m1.mem, + ctxb, + k, + v, + ) by { + lemma_abi_consts(); + super::memlemmas::lemma_read_after_write_disjoint(m.mem, addr, 8, w, m2, ctxb + slot_disp(k), 8); + } +} + +/// `mov dst, imm64` and `mov dst, imm32` (zero-extending). +pub proof fn lemma_step_imm(cu: spec_fn(nat) -> nat, m: x64::State, i: x64::Instr) + requires + x64::wf(m), + x64::canonical(m.rip + x64::instr_len(i)), + i is MovImm64 || i is MovImm32, + i is MovImm64 ==> i->MovImm64_dst < 16, + i is MovImm32 ==> i->MovImm32_dst < 16, + ensures + i is MovImm64 ==> x64::step(cu, m, i) == Some( + x64::State { + rgf: m.rgf.update(i->MovImm64_dst as int, i->MovImm64_imm_u64), + rip: m.rip + x64::instr_len(i), + ..m + }, + ), + i is MovImm32 ==> x64::step(cu, m, i) == Some( + x64::State { + rgf: m.rgf.update(i->MovImm32_dst as int, i->MovImm32_imm_u32 as u64), + rip: m.rip + x64::instr_len(i), + ..m + }, + ), +{ + super::memlemmas::lemma_p2_consts(); + if i is MovImm64 { + assert(x64::loghead(64, i->MovImm64_imm_u64 as int) == i->MovImm64_imm_u64 as int); + } else { + assert(x64::loghead(32, i->MovImm32_imm_u32 as int) == i->MovImm32_imm_u32 as int); + assert(x64::loghead(64, i->MovImm32_imm_u32 as int) == i->MovImm32_imm_u32 as int); + } +} + +/// `mov dst32, src32`: the low 32 bits of `src`, zero-extended, into `dst`. +pub proof fn lemma_step_mov_rr32(cu: spec_fn(nat) -> nat, m: x64::State, dst: u8, src: u8) + requires + x64::wf(m), + dst < 16, + src < 16, + x64::canonical( + m.rip + x64::instr_len(x64::Instr::MovRR { sz: x64::Size::W32, dst: dst, src: src }), + ), + ensures + x64::step(cu, m, x64::Instr::MovRR { sz: x64::Size::W32, dst: dst, src: src }) == Some( + x64::State { + rgf: m.rgf.update(dst as int, (m.rgf[src as int] % 0x1_0000_0000) as u64), + rip: m.rip + x64::instr_len( + x64::Instr::MovRR { sz: x64::Size::W32, dst: dst, src: src }, + ), + ..m + }, + ), +{ + super::memlemmas::lemma_p2_consts(); + let v = m.rgf[src as int] as int % 0x1_0000_0000; + assert(x64::loghead(64, v) == v); +} + +} // verus! diff --git a/crates/clazel-jit/src/templates.rs b/crates/clazel-jit/src/templates.rs new file mode 100644 index 00000000..af62f557 --- /dev/null +++ b/crates/clazel-jit/src/templates.rs @@ -0,0 +1,277 @@ +//! The templates (jit.md J.9): for each LIR instruction of the first slice, +//! at a known stack height, a fixed list of x86-64 instructions over the +//! scratch registers `rax`, `rcx` and `rdx`, reading and writing frame slots. +//! These are spec functions: the executable emitter (`emit`) is proven equal +//! to them, and the refinement proofs (`proofs`) are about them. +//! +//! Every template has the shape *load operands from slots into scratch +//! registers, compute in registers, store the result to a slot*. The +//! operand stack's top is slot `nl + h - 1` for `nl` locals and height `h` +//! (see `spec`, modelling choice 2), so a binary operation at height `h` +//! reads slots `nl + h - 2` and `nl + h - 1` and writes the first. +//! +//! No template reads memory other than the frame, writes anything but the +//! frame and scratch registers, or touches `r15` or `rsp`. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// `mov r, [r15 + 264 + 8 j]`: load frame slot `j` (64 bits) into `dst`. +pub open spec fn load_slot(dst: u8, j: nat) -> x64::Instr { + x64::Instr::MovLoad { sz: x64::Size::W64, dst: dst, mem: slot_mem(j) } +} + +/// `mov [r15 + 264 + 8 j], r`: store `src` (64 bits) to frame slot `j`. +pub open spec fn store_slot(j: nat, src: u8) -> x64::Instr { + x64::Instr::MovStore { sz: x64::Size::W64, mem: slot_mem(j), src: src } +} + +/// The condition code of `setcc` for an integer comparison, read after +/// `cmp lhs, rhs` (so the flags are those of `lhs - rhs`): `e`, `ne`, `l` +/// (signed less), `b` (below: carry), `g`, `a`, `le`, `be`, `ge`, `ae`. +pub open spec fn cc_of(c: lir::ICmp) -> u8 { + match c { + lir::ICmp::Eq => 4, + lir::ICmp::Ne => 5, + lir::ICmp::LtS => 12, + lir::ICmp::LtU => 2, + lir::ICmp::GtS => 15, + lir::ICmp::GtU => 7, + lir::ICmp::LeS => 14, + lir::ICmp::LeU => 6, + lir::ICmp::GeS => 13, + lir::ICmp::GeU => 3, + } +} + +/// The x86-64 two-operand operation for an integer binary operator with a +/// one-instruction register-register form (`add`, `sub`, `and`, `or`, `xor`). +pub open spec fn alu_of(o: lir::IBin) -> Option { + match o { + lir::IBin::Add => Some(x64::AluOp::Add), + lir::IBin::Sub => Some(x64::AluOp::Sub), + lir::IBin::And => Some(x64::AluOp::And), + lir::IBin::Or => Some(x64::AluOp::Or), + lir::IBin::Xor => Some(x64::AluOp::Xor), + _ => None, + } +} + +/// The x86-64 shift for an integer shift operator (`shl`, `shr`, `sar`). +pub open spec fn shift_of(o: lir::IBin) -> Option { + match o { + lir::IBin::Shl => Some(x64::ShiftOp::Shl), + lir::IBin::ShrU => Some(x64::ShiftOp::Shr), + lir::IBin::ShrS => Some(x64::ShiftOp::Sar), + _ => None, + } +} + +/// The instructions that load the slots `ls` (register, slot pairs) one after +/// the other. +pub open spec fn loads_seq(ls: Seq<(u8, nat)>) -> Seq + decreases ls.len(), +{ + if ls.len() == 0 { + seq![] + } else { + loads_seq(ls.drop_last()) + seq![load_slot(ls.last().0, ls.last().1)] + } +} + +/// A template: the loads, the register-only middle, and one store of `rax` to +/// a slot. +pub open spec fn shape( + ls: Seq<(u8, nat)>, + mid: Seq, + ts: nat, +) -> Seq { + loads_seq(ls) + mid + seq![store_slot(ts, rax())] +} + +/// `ra := ra op rb` with the operands in `rax` and `rcx`: the operator's +/// instruction (`add sub and or xor imul`, or a shift by `cl`). +pub open spec fn int_op_instr(o: lir::IBin, sz: x64::Size) -> x64::Instr { + match alu_of(o) { + Some(alu) => x64::Instr::AluRR { alu: alu, sz: sz, dst: rax(), src: rcx() }, + None => match shift_of(o) { + Some(sh) => x64::Instr::ShiftCl { shift: sh, sz: sz, r: rax() }, + None => x64::Instr::ImulRR { sz: sz, dst: rax(), src: rcx() }, + }, + } +} + +/// `mov eax, 0; cmp rcx, rdx; setcc al`: `rax` is 0 or 1. The `mov` is +/// before the compare because it leaves the flags alone. +pub open spec fn cmp_mid(c: lir::ICmp, sz: x64::Size) -> Seq { + seq![ + x64::Instr::MovImm32 { dst: rax(), imm_u32: 0 }, + x64::Instr::AluRR { alu: x64::AluOp::Cmp, sz: sz, dst: rcx(), src: rdx() }, + x64::Instr::Setcc { cc: cc_of(c), dst: rax() }, + ] +} + +/// `mov eax, 0; test rcx, rcx; sete al`. +pub open spec fn eqz_mid(sz: x64::Size) -> Seq { + seq![ + x64::Instr::MovImm32 { dst: rax(), imm_u32: 0 }, + x64::Instr::TestRR { sz: sz, a: rcx(), b: rcx() }, + x64::Instr::Setcc { cc: 4, dst: rax() }, + ] +} + +/// `mov rcx, mask; xor/and rax, rcx`: `f64.neg` (flip the sign bit) and +/// `f64.abs` (clear it) on the bits. +pub open spec fn mask_mid(alu: x64::AluOp, mask: u64) -> Seq { + seq![ + x64::Instr::MovImm64 { dst: rcx(), imm_u64: mask }, + x64::Instr::AluRR { alu: alu, sz: x64::Size::W64, dst: rax(), src: rcx() }, + ] +} + +/// `mov ecx, 0x80000000; xor rax, rcx; sub rax, rcx`: sign-extends the low +/// 32 bits of `rax`, `(x ^ 2^31) - 2^31`. +pub open spec fn exts_mid() -> Seq { + seq![ + x64::Instr::MovImm32 { dst: rcx(), imm_u32: 0x8000_0000 }, + x64::Instr::AluRR { + alu: x64::AluOp::Xor, + sz: x64::Size::W64, + dst: rax(), + src: rcx(), + }, + x64::Instr::AluRR { + alu: x64::AluOp::Sub, + sz: x64::Size::W64, + dst: rax(), + src: rcx(), + }, + ] +} + +/// `mov eax, eax`: the low 32 bits, zero-extended. +pub open spec fn wrap_mid() -> Seq { + seq![x64::Instr::MovRR { sz: x64::Size::W32, dst: rax(), src: rax() }] +} + +/// `test edx, edx; cmove rax, rcx`: `rax` (the first value) stays unless the +/// condition in `rdx` is 0, when it becomes `rcx` (the second). +pub open spec fn select_mid() -> Seq { + seq![ + x64::Instr::TestRR { sz: x64::Size::W32, a: rdx(), b: rdx() }, + x64::Instr::Cmovcc { cc: 4, sz: x64::Size::W64, dst: rax(), src: rcx() }, + ] +} + +/// The template of an integer arithmetic, logic or shift instruction at +/// slots `t` (left operand and result) and `t + 1` (right operand): `mov rax, +/// [t]; mov rcx, [t+1]; op rax, rcx; mov [t], rax`. +pub open spec fn int_bin_tmpl(o: lir::IBin, sz: x64::Size, t: nat) -> Seq { + shape(seq![(rax(), t), (rcx(), t + 1)], seq![int_op_instr(o, sz)], t) +} + +/// The template of an integer comparison at slots `t` and `t + 1`: `mov rcx, +/// [t]; mov rdx, [t+1]; mov eax, 0; cmp rcx, rdx; setcc al; mov [t], rax`. +pub open spec fn int_cmp_tmpl(c: lir::ICmp, sz: x64::Size, t: nat) -> Seq { + shape(seq![(rcx(), t), (rdx(), t + 1)], cmp_mid(c, sz), t) +} + +/// The template of `eqz` at slot `t`. +pub open spec fn eqz_tmpl(sz: x64::Size, t: nat) -> Seq { + shape(seq![(rcx(), t)], eqz_mid(sz), t) +} + +/// The template of a binary instruction at stack height `h` with `nl` +/// locals. An empty list for an instruction outside the slice. +pub open spec fn bin_tmpl(b: lir::BinOp, nl: nat, h: nat) -> Seq { + let t = (nl + h - 2) as nat; + match b { + lir::BinOp::I32(o) => int_bin_tmpl(o, x64::Size::W32, t), + lir::BinOp::I64(o) => int_bin_tmpl(o, x64::Size::W64, t), + lir::BinOp::I32Cmp(c) => int_cmp_tmpl(c, x64::Size::W32, t), + lir::BinOp::I64Cmp(c) => int_cmp_tmpl(c, x64::Size::W64, t), + lir::BinOp::F64(_) => seq![], + lir::BinOp::F64Cmp(_) => seq![], + } +} + +/// The template of a unary instruction at stack height `h` with `nl` locals. +/// The conversions that change no bits of the word (`extend_i32_u`, the +/// reinterprets) are empty: an `i32` is stored zero-extended, and an `f64` +/// is its bits. +pub open spec fn un_tmpl(u: lir::UnOp, nl: nat, h: nat) -> Seq { + let t = (nl + h - 1) as nat; + match u { + lir::UnOp::I32Eqz => eqz_tmpl(x64::Size::W32, t), + lir::UnOp::I64Eqz => eqz_tmpl(x64::Size::W64, t), + lir::UnOp::F64Neg => shape( + seq![(rax(), t)], + mask_mid(x64::AluOp::Xor, 0x8000_0000_0000_0000), + t, + ), + lir::UnOp::F64Abs => shape( + seq![(rax(), t)], + mask_mid(x64::AluOp::And, 0x7FFF_FFFF_FFFF_FFFF), + t, + ), + lir::UnOp::I64ExtendI32S => shape(seq![(rax(), t)], exts_mid(), t), + lir::UnOp::I32WrapI64 => shape(seq![(rax(), t)], wrap_mid(), t), + lir::UnOp::I64ExtendI32U => seq![], + lir::UnOp::F64ReinterpretI64 => seq![], + lir::UnOp::I64ReinterpretF64 => seq![], + lir::UnOp::F64Sqrt => seq![], + lir::UnOp::F64ConvertI32S => seq![], + lir::UnOp::F64ConvertI32U => seq![], + lir::UnOp::F64ConvertI64S => seq![], + lir::UnOp::F64ConvertI64U => seq![], + } +} + +/// The load of a constant into `rax`: `mov eax, c` (zero-extending) for an +/// `i32`, `mov rax, c` for an `i64` or an `f64`'s bits. +pub open spec fn const_instr(v: lir::Val) -> x64::Instr { + match v { + lir::Val::I32(c) => x64::Instr::MovImm32 { dst: rax(), imm_u32: c }, + lir::Val::I64(c) => x64::Instr::MovImm64 { dst: rax(), imm_u64: c }, + lir::Val::F64(c) => x64::Instr::MovImm64 { dst: rax(), imm_u64: c }, + } +} + +/// **The template of one instruction** at stack height `h` with `nl` locals. +pub open spec fn tmpl(op: Op, nl: nat, h: nat) -> Seq { + match op { + Op::Nop => seq![], + Op::Drop => seq![], + // the new top is slot nl + h + Op::Const(v) => shape(seq![], seq![const_instr(v)], nl + h), + Op::LocalGet(x) => shape(seq![(rax(), x as nat)], seq![], nl + h), + // the top is slot nl + h - 1 + Op::LocalSet(x) => shape(seq![(rax(), (nl + h - 1) as nat)], seq![], x as nat), + Op::LocalTee(x) => shape(seq![(rax(), (nl + h - 1) as nat)], seq![], x as nat), + // v1, v2, c at slots t, t + 1, t + 2: c == 0 picks v2 (cmove) + Op::Select => { + let t = (nl + h - 3) as nat; + shape(seq![(rax(), t), (rcx(), t + 1), (rdx(), t + 2)], select_mid(), t) + }, + Op::Bin(b) => bin_tmpl(b, nl, h), + Op::Un(u) => un_tmpl(u, nl, h), + } +} + +/// The code of a program: the templates one after the other, each at the +/// stack height the instructions before it leave. +pub open spec fn code_of(ops: Seq, nl: nat, h: nat) -> Seq + decreases ops.len(), +{ + if ops.len() == 0 { + seq![] + } else { + code_of(ops.drop_last(), nl, h) + tmpl(ops.last(), nl, height_after(ops.drop_last(), h)) + } +} + +} // verus! diff --git a/crates/clazel-jit/src/tlemmas.rs b/crates/clazel-jit/src/tlemmas.rs new file mode 100644 index 00000000..3aa98c00 --- /dev/null +++ b/crates/clazel-jit/src/tlemmas.rs @@ -0,0 +1,353 @@ +//! Facts about the template definitions the emitter's proof needs: a template +//! is the explicit list of instructions the emitter pushes, and every +//! instruction of the code is in the x86-64 subset. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// `shape` with no loads. +pub proof fn lemma_shape0(mid: Seq, ts: nat) + ensures + super::templates::shape(seq![], mid, ts) == mid + seq![super::templates::store_slot(ts, rax())], +{ + assert(super::templates::loads_seq(Seq::<(u8, nat)>::empty()) == Seq::::empty()); + assert(Seq::::empty() + mid =~= mid); +} + +/// `shape` with one load. +pub proof fn lemma_shape1(r: u8, j: nat, mid: Seq, ts: nat) + ensures + super::templates::shape(seq![(r, j)], mid, ts) == seq![super::templates::load_slot(r, j)] + mid + seq![super::templates::store_slot(ts, rax())], +{ + let ls = seq![(r, j)]; + assert(ls.drop_last() =~= Seq::<(u8, nat)>::empty()); + assert(ls.last() == (r, j)); + assert(super::templates::loads_seq(Seq::<(u8, nat)>::empty()) == Seq::::empty()); + assert(super::templates::loads_seq(ls) =~= seq![super::templates::load_slot(r, j)]); +} + +/// `shape` with two loads. +pub proof fn lemma_shape2(r1: u8, j1: nat, r2: u8, j2: nat, mid: Seq, ts: nat) + ensures + super::templates::shape(seq![(r1, j1), (r2, j2)], mid, ts) == seq![super::templates::load_slot(r1, j1), super::templates::load_slot(r2, j2)] + + mid + seq![super::templates::store_slot(ts, rax())], +{ + let ls = seq![(r1, j1), (r2, j2)]; + assert(ls.drop_last() =~= seq![(r1, j1)]); + assert(ls.last() == (r2, j2)); + lemma_shape1(r1, j1, seq![], 0); + assert(super::templates::loads_seq(seq![(r1, j1)]) =~= seq![super::templates::load_slot(r1, j1)]) by { + let l1 = seq![(r1, j1)]; + assert(l1.drop_last() =~= Seq::<(u8, nat)>::empty()); + assert(l1.last() == (r1, j1)); + assert(super::templates::loads_seq(Seq::<(u8, nat)>::empty()) == Seq::::empty()); + } + assert(super::templates::loads_seq(ls) =~= seq![super::templates::load_slot(r1, j1), super::templates::load_slot(r2, j2)]); +} + +/// `shape` with three loads. +pub proof fn lemma_shape3( + r1: u8, + j1: nat, + r2: u8, + j2: nat, + r3: u8, + j3: nat, + mid: Seq, + ts: nat, +) + ensures + super::templates::shape(seq![(r1, j1), (r2, j2), (r3, j3)], mid, ts) == seq![ + super::templates::load_slot(r1, j1), + super::templates::load_slot(r2, j2), + super::templates::load_slot(r3, j3), + ] + mid + seq![super::templates::store_slot(ts, rax())], +{ + let ls = seq![(r1, j1), (r2, j2), (r3, j3)]; + assert(ls.drop_last() =~= seq![(r1, j1), (r2, j2)]); + assert(ls.last() == (r3, j3)); + let l2 = seq![(r1, j1), (r2, j2)]; + assert(l2.drop_last() =~= seq![(r1, j1)]); + assert(l2.last() == (r2, j2)); + let l1 = seq![(r1, j1)]; + assert(l1.drop_last() =~= Seq::<(u8, nat)>::empty()); + assert(l1.last() == (r1, j1)); + assert(super::templates::loads_seq(Seq::<(u8, nat)>::empty()) == Seq::::empty()); + assert(super::templates::loads_seq(l1) =~= seq![super::templates::load_slot(r1, j1)]); + assert(super::templates::loads_seq(l2) =~= seq![super::templates::load_slot(r1, j1), super::templates::load_slot(r2, j2)]); + assert(super::templates::loads_seq(ls) =~= seq![super::templates::load_slot(r1, j1), super::templates::load_slot(r2, j2), super::templates::load_slot(r3, j3)]); +} + +/// The slot operand of a frame slot below 31 is a valid memory operand. +pub proof fn lemma_slot_valid(j: nat) + requires + j < max_slots(), + ensures + x64::mem_ok(slot_mem(j)), +{ +} + +/// A load or store of an existing slot with scratch registers is in the subset. +pub proof fn lemma_ls_valid(r: u8, j: nat) + requires + r < 16, + j < max_slots(), + ensures + x64::valid_instr(super::templates::load_slot(r, j)), + x64::valid_instr(super::templates::store_slot(j, r)), +{ + lemma_slot_valid(j); +} + +/// Every instruction of a template is in the subset. +pub proof fn lemma_tmpl_valid(op: Op, nl: nat, h: nat) + requires + op_ok(op, nl, h), + ensures + forall|k: int| 0 <= k < super::templates::tmpl(op, nl, h).len() ==> x64::valid_instr(#[trigger] super::templates::tmpl(op, nl, h)[k]), +{ + assert(max_slots() == 31) by { + lemma_abi_consts_t(); + } + let code = super::templates::tmpl(op, nl, h); + assert forall|k: int| 0 <= k < code.len() implies x64::valid_instr(#[trigger] code[k]) by { + match op { + Op::Nop => {}, + Op::Drop => {}, + Op::Const(v) => { + lemma_shape0(seq![super::templates::const_instr(v)], nl + h); + lemma_ls_valid(0, nl + h); + assert(code =~= seq![super::templates::const_instr(v), super::templates::store_slot(nl + h, rax())]); + }, + Op::LocalGet(x) => { + lemma_shape1(rax(), x as nat, seq![], nl + h); + lemma_ls_valid(0, nl + h); + lemma_ls_valid(0, x as nat); + assert(code =~= seq![super::templates::load_slot(rax(), x as nat), super::templates::store_slot(nl + h, rax())]); + }, + Op::LocalSet(x) => { + lemma_shape1(rax(), (nl + h - 1) as nat, seq![], x as nat); + lemma_ls_valid(0, x as nat); + lemma_ls_valid(0, (nl + h - 1) as nat); + assert(code =~= seq![super::templates::load_slot(rax(), (nl + h - 1) as nat), super::templates::store_slot(x as nat, rax())]); + }, + Op::LocalTee(x) => { + lemma_shape1(rax(), (nl + h - 1) as nat, seq![], x as nat); + lemma_ls_valid(0, x as nat); + lemma_ls_valid(0, (nl + h - 1) as nat); + assert(code =~= seq![super::templates::load_slot(rax(), (nl + h - 1) as nat), super::templates::store_slot(x as nat, rax())]); + }, + Op::Select => { + let t = (nl + h - 3) as nat; + lemma_shape3(rax(), t, rcx(), t + 1, rdx(), t + 2, super::templates::select_mid(), t); + lemma_ls_valid(0, t); + lemma_ls_valid(1, t + 1); + lemma_ls_valid(2, t + 2); + assert(code =~= seq![ + super::templates::load_slot(rax(), t), + super::templates::load_slot(rcx(), t + 1), + super::templates::load_slot(rdx(), t + 2), + super::templates::select_mid()[0], + super::templates::select_mid()[1], + super::templates::store_slot(t, rax()), + ]); + }, + Op::Bin(b) => { + let t = (nl + h - 2) as nat; + match b { + lir::BinOp::I32(o) => { + lemma_shape2(rax(), t, rcx(), t + 1, seq![super::templates::int_op_instr(o, x64::Size::W32)], t); + lemma_ls_valid(0, t); + lemma_ls_valid(1, t + 1); + assert(code =~= seq![ + super::templates::load_slot(rax(), t), + super::templates::load_slot(rcx(), t + 1), + super::templates::int_op_instr(o, x64::Size::W32), + super::templates::store_slot(t, rax()), + ]); + }, + lir::BinOp::I64(o) => { + lemma_shape2(rax(), t, rcx(), t + 1, seq![super::templates::int_op_instr(o, x64::Size::W64)], t); + lemma_ls_valid(0, t); + lemma_ls_valid(1, t + 1); + assert(code =~= seq![ + super::templates::load_slot(rax(), t), + super::templates::load_slot(rcx(), t + 1), + super::templates::int_op_instr(o, x64::Size::W64), + super::templates::store_slot(t, rax()), + ]); + }, + lir::BinOp::I32Cmp(c) => { + lemma_shape2(rcx(), t, rdx(), t + 1, super::templates::cmp_mid(c, x64::Size::W32), t); + lemma_ls_valid(1, t); + lemma_ls_valid(2, t + 1); + lemma_ls_valid(0, t); + assert(code =~= seq![ + super::templates::load_slot(rcx(), t), + super::templates::load_slot(rdx(), t + 1), + super::templates::cmp_mid(c, x64::Size::W32)[0], + super::templates::cmp_mid(c, x64::Size::W32)[1], + super::templates::cmp_mid(c, x64::Size::W32)[2], + super::templates::store_slot(t, rax()), + ]); + }, + lir::BinOp::I64Cmp(c) => { + lemma_shape2(rcx(), t, rdx(), t + 1, super::templates::cmp_mid(c, x64::Size::W64), t); + lemma_ls_valid(1, t); + lemma_ls_valid(2, t + 1); + lemma_ls_valid(0, t); + assert(code =~= seq![ + super::templates::load_slot(rcx(), t), + super::templates::load_slot(rdx(), t + 1), + super::templates::cmp_mid(c, x64::Size::W64)[0], + super::templates::cmp_mid(c, x64::Size::W64)[1], + super::templates::cmp_mid(c, x64::Size::W64)[2], + super::templates::store_slot(t, rax()), + ]); + }, + lir::BinOp::F64(_) => { + assert(false); + }, + lir::BinOp::F64Cmp(_) => { + assert(false); + }, + } + }, + Op::Un(u) => { + let t = (nl + h - 1) as nat; + lemma_ls_valid(0, t); + lemma_ls_valid(1, t); + match u { + lir::UnOp::I32Eqz => { + lemma_shape1(rcx(), t, super::templates::eqz_mid(x64::Size::W32), t); + assert(code =~= seq![ + super::templates::load_slot(rcx(), t), + super::templates::eqz_mid(x64::Size::W32)[0], + super::templates::eqz_mid(x64::Size::W32)[1], + super::templates::eqz_mid(x64::Size::W32)[2], + super::templates::store_slot(t, rax()), + ]); + }, + lir::UnOp::I64Eqz => { + lemma_shape1(rcx(), t, super::templates::eqz_mid(x64::Size::W64), t); + assert(code =~= seq![ + super::templates::load_slot(rcx(), t), + super::templates::eqz_mid(x64::Size::W64)[0], + super::templates::eqz_mid(x64::Size::W64)[1], + super::templates::eqz_mid(x64::Size::W64)[2], + super::templates::store_slot(t, rax()), + ]); + }, + lir::UnOp::F64Neg => { + lemma_shape1(rax(), t, super::templates::mask_mid(x64::AluOp::Xor, 0x8000_0000_0000_0000), t); + assert(code =~= seq![ + super::templates::load_slot(rax(), t), + super::templates::mask_mid(x64::AluOp::Xor, 0x8000_0000_0000_0000)[0], + super::templates::mask_mid(x64::AluOp::Xor, 0x8000_0000_0000_0000)[1], + super::templates::store_slot(t, rax()), + ]); + }, + lir::UnOp::F64Abs => { + lemma_shape1(rax(), t, super::templates::mask_mid(x64::AluOp::And, 0x7FFF_FFFF_FFFF_FFFF), t); + assert(code =~= seq![ + super::templates::load_slot(rax(), t), + super::templates::mask_mid(x64::AluOp::And, 0x7FFF_FFFF_FFFF_FFFF)[0], + super::templates::mask_mid(x64::AluOp::And, 0x7FFF_FFFF_FFFF_FFFF)[1], + super::templates::store_slot(t, rax()), + ]); + }, + lir::UnOp::I64ExtendI32S => { + lemma_shape1(rax(), t, super::templates::exts_mid(), t); + assert(code =~= seq![ + super::templates::load_slot(rax(), t), + super::templates::exts_mid()[0], + super::templates::exts_mid()[1], + super::templates::exts_mid()[2], + super::templates::store_slot(t, rax()), + ]); + }, + lir::UnOp::I32WrapI64 => { + lemma_shape1(rax(), t, super::templates::wrap_mid(), t); + assert(code =~= seq![ + super::templates::load_slot(rax(), t), + super::templates::wrap_mid()[0], + super::templates::store_slot(t, rax()), + ]); + }, + lir::UnOp::I64ExtendI32U => {}, + lir::UnOp::F64ReinterpretI64 => {}, + lir::UnOp::I64ReinterpretF64 => {}, + lir::UnOp::F64Sqrt => { + assert(false); + }, + lir::UnOp::F64ConvertI32S => { + assert(false); + }, + lir::UnOp::F64ConvertI32U => { + assert(false); + }, + lir::UnOp::F64ConvertI64S => { + assert(false); + }, + lir::UnOp::F64ConvertI64U => { + assert(false); + }, + } + }, + } + } +} + +/// The ABI constants the lemmas above need. +pub proof fn lemma_abi_consts_t() + ensures + max_slots() == 31, +{ +} + +/// Every instruction of a program's code is in the subset. +pub proof fn lemma_code_of_valid(ops: Seq, nl: nat, h0: nat) + requires + prog_ok(ops, nl, h0), + ensures + super::contract::all_valid_instrs(super::templates::code_of(ops, nl, h0)), + decreases ops.len(), +{ + if ops.len() > 0 { + let pre = ops.drop_last(); + let last = ops.last(); + let hl = height_after(pre, h0); + lemma_code_of_valid(pre, nl, h0); + lemma_tmpl_valid(last, nl, hl); + let ca = super::templates::code_of(pre, nl, h0); + let cb = super::templates::tmpl(last, nl, hl); + assert(super::templates::code_of(ops, nl, h0) == ca + cb); + assert forall|k: int| 0 <= k < (ca + cb).len() implies x64::valid_instr( + #[trigger] (ca + cb)[k], + ) by { + if k < ca.len() { + assert((ca + cb)[k] == ca[k]); + } else { + assert((ca + cb)[k] == cb[k - ca.len()]); + } + } + } +} + +/// The exit sequence is in the subset. +pub proof fn lemma_exit_valid(c: u32) + ensures + super::contract::all_valid_instrs(exit_seq(c)), +{ + assert forall|k: int| 0 <= k < exit_seq(c).len() implies x64::valid_instr( + #[trigger] exit_seq(c)[k], + ) by { + assert(k == 0 || k == 1 || k == 2); + } +} + +} // verus! diff --git a/crates/clazel-jit/tests/validator.rs b/crates/clazel-jit/tests/validator.rs new file mode 100644 index 00000000..4259681c --- /dev/null +++ b/crates/clazel-jit/tests/validator.rs @@ -0,0 +1,388 @@ +//! The back end never produces a blob the validator refuses (docs/phases/jit.md +//! J.9: "a test checks that the back end never produces a blob the validator +//! refuses"). +//! +//! The blob is `emit_blob`'s output: the encoded templates and the exit +//! sequence. The validator is `clazel-codecheck`'s executable one +//! ([`clazel_codecheck::validate::validate`], proven sound and complete for +//! its spec), entered at offset 0. +//! +//! 1. **Every template.** For each instruction of the first slice, with every +//! operator and comparison, a program that sets up the operands and runs it. +//! 2. **Generated programs.** A few thousand small random well-formed +//! programs (a fixed seed), each of which must have a blob that is +//! accepted. +//! 3. **What has no template is refused by the back end, not emitted**: the +//! `f64` arithmetic, the rotates, a bad local, a short stack, a frame of +//! more than 31 slots. +//! 4. **Controls.** The validator does refuse the blob when its last byte is +//! changed or cut off, so a `true` above is not the validator saying yes +//! to everything. +//! +//! This test is evidence, not proof: the proofs are in the `verus!` modules +//! (`compose::lemma_prog_refines` for the meaning of the code, +//! `emit::emit_blob_impl` for the bytes). That every blob is accepted is not +//! yet a theorem. + +use clazel_codecheck::validate::validate; +use clazel_jit::api::Backend; +use clazel_jit::emit::X64Backend; +use clazel_jit::spec::Op; +use clazel_lir::spec::{BinOp, FBin, FCmp, IBin, ICmp, UnOp, Val}; + +// The spec's types are not `Copy`, so each use builds a fresh value. + +const IBINS: [fn() -> IBin; 9] = [ + || IBin::Add, + || IBin::Sub, + || IBin::Mul, + || IBin::And, + || IBin::Or, + || IBin::Xor, + || IBin::Shl, + || IBin::ShrU, + || IBin::ShrS, +]; + +const ICMPS: [fn() -> ICmp; 10] = [ + || ICmp::Eq, + || ICmp::Ne, + || ICmp::LtS, + || ICmp::LtU, + || ICmp::GtS, + || ICmp::GtU, + || ICmp::LeS, + || ICmp::LeU, + || ICmp::GeS, + || ICmp::GeU, +]; + +const UNS: [fn() -> UnOp; 8] = [ + || UnOp::I32Eqz, + || UnOp::I64Eqz, + || UnOp::F64Neg, + || UnOp::F64Abs, + || UnOp::I32WrapI64, + || UnOp::I64ExtendI32S, + || UnOp::I64ExtendI32U, + || UnOp::F64ReinterpretI64, +]; + +/// Every operation of the slice that is one constructor away, with the +/// number of operands it takes. +fn all_ops() -> Vec<(Op, usize)> { + let mut v = vec![ + (Op::Nop, 0), + (Op::Drop, 1), + (Op::Select, 3), + (Op::LocalGet(0), 0), + (Op::LocalGet(1), 0), + (Op::LocalSet(0), 1), + (Op::LocalSet(1), 1), + (Op::LocalTee(0), 1), + (Op::LocalTee(1), 1), + (Op::Const(Val::I32(0)), 0), + (Op::Const(Val::I32(u32::MAX)), 0), + (Op::Const(Val::I64(0x1234_5678_9abc_def0)), 0), + (Op::Const(Val::F64(0x7ff8_0000_0000_0001)), 0), + (Op::Un(UnOp::I64ReinterpretF64), 1), + ]; + for u in UNS { + v.push((Op::Un(u()), 1)); + } + for o in IBINS { + v.push((Op::Bin(BinOp::I32(o())), 2)); + v.push((Op::Bin(BinOp::I64(o())), 2)); + } + for c in ICMPS { + v.push((Op::Bin(BinOp::I32Cmp(c())), 2)); + v.push((Op::Bin(BinOp::I64Cmp(c())), 2)); + } + v +} + +/// A program that pushes `n` constants, then runs `op`. +fn with_operands(op: Op, n: usize) -> Vec { + let mut p: Vec = (0..n).map(|k| Op::Const(Val::I64(k as u64))).collect(); + p.push(op); + p +} + +fn blob(ops: &[Op], nl: usize) -> Option> { + X64Backend::emit_blob(ops, nl, 7) +} + +fn accepted(b: &[u8]) -> bool { + validate(b, &[0]) +} + +#[test] +fn every_template_is_accepted() { + let mut count = 0usize; + for (op, n) in all_ops() { + let prog = with_operands(op, n); + let b = blob(&prog, 2); + assert!( + b.is_some(), + "no blob for template {count} ({} ops)", + prog.len() + ); + let b = b.unwrap_or_default(); + assert!( + accepted(&b), + "the validator refuses template {count}: {b:02x?}" + ); + count = count.saturating_add(1); + } + // 14 fixed + 8 unary + 18 integer + 20 comparisons + assert_eq!(count, 60); +} + +#[test] +fn the_body_alone_is_not_a_blob_but_the_blob_is() { + // The blob is the body plus the exit sequence: cut the `ret` off and the + // validator refuses (every path must end in an exit sequence or a + // branch). + let prog = with_operands(Op::Bin(BinOp::I32(IBin::Add)), 2); + let body = X64Backend::emit_body(&prog, 0).unwrap_or_default(); + assert!(!body.is_empty()); + let b = blob(&prog, 0).unwrap_or_default(); + assert!(accepted(&b)); + // The exit sequence is `mov eax, 7` (5 bytes), `mov [r15+256], rax` + // (8) and `ret` (1). + assert_eq!(b.last().copied(), Some(0xc3)); + assert!(!accepted(b.get(..b.len().saturating_sub(1)).unwrap_or(&[]))); +} + +#[test] +fn an_empty_program_is_just_the_exit_sequence() { + let b = blob(&[], 0).unwrap_or_default(); + assert_eq!(b.len(), 14); + assert!(accepted(&b)); +} + +/// xorshift64: a fixed pseudo-random sequence. +struct Rng(u64); + +impl Rng { + fn next(&mut self) -> u64 { + let mut x = self.0; + x ^= x.wrapping_shl(13); + x ^= x.wrapping_shr(7); + x ^= x.wrapping_shl(17); + self.0 = x; + x + } + fn below(&mut self, n: usize) -> usize { + usize::try_from( + self.next() + .checked_rem(u64::try_from(n).unwrap_or(1)) + .unwrap_or(0), + ) + .unwrap_or(0) + } +} + +/// A random well-formed program for `nl` locals: each instruction has the +/// operands it needs, local indices are in range, the frame fits. Returns the +/// program. +fn random_program(rng: &mut Rng, nl: usize, len: usize) -> Vec { + let ops = all_ops(); + let mut prog = Vec::new(); + let mut h = 0usize; + for _ in 0..len { + let pick = rng.below(ops.len()); + let Some((op, pops)) = ops.get(pick) else { + continue; + }; + let pops = *pops; + // keep the frame inside 31 slots and the operands available + if h < pops { + let c = match rng.below(3) { + 0 => Val::I32(u32::try_from(rng.next() & 0xffff_ffff).unwrap_or(0)), + 1 => Val::I64(rng.next()), + _ => Val::F64(rng.next()), + }; + if nl.saturating_add(h) < 31 { + prog.push(Op::Const(c)); + h = h.saturating_add(1); + } + continue; + } + let pushes = match op { + Op::Nop | Op::Drop | Op::LocalSet(_) => 0, + _ => 1, + }; + let after = h.saturating_sub(pops).saturating_add(pushes); + if nl.saturating_add(after) > 31 { + continue; + } + // local indices 0 and 1 need two locals + if matches!(op, Op::LocalGet(_) | Op::LocalSet(_) | Op::LocalTee(_)) && nl < 2 { + continue; + } + prog.push(clone_op(op)); + h = after; + } + prog +} + +fn clone_op(op: &Op) -> Op { + match op { + Op::Nop => Op::Nop, + Op::Const(Val::I32(c)) => Op::Const(Val::I32(*c)), + Op::Const(Val::I64(c)) => Op::Const(Val::I64(*c)), + Op::Const(Val::F64(c)) => Op::Const(Val::F64(*c)), + Op::LocalGet(x) => Op::LocalGet(*x), + Op::LocalSet(x) => Op::LocalSet(*x), + Op::LocalTee(x) => Op::LocalTee(*x), + Op::Drop => Op::Drop, + Op::Select => Op::Select, + Op::Bin(b) => Op::Bin(match b { + BinOp::I32(o) => BinOp::I32(clone_ibin(o)), + BinOp::I64(o) => BinOp::I64(clone_ibin(o)), + BinOp::I32Cmp(c) => BinOp::I32Cmp(clone_icmp(c)), + BinOp::I64Cmp(c) => BinOp::I64Cmp(clone_icmp(c)), + BinOp::F64(_) => BinOp::F64(FBin::Add), + BinOp::F64Cmp(_) => BinOp::F64Cmp(FCmp::Eq), + }), + Op::Un(u) => Op::Un(clone_un(u)), + } +} + +fn clone_ibin(o: &IBin) -> IBin { + match o { + IBin::Add => IBin::Add, + IBin::Sub => IBin::Sub, + IBin::Mul => IBin::Mul, + IBin::And => IBin::And, + IBin::Or => IBin::Or, + IBin::Xor => IBin::Xor, + IBin::Shl => IBin::Shl, + IBin::ShrS => IBin::ShrS, + IBin::ShrU => IBin::ShrU, + IBin::Rotl => IBin::Rotl, + IBin::Rotr => IBin::Rotr, + } +} + +fn clone_icmp(c: &ICmp) -> ICmp { + match c { + ICmp::Eq => ICmp::Eq, + ICmp::Ne => ICmp::Ne, + ICmp::LtS => ICmp::LtS, + ICmp::LtU => ICmp::LtU, + ICmp::GtS => ICmp::GtS, + ICmp::GtU => ICmp::GtU, + ICmp::LeS => ICmp::LeS, + ICmp::LeU => ICmp::LeU, + ICmp::GeS => ICmp::GeS, + ICmp::GeU => ICmp::GeU, + } +} + +fn clone_un(u: &UnOp) -> UnOp { + match u { + UnOp::I32Eqz => UnOp::I32Eqz, + UnOp::I64Eqz => UnOp::I64Eqz, + UnOp::F64Neg => UnOp::F64Neg, + UnOp::F64Abs => UnOp::F64Abs, + UnOp::F64Sqrt => UnOp::F64Sqrt, + UnOp::I32WrapI64 => UnOp::I32WrapI64, + UnOp::I64ExtendI32S => UnOp::I64ExtendI32S, + UnOp::I64ExtendI32U => UnOp::I64ExtendI32U, + UnOp::F64ConvertI32S => UnOp::F64ConvertI32S, + UnOp::F64ConvertI32U => UnOp::F64ConvertI32U, + UnOp::F64ConvertI64S => UnOp::F64ConvertI64S, + UnOp::F64ConvertI64U => UnOp::F64ConvertI64U, + UnOp::F64ReinterpretI64 => UnOp::F64ReinterpretI64, + UnOp::I64ReinterpretF64 => UnOp::I64ReinterpretF64, + } +} + +#[test] +fn generated_programs_are_accepted() { + let mut rng = Rng(0x9e37_79b9_7f4a_7c15); + let mut longest = 0usize; + for round in 0..3000usize { + let nl = rng.below(6); + let len = rng.below(60); + let prog = random_program(&mut rng, nl, len); + let b = blob(&prog, nl); + assert!( + b.is_some(), + "round {round}: no blob ({} ops, {nl} locals)", + prog.len() + ); + let b = b.unwrap_or_default(); + assert!( + accepted(&b), + "round {round}: refused ({} ops, {nl} locals): {b:02x?}", + prog.len() + ); + longest = longest.max(b.len()); + } + // the programs are not all tiny + assert!(longest > 300, "longest blob {longest}"); +} + +#[test] +fn no_template_means_no_blob() { + // `f64` arithmetic, comparisons and conversions: LIR's are uninterpreted. + let none = |op: Op, n: usize| { + let prog = with_operands(op, n); + assert!( + blob(&prog, 2).is_none(), + "unexpected blob for a program of {} ops", + prog.len() + ); + assert!(X64Backend::emit_body(&prog, 2).is_none()); + }; + none(Op::Bin(BinOp::F64(FBin::Add)), 2); + none(Op::Bin(BinOp::F64(FBin::Div)), 2); + none(Op::Bin(BinOp::F64Cmp(FCmp::Lt)), 2); + none(Op::Un(UnOp::F64Sqrt), 1); + none(Op::Un(UnOp::F64ConvertI32S), 1); + none(Op::Un(UnOp::F64ConvertI64U), 1); + // rotates + none(Op::Bin(BinOp::I32(IBin::Rotl)), 2); + none(Op::Bin(BinOp::I64(IBin::Rotr)), 2); + // a local that does not exist + none(Op::LocalGet(2), 0); + none(Op::LocalSet(5), 1); + // a short stack + none(Op::Bin(BinOp::I32(IBin::Add)), 1); + none(Op::Select, 2); + none(Op::Drop, 0); +} + +#[test] +fn the_frame_has_31_slots() { + // 31 constants fit with no locals; the 32nd does not. + let consts = |n: usize| -> Vec { (0..n).map(|_| Op::Const(Val::I32(1))).collect() }; + let b = blob(&consts(31), 0); + assert!(b.as_deref().map(accepted).unwrap_or(false)); + assert!(blob(&consts(32), 0).is_none()); + // locals and stack share the 31 + assert!(blob(&consts(21), 10).is_some()); + assert!(blob(&consts(22), 10).is_none()); + assert!(blob(&[], 31).is_some()); + assert!(blob(&[], 32).is_none()); +} + +#[test] +fn the_validator_refuses_what_is_not_a_blob() { + let prog = with_operands(Op::Bin(BinOp::I64(IBin::Xor)), 2); + let b = blob(&prog, 0).unwrap_or_default(); + assert!(accepted(&b)); + // cut off + assert!(!accepted(b.get(..b.len().saturating_sub(1)).unwrap_or(&[]))); + // the `ret` replaced by a byte that is no instruction of the subset + let mut bad = b.clone(); + if let Some(last) = bad.last_mut() { + *last = 0xf4; // hlt + } + assert!(!accepted(&bad)); + // entered in the middle of an instruction + assert!(!validate(&b, &[1])); +} From 9510ac032acdcbc51ef48d0c3f2c1cacb323eeec Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 16:51:35 +0000 Subject: [PATCH 026/195] Phase 7.10: the RegExp matcher (backtracking, bounded stack), case-folding and property tables Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-regexp/Cargo.toml | 10 +- crates/clazel-js-regexp/README.md | 151 +- crates/clazel-js-regexp/src/compile.rs | 791 + crates/clazel-js-regexp/src/lib.rs | 35 +- crates/clazel-js-regexp/src/program.rs | 260 + crates/clazel-js-regexp/src/proofs.rs | 183 + crates/clazel-js-regexp/src/stack.rs | 126 + crates/clazel-js-regexp/src/tables.rs | 22014 ++++++++++++++++ crates/clazel-js-regexp/src/unicode.rs | 241 + crates/clazel-js-regexp/src/vm.rs | 725 + crates/clazel-js-regexp/tests/differential.rs | 1101 + crates/clazel-js-regexp/tests/limits.rs | 202 + crates/clazel-js-regexp/tests/matching.rs | 649 + crates/clazel-js-regexp/tests/tables.rs | 561 + 14 files changed, 27029 insertions(+), 20 deletions(-) create mode 100644 crates/clazel-js-regexp/src/compile.rs create mode 100644 crates/clazel-js-regexp/src/program.rs create mode 100644 crates/clazel-js-regexp/src/proofs.rs create mode 100644 crates/clazel-js-regexp/src/stack.rs create mode 100644 crates/clazel-js-regexp/src/tables.rs create mode 100644 crates/clazel-js-regexp/src/unicode.rs create mode 100644 crates/clazel-js-regexp/src/vm.rs create mode 100644 crates/clazel-js-regexp/tests/differential.rs create mode 100644 crates/clazel-js-regexp/tests/limits.rs create mode 100644 crates/clazel-js-regexp/tests/matching.rs create mode 100644 crates/clazel-js-regexp/tests/tables.rs diff --git a/crates/clazel-js-regexp/Cargo.toml b/crates/clazel-js-regexp/Cargo.toml index 71e3004d..410574b5 100644 --- a/crates/clazel-js-regexp/Cargo.toml +++ b/crates/clazel-js-regexp/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" edition.workspace = true license.workspace = true publish.workspace = true -description = "ECMAScript regular expressions: the pattern parser and its early errors (phase-7.md item 7.10, first half). The matcher and the Unicode tables are not written; the crate holds the vendored Unicode Character Database files." +description = "ECMAScript regular expressions: the pattern parser and early errors, and the backtracking matcher with a bounded stack, case folding and property tables (phase-7.md item 7.10)." [dependencies] # ID_Start and ID_Continue above U+007F, for group names (RegExpIdentifierStart @@ -14,10 +14,10 @@ clazel-js-lexer = { path = "../clazel-js-lexer" } # Verification tier (docs/VERIFICATION.md). `tier` is what is proven about the # shipped code today; `target-tier` is what phase-7.md's "Crates" table sets. -# The parser is written and tested (tests/), and src/parser/proofs.rs holds Kani -# harnesses for it, but `tier` stays 0 until CI's full verification of them is -# green on a pull request (CLAUDE.md rule 7), and the matcher, which the -# target tier also covers, does not exist. +# The parser and the matcher are written and tested (tests/), and +# src/parser/proofs.rs and src/proofs.rs hold Kani harnesses for pieces of +# them, but `tier` stays 0 until CI's full verification of them is green on a +# pull request (CLAUDE.md rule 7) and the gaps the README lists are closed. [package.metadata.clazel] tier = 0 target-tier = 1 diff --git a/crates/clazel-js-regexp/README.md b/crates/clazel-js-regexp/README.md index 980433f4..c947a771 100644 --- a/crates/clazel-js-regexp/README.md +++ b/crates/clazel-js-regexp/README.md @@ -4,10 +4,12 @@ Part of [Clazel](../../README.md). The ECMAScript pattern parser, the matcher and the Unicode tables behind `\p{..}` and case folding ([phase-7.md](../../docs/phases/phase-7.md) item 7.10). -**Written: the pattern parser and its early errors. Not written: the matcher, -the case-folding tables and the property tables.** Tier 0 (target tier 1). +**Written: the pattern parser and its early errors; the backtracking matcher +with a bounded stack, a step budget and an interrupt hook; the case-folding +tables, and the General_Category and binary-property tables (not `Script`).** +Tier 0 (target tier 1): see "What is proven". -The Unicode 18.0.0 files the tables will be generated from are vendored in +The Unicode 18.0.0 files the tables are generated from are vendored in `tests/data/ucd-regexp/` (see `SOURCE.md` there). ## The parser @@ -66,6 +68,103 @@ choices at its top. only), so `new RegExp(..)` strings and the generated property-escape tests are not run. +## The matcher + +```rust +let pattern = parse(&pattern_units, flags)?; // §22.2.1† +let program = compile(&pattern, flags)?; // §22.2.2† as instructions +let m = program.exec(&input, start, sticky, &Limits::default(), None)?; +``` + +`Program::exec` matches UTF-16 input (`&[u16]`) from a code unit index +`start`: only there with `sticky` (`y`), else scanning forward. `lastIndex`, +`g` and what to do with the result are the caller's. A `Match` holds the +captures as code unit index pairs (index 0 the whole match; `None` for a group +that did not take part); `Program::named_capture` finds the group of a name, +duplicate names included. + +Spec: §22.2.2† (Pattern Semantics), section numbers marked † as everywhere. +`src/compile.rs` and `src/vm.rs` list the modelling choices at their tops. + +**Covered** + +- Alternation, groups (capturing, named, duplicate names, non-capturing), + greedy and lazy quantifiers with RepeatMatcher's empty check and the reset of + captures on each iteration, counted quantifiers (`{n,m}` is a counter, not a + copy), backreferences (numbered, named, backward ones in lookbehind), + `^ $ \b \B` with `m`, `.` with and without `s`, classes and the escapes + `\d \D \s \S \w \W`. +- Lookahead and lookbehind, positive and negative. A lookbehind matches + backwards (terms right to left, characters read before the position, groups + capture end first); bodies are atomic. +- `i`: `Canonicalize` without `u`/`v` is `toUppercase` of the code unit (never + into or out of ASCII, never to more than one unit), with `u`/`v` simple case + folding; `\w`/`\b` get U+017F and U+212A with `u`/`v` and `i`. Classes ask, + as the standard does, whether some member has the character's canonical form + (so `/\P{Lu}/iu` matches `A`, and `v` mode does not). +- `u` and `v` (code points): `.` and classes match a pair as one character, + a lone surrogate is itself, and a search steps by code point. +- Modifiers `(?ims-ims:..)`, as compile-time flag scopes. +- `v` class sets: union, `&&`, `--`, nested and negated classes, ranges, and + `\q{..}` with strings (matched longest first, then single characters, then + the empty string). +- `\p{..}` and `\P{..}` for `General_Category` (every value and alias) and + the binary properties of ECMA-262's table (`Any`, `ASCII`, `Assigned` and + the others from tables generated from the UCD). +- **An explicit backtrack stack, no recursion over the pattern or the input.** + Choice points and register changes are entries of a `Vec` capped at + `Limits::max_stack` entries (default a million, 16 to 24 bytes each). A + match that needs more is `MatchError::StackOverflow`, which the engine turns + into a `RangeError`: a listed deviation (the standard has no limit). A + greedy loop over one character is one entry for the whole run. +- **A step budget and an interrupt hook** for 7.0(g): `Limits::max_steps` + (`MatchError::StepLimit`), and a closure asked every 4096 steps + (`MatchError::Interrupted`). A catastrophic pattern such as `(a*)*b` runs + until one of these; the empty check and the one-entry runs keep its stack + shallow, so it is the step budget that ends it, while `(?:a|aa)*b` on a long + run of `a` fills the stack first and ends in `StackOverflow` + (`tests/limits.rs`). +- Compilation recurses over the pattern, bounded by the parser's `MAX_DEPTH` + (a deeper hand-built tree is `CompileError::TooDeep`); matching does not. + +**Not done** + +- `\p{Script=..}`, `\p{Script_Extensions=..}` and the properties of strings + (`\p{RGI_Emoji}` and the like, `v` mode): `compile` returns + `CompileError::UnsupportedProperty`. The parser accepts the names; the + tables are not generated. (`Scripts.txt`, `ScriptExtensions.txt` and the + emoji sequence files are vendored; the generator in `tests/tables.rs` is + where they would go.) +- The `RegExp` object: `lastIndex`, `exec`'s result object, `d` indices, + `Symbol.replace` and the rest (7.10's other items). +- Test262's `built-ins/RegExp` is not vendored, and the + `language/literals/regexp` tests that run a match need a JavaScript engine + (they assert on the result of `.exec`), so no Test262 match test is run + here. The conformance tests are the standard's own worked examples + (`tests/matching.rs`). +- Two choices, listed in `src/vm.rs`: a match that starts inside a surrogate + pair with `u` starts at the pair, and the stack bound's allocation can be up + to twice `max_stack` entries (the `Vec` doubles). +- The section numbers are not checked against the specification's text (†). +- No Verus. No `spec.rs`: the compiler and the matcher are the transcription. + +## The tables + +`src/tables.rs` is generated by `tests/tables.rs` from `tests/data/ucd-regexp/` +(there is no `cargo xtask tables` step: the generator is a test, so no other +crate's check is affected). The test `tables_are_current` fails if the +committed file differs from what the generator writes; to rewrite it run +`CLAZEL_WRITE_TABLES=1 cargo test -p clazel-js-regexp --test tables` and +`cargo fmt`. Contents: Simple Case Folding (`CaseFolding.txt`, `C` and `S`), +`toUppercase` of the BMP (`SpecialCasing.txt` and `UnicodeData.txt`), +`General_Category` (`DerivedGeneralCategory.txt`), and the binary properties +(`PropList.txt`, `DerivedCoreProperties.txt`, `DerivedNormalizationProps.txt`, +`DerivedBinaryProperties.txt`, `emoji-data.txt`). About 22 000 lines. +Independent checks in the same file: the categories against `UnicodeData.txt` +for every code point, the equivalence classes (`unicode::equivalents`) against +`canonicalize` for every code point, folding idempotent, the word-character +extras exactly U+017F and U+212A, every property name resolving. + ## Evidence - `tests/parser.rs`: about 240 hand-written accept and reject cases by mode @@ -80,11 +179,45 @@ choices at its top. and reason (lexical errors, which are `clazel-js-lexer`'s; patterns built by computing a string; two tests whose error is in the JavaScript parser). - `tests/conformance_names.rs`: the property names against the vendored UCD. +- `tests/matching.rs`: 234 hand-written matches by feature, with the + result the standard's algorithm gives (several are the standard's own + worked examples: `(z)((a+)?(b+)?(c))*`, `(?=(a+))a*b\1`, + `(.*?)a(?!(a+)b\2c)\2(.*)`, `(?<=(\d+)(\d+))$`), start indexes and `y`, + long inputs (100 000 characters, counts of 100 000 and 4 000 000 000). +- `tests/limits.rs`: catastrophic patterns end in `StepLimit` or + `StackOverflow`; the stack bound is exact; the hook is asked and stops. +- `tests/differential.rs`: a reference matcher (a recursive, exponential, + spec-literal transcription of §22.2.2† over characters, with closures for + continuations, sharing only the parser, the case-folding function and the + tables) against the matcher, over random patterns and inputs: 12 000 + patterns, about 87 000 comparisons (about 52 000 with a match), each at + every start with and without `y`, in all of `i m s u v`. The test is not + vacuous: injecting a bug into the empty check, the backward group capture, + `\b`, the word-character extras, lookahead negation, or subtraction + operand order each made it fail. A reduced count under Miri. +- `tests/tables.rs`: the generated tables against the UCD, above. - `src/proofs.rs`: the Kani harnesses, below. ## Kani harnesses (compiled only under `cargo kani`) -`src/parser/proofs.rs`. Each runs one step of the parser on every input up to +**The matcher's** (`src/proofs.rs`): + +| Harness | Checks | +|---------|--------| +| `canonicalize_unit_any` | for every code unit, `Canonicalize` without `u` is a code unit and a non-ASCII unit never becomes ASCII | +| `simple_fold_any` | simple case folding of every code point is a code point | +| `stack_push_respects_the_bound` | any bound up to 4, six pushes: the length never exceeds the bound, a push is refused exactly when full | +| `stack_pop_returns_the_last_push` | a pop returns the last push, an empty stack nothing | +| `stack_commit_look_keeps_only_the_undos` | a positive lookaround's commit drops the mark and the choices above it, keeps the undo entries in order, returns the mark's position | +| `read_any_3` | reading a character at any position of any 3-unit input, either direction, either mode: the new position is inside and one or two units away, the character valid | + +Not here: the matcher loop and the compiler (they build `Vec`s in loops, which +CBMC does not finish on, as for the parser below), and that the inverse case +table agrees with the forward one (a bisection twice over a table, with a +growing `Vec`: over ten CPU-minutes). Those are tested: the differential, and +`tests/tables.rs` for every code point. + +**The parser's** (`src/parser/proofs.rs`). Each runs one step of the parser on every input up to a bound (a symbolic array of code units, a symbolic length, a symbolic start position), and checks that no panic, overflow or out-of-bounds read is reachable, with unwinding assertions that every loop finishes within the stated @@ -119,5 +252,11 @@ duplicate-name check (`names_in_disjunction`) is in no harness either. Group names are checked only below U+0080: the lexer's `ID_Start` table lookup, which Verus proves total there, is a bisection that costs CBMC minutes. -**The tier stays 0** until CI's full verification of the harnesses has passed -on a pull request (CLAUDE.md rule 7), and the whole-parse gap above is closed. +## What is proven + +Nothing beyond the harnesses above, and none of them has had CI's full +verification on a pull request. **The tier stays 0** until it has (CLAUDE.md +rule 7), and the whole-parse gap and the matcher gap above are closed. The +matcher is tested, not proven: that it implements §22.2.2† rests on the +differential against a reference written from the same reading of the +standard, and on the hand-written cases. diff --git a/crates/clazel-js-regexp/src/compile.rs b/crates/clazel-js-regexp/src/compile.rs new file mode 100644 index 00000000..7e75bd7c --- /dev/null +++ b/crates/clazel-js-regexp/src/compile.rs @@ -0,0 +1,791 @@ +//! From the syntax tree to instructions: ECMA-262 §22.2.2† (Pattern +//! Semantics), one production at a time. Section numbers marked † are from +//! memory (the specification's text is not vendored). +//! +//! # Modelling choices +//! +//! - **Continuations become jumps.** The standard's Matcher is a closure from +//! a MatchState and a continuation to a MatchState or failure. Here a +//! Matcher is a run of instructions that falls through to the next one on +//! success, and a failure is a pop of the backtrack stack. Every place the +//! standard tries one continuation and then another (alternation, a greedy +//! or lazy quantifier, a class with strings) is a [`Inst::Split`] or a +//! stack entry, in the order the standard tries them. +//! - **Direction.** A lookbehind body is compiled with `direction` backward +//! (§22.2.2.3.1† Alternative: "the terms are matched right to left"): its +//! terms in reverse order, its characters read before the position, and its +//! groups closing with the end first. A lookahead inside a lookbehind is +//! forward again, and the other way round. +//! - **Modifiers.** `i`, `m` and `s` are compile-time state: `(?i-s:..)` +//! compiles its body with them changed, so no instruction asks for the flag +//! at match time. `u` and `v` are the pattern's, and cannot be modified. +//! - **Counting.** `{n,m}` is a counter register and a loop, never `n` copies +//! of the body. A greedy quantifier over one character with no captures is +//! one instruction ([`Inst::Run`]) and one stack entry for the whole run. +//! - **Classes.** A character class is a postfix program over its leaves (a +//! character, a range, an escape) and `not`, `or`, `and`, `minus`, so that +//! matching a character needs no recursion over the class's nesting. With +//! `i`, each leaf asks whether *some* character with the same `Canonicalize` +//! as the input's is in it (CharacterSetMatcher, §22.2.2.7.1†), which is the +//! standard's rule for classes without `v`; with `v` the standard folds each +//! leaf first and then combines them, which is the same formula applied leaf +//! by leaf, with `\P`, `\D`, `\S`, `\W` and `[^..]` as a `not` over the +//! positive leaf. (Without `v`, `\P{Lu}` with `iu` matches `a`: the complement +//! is taken before folding, as the standard does.) +//! - **Strings in classes (`v`).** A class that can match strings of more or +//! fewer than one character is an alternation: the strings, longest first +//! (ties in code point order), then the single characters, then the empty +//! string (§22.2.2.7† CompileAtom, "CharacterClass"). +//! - **Recursion** over the tree is bounded by [`MAX_DEPTH`]: the parser +//! never builds a deeper one, and a tree built by hand that is deeper is +//! [`CompileError::TooDeep`]. The matcher itself does not recurse. + +use std::collections::BTreeSet; + +use crate::ast::{ + Alternative, Assertion, Atom, CharacterClass, ClassContents, ClassEscape, ClassItem, + ClassSetExpr, ClassSetItem, ClassSetOperand, Disjunction, Group, Look, Pattern, Property, + Quantifier, Term, TermKind, +}; +use crate::flags::Flags; +use crate::parser::MAX_DEPTH; +use crate::program::{ClassOp, ClassProg, EscKind, Inst, One, OneKind, Program}; +use crate::unicode::{self, Prop, canonicalize, simple_fold}; + +/// Why a pattern cannot be compiled. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum CompileError { + /// The tree nests deeper than [`MAX_DEPTH`] (a tree from + /// [`crate::parse`] never does). + TooDeep, + /// A backreference to a group that does not exist (a tree from + /// [`crate::parse`] never has one). + BackReference(u32), + /// A `\p{..}` whose table is not generated: `Script`, `Script_Extensions` + /// and the properties of strings (`v`). The text names it. + UnsupportedProperty(String), + /// More than 2^32 instructions or registers. + TooLarge, +} + +impl core::fmt::Display for CompileError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + CompileError::TooDeep => write!(f, "pattern nests too deeply"), + CompileError::BackReference(n) => write!(f, "no group {n} to refer to"), + CompileError::UnsupportedProperty(p) => write!(f, "unsupported property {p}"), + CompileError::TooLarge => write!(f, "pattern too large"), + } + } +} + +type R = Result; + +/// Compiles `pattern`, parsed with `flags`, into a [`Program`]. +/// +/// # Errors +/// +/// [`CompileError`]: a `\p{..}` that has no table, or (for a tree not made by +/// [`crate::parse`]) too deep or with a dangling backreference. +pub fn compile(pattern: &Pattern, flags: Flags) -> Result { + let regs0 = pattern + .capture_count + .checked_add(1) + .and_then(|n| n.checked_mul(2)) + .ok_or(CompileError::TooLarge)?; + let mut c = Compiler { + unicode: flags.unicode_mode(), + v: flags.unicode_sets, + capture_count: pattern.capture_count, + group_names: &pattern.group_names, + insts: Vec::new(), + classes: Vec::new(), + backrefs: Vec::new(), + next_reg: regs0, + }; + let st = St { + ic: flags.ignore_case, + ml: flags.multiline, + dot_all: flags.dot_all, + back: false, + }; + c.disjunction(&pattern.disjunction, st, 1)?; + c.emit(Inst::Match)?; + Ok(Program { + insts: c.insts, + classes: c.classes, + backrefs: c.backrefs, + regs: usize::try_from(c.next_reg).map_err(|_| CompileError::TooLarge)?, + capture_count: pattern.capture_count, + unicode: c.unicode, + group_names: pattern.group_names.clone(), + }) +} + +/// The compile-time state: the flags in scope and the direction. +#[derive(Debug, Clone, Copy)] +struct St { + ic: bool, + ml: bool, + dot_all: bool, + back: bool, +} + +struct Compiler<'a> { + unicode: bool, + v: bool, + capture_count: u32, + group_names: &'a [(Vec, u32)], + insts: Vec, + classes: Vec, + backrefs: Vec>, + next_reg: u32, +} + +/// What a quantifier repeats. +enum Body<'t> { + One(One), + Kind(&'t TermKind), +} + +/// An alternative of a class with strings. +enum Alt { + Str(Vec), + One(One), + Empty, +} + +fn to_usize(n: u64) -> usize { + usize::try_from(n).unwrap_or(usize::MAX) +} + +impl Compiler<'_> { + fn pc(&self) -> R { + u32::try_from(self.insts.len()).map_err(|_| CompileError::TooLarge) + } + + fn emit(&mut self, i: Inst) -> R { + let at = self.pc()?; + self.insts.push(i); + Ok(at) + } + + fn set(&mut self, at: u32, i: Inst) { + if let Some(slot) = self.insts.get_mut(at as usize) { + *slot = i; + } + } + + fn reg(&mut self) -> R { + let r = self.next_reg; + self.next_reg = r.checked_add(1).ok_or(CompileError::TooLarge)?; + Ok(r) + } + + fn add_class(&mut self, c: ClassProg) -> R { + let id = u32::try_from(self.classes.len()).map_err(|_| CompileError::TooLarge)?; + self.classes.push(c); + Ok(id) + } + + /// Disjunction (§22.2.2.3.1†): `Alternative | Disjunction` tries the left + /// alternative, then the right one. + fn disjunction(&mut self, d: &Disjunction, st: St, depth: usize) -> R { + if depth > MAX_DEPTH.saturating_add(1) { + return Err(CompileError::TooDeep); + } + let n = d.alternatives.len(); + let mut jumps = Vec::new(); + for (i, alt) in d.alternatives.iter().enumerate() { + if i.saturating_add(1) >= n { + self.alternative(alt, st, depth)?; + } else { + let split = self.emit(Inst::Split { + first: 0, + second: 0, + })?; + let first = self.pc()?; + self.alternative(alt, st, depth)?; + jumps.push(self.emit(Inst::Jmp(0))?); + let second = self.pc()?; + self.set(split, Inst::Split { first, second }); + } + } + let end = self.pc()?; + for j in jumps { + self.set(j, Inst::Jmp(end)); + } + Ok(()) + } + + /// Alternative (§22.2.2.3.1†): the terms in order, or with `direction` + /// backward in reverse order. + fn alternative(&mut self, a: &Alternative, st: St, depth: usize) -> R { + if st.back { + for t in a.terms.iter().rev() { + self.term(t, st, depth)?; + } + } else { + for t in &a.terms { + self.term(t, st, depth)?; + } + } + Ok(()) + } + + fn term(&mut self, t: &Term, st: St, depth: usize) -> R { + match &t.quantifier { + None => self.kind(&t.kind, st, depth), + Some(q) => self.quantified(&t.kind, q, st, depth), + } + } + + fn kind(&mut self, k: &TermKind, st: St, depth: usize) -> R { + match k { + TermKind::Assertion(a) => { + let extras = self.unicode && st.ic; + let inst = match a { + Assertion::Start => Inst::LineStart { multiline: st.ml }, + Assertion::End => Inst::LineEnd { multiline: st.ml }, + Assertion::WordBoundary => Inst::WordBoundary { neg: false, extras }, + Assertion::NotWordBoundary => Inst::WordBoundary { neg: true, extras }, + }; + self.emit(inst).map(|_| ()) + } + TermKind::Look(l) => self.look(l, st, depth), + TermKind::Atom(a) => self.atom(a, st, depth), + } + } + + /// Assertion `(?=`, `(?!`, `(?<=`, `(? R { + let start = self.emit(Inst::LookStart { + neg: l.negative, + end: 0, + })?; + let inner = St { + back: l.behind, + ..st + }; + self.disjunction(&l.body, inner, depth.saturating_add(1))?; + self.emit(Inst::LookEnd { neg: l.negative })?; + let end = self.pc()?; + self.set( + start, + Inst::LookStart { + neg: l.negative, + end, + }, + ); + Ok(()) + } + + fn emit_body(&mut self, b: &Body<'_>, st: St, depth: usize) -> R { + match b { + Body::One(o) => self.emit(Inst::One(o.clone())).map(|_| ()), + Body::Kind(k) => self.kind(k, st, depth), + } + } + + /// Term :: Atom Quantifier (§22.2.2.3.1†, RepeatMatcher §22.2.2.3.2†). + fn quantified(&mut self, k: &TermKind, q: &Quantifier, st: St, depth: usize) -> R { + let min = to_usize(q.min); + let max = q.max.map_or(usize::MAX, to_usize); + // RepeatMatcher step 1: "If max = 0, return c(x)". + if max == 0 { + return Ok(()); + } + let one = match k { + TermKind::Atom(a) => self.one_of(a, st, depth)?, + _ => None, + }; + if q.greedy + && let Some(o) = &one + { + return self + .emit(Inst::Run { + one: o.clone(), + min, + max, + }) + .map(|_| ()); + } + let body = match one { + Some(o) => Body::One(o), + None => Body::Kind(k), + }; + if min == 1 && max == 1 { + return self.emit_body(&body, st, depth); + } + let counter = self.reg()?; + let pos_reg = self.reg()?; + self.emit(Inst::CounterInit { reg: counter })?; + let head = self.emit(Inst::LoopHead { + counter, + min, + max, + greedy: q.greedy, + body: 0, + exit: 0, + })?; + let body_pc = self.pc()?; + // Step 4: "For each integer k in the inclusive interval from + // parenIndex + 1 to parenIndex + parenCount, set cap[k] to undefined." + if let Some((first, last)) = cap_range(k) { + self.emit(Inst::ResetCaps { first, last })?; + } + self.emit(Inst::SavePos { reg: pos_reg })?; + self.emit_body(&body, st, depth)?; + // Step 2.b: "If min = 0 and y's endIndex = x's endIndex, return + // failure." + self.emit(Inst::LoopEnd { + counter, + pos_reg, + min, + head, + })?; + let exit = self.pc()?; + self.set( + head, + Inst::LoopHead { + counter, + min, + max, + greedy: q.greedy, + body: body_pc, + exit, + }, + ); + Ok(()) + } + + /// The matcher for an atom that is one character, with no captures, or + /// `None` for the others (groups, backreferences, a class with strings). + fn one_of(&mut self, a: &Atom, st: St, depth: usize) -> R> { + let kind = match a { + Atom::Char(c) => OneKind::Char { + c: if st.ic { + canonicalize(*c, self.unicode) + } else { + *c + }, + ic: st.ic, + }, + Atom::Dot => OneKind::Dot { all: st.dot_all }, + Atom::Escape(e) => { + let mut ops = Vec::new(); + self.escape(e, &mut ops)?; + let id = self.add_class(ClassProg { + ops, + ic: st.ic, + invert: false, + word_extras: self.unicode && st.ic, + })?; + OneKind::Class(id) + } + Atom::Class(c) => { + if !self.class_strings_set(c, st, depth)?.is_empty() { + return Ok(None); + } + let prog = self.class_prog(c, st, depth)?; + OneKind::Class(self.add_class(prog)?) + } + _ => return Ok(None), + }; + Ok(Some(One { + kind, + back: st.back, + })) + } + + fn atom(&mut self, a: &Atom, st: St, depth: usize) -> R { + if let Some(one) = self.one_of(a, st, depth)? { + return self.emit(Inst::One(one)).map(|_| ()); + } + match a { + Atom::Group(g) => self.group(g, st, depth), + Atom::Modified(m) => { + // §22.2.1†, RegularExpressionModifiers: `add` turns a flag on + // and `remove` turns it off, for the body only. + let flag = |cur: bool, add: bool, remove: bool| (cur || add) && !remove; + let inner = St { + ic: flag(st.ic, m.add.ignore_case, m.remove.ignore_case), + ml: flag(st.ml, m.add.multiline, m.remove.multiline), + dot_all: flag(st.dot_all, m.add.dot_all, m.remove.dot_all), + back: st.back, + }; + self.disjunction(&m.body, inner, depth.saturating_add(1)) + } + Atom::BackReference(n) => { + if *n == 0 || *n > self.capture_count { + return Err(CompileError::BackReference(*n)); + } + self.backref(vec![*n], st) + } + Atom::NamedBackReference(name) => { + let groups: Vec = self + .group_names + .iter() + .filter(|(n, _)| n == name) + .map(|&(_, i)| i) + .collect(); + if groups.is_empty() { + return Err(CompileError::BackReference(0)); + } + self.backref(groups, st) + } + Atom::Class(c) => self.class_with_strings(c, st, depth), + // One character, handled by `one_of`. + Atom::Char(_) | Atom::Dot | Atom::Escape(_) => Ok(()), + } + } + + fn backref(&mut self, groups: Vec, st: St) -> R { + let id = u32::try_from(self.backrefs.len()).map_err(|_| CompileError::TooLarge)?; + self.backrefs.push(groups); + self.emit(Inst::BackRef { + id, + ic: st.ic, + back: st.back, + }) + .map(|_| ()) + } + + /// Atom :: `(` GroupSpecifier Disjunction `)` (§22.2.2.3.1†): the group + /// records where it began, and sets the capture when it ends. + fn group(&mut self, g: &Group, st: St, depth: usize) -> R { + let inner_depth = depth.saturating_add(1); + match g.index { + Some(cap) => { + let reg = self.reg()?; + self.emit(Inst::GroupOpen { reg })?; + self.disjunction(&g.body, st, inner_depth)?; + self.emit(Inst::GroupClose { + cap, + reg, + back: st.back, + }) + .map(|_| ()) + } + None => self.disjunction(&g.body, st, inner_depth), + } + } + + /// A `\d`-like escape as a leaf (or, with `v`, a leaf and a `not`). + fn escape(&self, e: &ClassEscape, ops: &mut Vec) -> R { + let (kind, neg) = match e { + ClassEscape::Digit => (EscKind::Digit, false), + ClassEscape::NotDigit => (EscKind::Digit, true), + ClassEscape::Space => (EscKind::Space, false), + ClassEscape::NotSpace => (EscKind::Space, true), + ClassEscape::Word => (EscKind::Word, false), + ClassEscape::NotWord => (EscKind::Word, true), + ClassEscape::Property { negated, property } => { + (EscKind::Prop(self.property(property)?), *negated) + } + }; + if self.v && neg { + ops.push(ClassOp::Esc { kind, neg: false }); + ops.push(ClassOp::Not); + } else { + ops.push(ClassOp::Esc { kind, neg }); + } + Ok(()) + } + + /// UnicodePropertyValueExpression (§22.2.2.9†). + fn property(&self, p: &Property) -> R { + let unsupported = |what: &str, v: &str| { + CompileError::UnsupportedProperty(format!("{what}={v}: no table is generated")) + }; + match p { + Property::GeneralCategory(v) => unicode::category_mask(v) + .map(Prop::Category) + .ok_or_else(|| unsupported("General_Category", v)), + Property::Binary(n) => { + unicode::binary_property(n).ok_or_else(|| unsupported("binary property", n)) + } + Property::Script(v) => Err(unsupported("Script", v)), + Property::ScriptExtensions(v) => Err(unsupported("Script_Extensions", v)), + Property::Strings(n) => Err(unsupported("property of strings", n)), + } + } + + /// CharacterClass (§22.2.2.7† CompileToCharSet) as a postfix program. + fn class_prog(&self, c: &CharacterClass, st: St, depth: usize) -> R { + let mut ops = Vec::new(); + let mut invert = false; + match &c.contents { + ClassContents::Ranges(items) => { + for it in items { + match it { + ClassItem::Char(x) => ops.push(ClassOp::Char(*x)), + ClassItem::Range(a, b) => ops.push(ClassOp::Range(*a, *b)), + ClassItem::Escape(e) => self.escape(e, &mut ops)?, + } + } + ops.push(ClassOp::Or( + u32::try_from(items.len()).map_err(|_| CompileError::TooLarge)?, + )); + invert = c.negated; + } + ClassContents::Set(expr) => { + self.set_expr(expr, &mut ops, depth.saturating_add(1))?; + if c.negated { + ops.push(ClassOp::Not); + } + } + } + Ok(ClassProg { + ops, + ic: st.ic, + invert, + word_extras: self.unicode && st.ic, + }) + } + + /// ClassSetExpression (`v`): union, intersection or subtraction of its + /// operands. + fn set_expr(&self, e: &ClassSetExpr, ops: &mut Vec, depth: usize) -> R { + if depth > MAX_DEPTH.saturating_add(2) { + return Err(CompileError::TooDeep); + } + let count = |n: usize| u32::try_from(n).map_err(|_| CompileError::TooLarge); + match e { + ClassSetExpr::Union(items) => { + for it in items { + match it { + ClassSetItem::Operand(o) => self.operand(o, ops, depth)?, + ClassSetItem::Range(a, b) => ops.push(ClassOp::Range(*a, *b)), + } + } + ops.push(ClassOp::Or(count(items.len())?)); + } + ClassSetExpr::Intersection(os) => { + for o in os { + self.operand(o, ops, depth)?; + } + ops.push(ClassOp::And(count(os.len())?)); + } + ClassSetExpr::Subtraction(os) => { + for o in os { + self.operand(o, ops, depth)?; + } + ops.push(ClassOp::Sub(count(os.len())?)); + } + } + Ok(()) + } + + fn operand(&self, o: &ClassSetOperand, ops: &mut Vec, depth: usize) -> R { + match o { + ClassSetOperand::Char(c) => ops.push(ClassOp::Char(*c)), + ClassSetOperand::Escape(e) => self.escape(e, ops)?, + ClassSetOperand::Nested { negated, expr } => { + self.set_expr(expr, ops, depth.saturating_add(1))?; + if *negated { + ops.push(ClassOp::Not); + } + } + ClassSetOperand::Strings(list) => { + // The one-character strings are characters of the set; the + // others are in `strings_of`. + let mut n = 0u32; + for s in list { + if let [c] = s.as_slice() { + ops.push(ClassOp::Char(*c)); + n = n.saturating_add(1); + } + } + ops.push(ClassOp::Or(n)); + } + } + Ok(()) + } + + /// The strings a `v` class can match that are not one character (the empty + /// string included), folded if the class ignores case; empty for a class + /// without `v` or a negated one. + fn class_strings_set(&self, c: &CharacterClass, st: St, depth: usize) -> R>> { + match &c.contents { + ClassContents::Set(e) if !c.negated => { + self.strings_of(e, self.v && st.ic, depth.saturating_add(1)) + } + _ => Ok(BTreeSet::new()), + } + } + + /// The strings of a ClassSetExpression that are not one character: + /// MayContainStrings's sets (§22.2.1.1†), computed. A union holds those of + /// its operands, an intersection those of all, a subtraction those of the + /// first that the others lack. + fn strings_of(&self, e: &ClassSetExpr, fold: bool, depth: usize) -> R>> { + if depth > MAX_DEPTH.saturating_add(2) { + return Err(CompileError::TooDeep); + } + let next = depth.saturating_add(1); + match e { + ClassSetExpr::Union(items) => { + let mut out = BTreeSet::new(); + for it in items { + if let ClassSetItem::Operand(o) = it { + out.extend(self.operand_strings(o, fold, next)?); + } + } + Ok(out) + } + ClassSetExpr::Intersection(os) => { + let mut it = os.iter(); + let mut out = match it.next() { + Some(o) => self.operand_strings(o, fold, next)?, + None => BTreeSet::new(), + }; + for o in it { + let other = self.operand_strings(o, fold, next)?; + out.retain(|s| other.contains(s)); + } + Ok(out) + } + ClassSetExpr::Subtraction(os) => { + let mut it = os.iter(); + let mut out = match it.next() { + Some(o) => self.operand_strings(o, fold, next)?, + None => BTreeSet::new(), + }; + for o in it { + let other = self.operand_strings(o, fold, next)?; + out.retain(|s| !other.contains(s)); + } + Ok(out) + } + } + } + + fn operand_strings( + &self, + o: &ClassSetOperand, + fold: bool, + depth: usize, + ) -> R>> { + match o { + ClassSetOperand::Char(_) | ClassSetOperand::Escape(_) => Ok(BTreeSet::new()), + ClassSetOperand::Nested { negated, expr } => { + if *negated { + Ok(BTreeSet::new()) + } else { + self.strings_of(expr, fold, depth) + } + } + ClassSetOperand::Strings(list) => Ok(list + .iter() + .filter(|s| s.len() != 1) + .map(|s| { + if fold { + s.iter().map(|&c| simple_fold(c)).collect() + } else { + s.clone() + } + }) + .collect()), + } + } + + /// A `v` class with strings: the strings longest first, then the single + /// characters, then the empty string if it is in the set. + fn class_with_strings(&mut self, c: &CharacterClass, st: St, depth: usize) -> R { + let set = self.class_strings_set(c, st, depth)?; + let has_empty = set.contains(&Vec::new()); + let mut multi: Vec> = set.into_iter().filter(|s| !s.is_empty()).collect(); + multi.sort_by(|a, b| b.len().cmp(&a.len()).then_with(|| a.cmp(b))); + let prog = self.class_prog(c, st, depth)?; + let id = self.add_class(prog)?; + let mut alts: Vec = multi.into_iter().map(Alt::Str).collect(); + alts.push(Alt::One(One { + kind: OneKind::Class(id), + back: st.back, + })); + if has_empty { + alts.push(Alt::Empty); + } + let n = alts.len(); + let mut jumps = Vec::new(); + for (i, alt) in alts.iter().enumerate() { + let last = i.saturating_add(1) >= n; + let split = if last { + None + } else { + Some(self.emit(Inst::Split { + first: 0, + second: 0, + })?) + }; + let first = self.pc()?; + match alt { + Alt::Str(s) => { + let one = |c: u32| One { + kind: OneKind::Char { + c: if st.ic { simple_fold(c) } else { c }, + ic: st.ic, + }, + back: st.back, + }; + if st.back { + for &c in s.iter().rev() { + self.emit(Inst::One(one(c)))?; + } + } else { + for &c in s { + self.emit(Inst::One(one(c)))?; + } + } + } + Alt::One(o) => { + self.emit(Inst::One(o.clone()))?; + } + Alt::Empty => {} + } + if let Some(split) = split { + jumps.push(self.emit(Inst::Jmp(0))?); + let second = self.pc()?; + self.set(split, Inst::Split { first, second }); + } + } + let end = self.pc()?; + for j in jumps { + self.set(j, Inst::Jmp(end)); + } + Ok(()) + } +} + +/// The first and last capture number of the groups inside a term (with the +/// term itself, if it is a group), by an explicit walk: no recursion. +fn cap_range(k: &TermKind) -> Option<(u32, u32)> { + /// Records a group's number and queues the bodies a kind holds. + fn visit<'t>(k: &'t TermKind, work: &mut Vec<&'t Disjunction>, lo: &mut u32, hi: &mut u32) { + match k { + TermKind::Atom(Atom::Group(g)) => { + if let Some(i) = g.index { + *lo = (*lo).min(i); + *hi = (*hi).max(i); + } + work.push(&g.body); + } + TermKind::Atom(Atom::Modified(m)) => work.push(&m.body), + TermKind::Look(l) => work.push(&l.body), + _ => {} + } + } + let mut lo = u32::MAX; + let mut hi = 0u32; + let mut work: Vec<&Disjunction> = Vec::new(); + visit(k, &mut work, &mut lo, &mut hi); + while let Some(d) = work.pop() { + for alt in &d.alternatives { + for t in &alt.terms { + visit(&t.kind, &mut work, &mut lo, &mut hi); + } + } + } + (hi != 0).then_some((lo, hi)) +} diff --git a/crates/clazel-js-regexp/src/lib.rs b/crates/clazel-js-regexp/src/lib.rs index 1d44eb46..143ab838 100644 --- a/crates/clazel-js-regexp/src/lib.rs +++ b/crates/clazel-js-regexp/src/lib.rs @@ -1,32 +1,49 @@ -//! ECMAScript regular expressions (phase-7.md item 7.10): this is the -//! pattern parser. The matcher and the Unicode tables behind `\p{..}` and -//! case folding are not written. +//! ECMAScript regular expressions (phase-7.md item 7.10): the pattern parser +//! and the backtracking matcher. //! //! Spec: ECMA-262, 2026 edition (`clazel-js-lexer/SPEC-PIN.md`): §22.2.1† //! (the pattern grammar), §22.2.1.1† (its early errors), Annex B §B.1.2† -//! (the web-compatibility grammar without `u` or `v`), and the flag rules of -//! §13.2.7.1† and §22.2.3.4†. Section numbers marked † are from memory (the -//! specification's text is not vendored); see [`parser`] for the modelling +//! (the web-compatibility grammar without `u` or `v`), §22.2.2† (Pattern +//! Semantics, the matcher), and the flag rules of §13.2.7.1† and §22.2.3.4†. +//! Section numbers marked † are from memory (the specification's text is not +//! vendored); see [`parser`], [`compile`] and [`vm`] for the modelling //! choices. //! //! - [`parse`] / [`parse_with`]: a pattern (UTF-16 code units) and //! [`Flags`] to a [`Pattern`] (the tree of [`ast`]), or an [`Error`]. //! - [`Flags::parse`]: the flag string. +//! - [`compile`]: a [`Pattern`] and its [`Flags`] to a [`Program`]. +//! - [`Program::exec`]: the program on UTF-16 input from a start index, with +//! [`Limits`] (a bounded backtrack stack, a step budget) and an interrupt +//! hook; the captures of the match as a [`Match`], or a [`MatchError`]. +//! - [`unicode`] and [`tables`]: case canonicalization and `\p{..}` sets, +//! from tables generated from the vendored Unicode 18.0.0 files. //! - [`props`]: the property names `\p{..}` accepts, and [`props::Names`], //! where a table of script names plugs in. //! -//! Tier 0 today. `src/parser/proofs.rs` holds Kani harnesses (Tier 1) that are -//! compiled only under `cargo kani`; see the README for the bounds and for -//! what they leave out. +//! Tier 0 today. `src/parser/proofs.rs` and `src/proofs.rs` hold Kani +//! harnesses (Tier 1) that are compiled only under `cargo kani`; see the +//! README for the bounds and for what they leave out. pub mod ast; +pub mod compile; pub mod error; pub mod flags; pub mod parser; +pub mod program; +#[cfg(kani)] +mod proofs; pub mod props; +pub(crate) mod stack; +pub mod tables; +pub mod unicode; +pub mod vm; pub use ast::Pattern; +pub use compile::{CompileError, compile}; pub use error::{Error, ErrorKind, FlagsError}; pub use flags::Flags; pub use parser::{MAX_DEPTH, parse, parse_with}; +pub use program::Program; pub use props::{Names, SyntaxOnly}; +pub use vm::{Limits, Match, MatchError}; diff --git a/crates/clazel-js-regexp/src/program.rs b/crates/clazel-js-regexp/src/program.rs new file mode 100644 index 00000000..50d5f784 --- /dev/null +++ b/crates/clazel-js-regexp/src/program.rs @@ -0,0 +1,260 @@ +//! The compiled form of a pattern: a list of instructions for the backtracking +//! matcher of [`crate::vm`]. +//! +//! The standard (ECMA-262 §22.2.2†) defines matching with closures: each +//! Matcher takes a state and a continuation. An instruction list is the same +//! thing with the continuation made explicit, so the matcher can be a loop +//! over a heap stack instead of recursion. [`crate::compile`] does that +//! translation, one production at a time, and cites the algorithm it takes +//! each instruction from. + +use crate::unicode::Prop; + +/// A matcher for one character (a code unit, or with `u`/`v` a code point). +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) enum OneKind { + /// A character; with `ic`, `c` is already canonicalized and the input's + /// character is too, before the comparison. + Char { + /// The character. + c: u32, + /// `i` is on. + ic: bool, + }, + /// `.`: any character, or any but a line terminator. + Dot { + /// `s` is on. + all: bool, + }, + /// A character class, by index into [`Program::classes`]. + Class(u32), +} + +/// [`OneKind`] and the direction it reads in. +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct One { + pub(crate) kind: OneKind, + /// Reads the character before the position, and moves back (lookbehind). + pub(crate) back: bool, +} + +/// An instruction. `pc` values are indices into [`Program::insts`]; register +/// numbers index [`Program`]'s registers (the captures come first: capture +/// `n` is registers `2n` and `2n + 1`). +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) enum Inst { + /// Match one character and move past it. + One(One), + /// A greedy loop over one character, `min` to `max` times, as one + /// instruction and one stack entry (RepeatMatcher, §22.2.2.3.1†). + Run { + /// The character. + one: One, + /// The least number of repetitions. + min: usize, + /// The most. + max: usize, + }, + /// `^` (§22.2.2.6.1† Assertion, step for `^`). + LineStart { + /// `m` is on. + multiline: bool, + }, + /// `$`. + LineEnd { + /// `m` is on. + multiline: bool, + }, + /// `\b` and `\B`. + WordBoundary { + /// `\B`. + neg: bool, + /// `u` or `v` with `i`: U+017F and U+212A are word characters. + extras: bool, + }, + /// A backreference (BackreferenceMatcher, §22.2.2.7.2†): the first group + /// of the list `Program::backrefs[id]` that has a capture is the one used. + BackRef { + /// Index into the program's list of group lists. + id: u32, + /// `i` is on. + ic: bool, + /// Matches backwards. + back: bool, + }, + /// Try `first`, and on failure `second`. + Split { + /// Tried first. + first: u32, + /// Tried after `first` fails. + second: u32, + }, + /// Go to `target`. + Jmp(u32), + /// A capturing group begins: remember the position in `reg`. + GroupOpen { + /// The register. + reg: u32, + }, + /// A capturing group ends: capture `cap` becomes the text between the + /// remembered position and this one. + GroupClose { + /// The capture's number. + cap: u32, + /// The register `GroupOpen` wrote. + reg: u32, + /// The group was matched backwards, so the end comes first. + back: bool, + }, + /// Undefine captures `first` to `last` (RepeatMatcher step 4). + ResetCaps { + /// The first capture. + first: u32, + /// The last. + last: u32, + }, + /// Set a loop's counter to zero. + CounterInit { + /// The register. + reg: u32, + }, + /// The top of a general loop (RepeatMatcher steps 1, 5, 6 and 7). + LoopHead { + /// The counter's register. + counter: u32, + /// The least number of iterations. + min: usize, + /// The most. + max: usize, + /// No `?` after the quantifier. + greedy: bool, + /// The first instruction of the body. + body: u32, + /// The instruction after the loop. + exit: u32, + }, + /// Remember the position a loop iteration began at. + SavePos { + /// The register. + reg: u32, + }, + /// The end of a loop iteration (RepeatMatcher step 2.b): an iteration + /// beyond the least number that matched nothing fails; else count it. + LoopEnd { + /// The counter's register. + counter: u32, + /// The register `SavePos` wrote. + pos_reg: u32, + /// The least number of iterations. + min: usize, + /// The instruction of the loop's `LoopHead`. + head: u32, + }, + /// The start of a lookaround's body (§22.2.2.3.2† Assertion). + LookStart { + /// `(?!` and `(?, + /// `i` is on: a leaf holds if it holds for some character with the same + /// `Canonicalize` as the input's (CharacterSetMatcher, §22.2.2.7.1†). + pub(crate) ic: bool, + /// The class is `[^..]` without `v` (with `v`, a `Not` op does it). + pub(crate) invert: bool, + /// `\w` includes U+017F and U+212A (`u` or `v`, with `i`). + pub(crate) word_extras: bool, +} + +/// A compiled pattern: see [`crate::compile`] and [`Program::exec`]. +#[derive(Debug, Clone)] +pub struct Program { + pub(crate) insts: Vec, + pub(crate) classes: Vec, + pub(crate) backrefs: Vec>, + pub(crate) regs: usize, + pub(crate) capture_count: u32, + pub(crate) unicode: bool, + pub(crate) group_names: Vec<(Vec, u32)>, +} + +impl Program { + /// The number of capturing groups (not counting the whole match). + #[must_use] + pub fn capture_count(&self) -> u32 { + self.capture_count + } + + /// Every named group, as its name (code points) and its number: the + /// parser's [`crate::ast::Pattern::group_names`]. + #[must_use] + pub fn group_names(&self) -> &[(Vec, u32)] { + &self.group_names + } + + /// Whether the pattern reads code points (`u` or `v`) rather than code + /// units. + #[must_use] + pub fn unicode(&self) -> bool { + self.unicode + } + + /// The group named `name` that took part in `m` (§22.2.2.3.1†'s duplicate + /// named groups: at most one does): its capture, if any. + #[must_use] + pub fn named_capture(&self, m: &crate::vm::Match, name: &[u32]) -> Option<(usize, usize)> { + self.group_names + .iter() + .filter(|(n, _)| n.as_slice() == name) + .find_map(|&(_, i)| m.captures.get(usize::try_from(i).ok()?).copied().flatten()) + } +} diff --git a/crates/clazel-js-regexp/src/proofs.rs b/crates/clazel-js-regexp/src/proofs.rs new file mode 100644 index 00000000..ca0e60e2 --- /dev/null +++ b/crates/clazel-js-regexp/src/proofs.rs @@ -0,0 +1,183 @@ +//! Kani harnesses (Tier 1) for the matcher's small pieces. Compiled only under +//! `cargo kani`. +//! +//! - **The case tables' lookups** ([`crate::unicode`]): for every input, +//! `Canonicalize` stays in range and never turns a non-ASCII unit into an +//! ASCII one (§22.2.2.7.3†). That the inverse table agrees with the forward +//! one (`equivalents` of a character's canonical form contains it) is not +//! here: with the two bisections and a growing `Vec` it ran past ten CPU +//! minutes in CBMC. `tests/tables.rs` checks it for every code point. +//! - **The backtrack stack** ([`crate::stack::BtStack`]): a push never grows it +//! past its bound, says "full" exactly at the bound, and a pop returns what +//! was pushed last; `commit_look` keeps the undo entries and drops the rest. +//! - **Reading a character** ([`crate::vm::read`]): at any position of any +//! input of up to 3 units, forward or backward, in either mode, the new +//! position is inside the input, moves by one or two units, and the +//! character is a code unit or a valid code point. +//! +//! What is not here: the matcher loop itself and the compiler. Both build +//! `Vec`s in loops, and the parser's README records that CBMC does not finish +//! on those (`src/parser/proofs.rs`). They are tested instead, by the +//! differential against a reference matcher (`tests/differential.rs`). + +use crate::stack::{BtStack, Entry}; +use crate::unicode::{canonicalize_unit, simple_fold}; +use crate::vm::read; + +/// The non-unicode `Canonicalize` of any code unit is a code unit, and a +/// non-ASCII unit never becomes ASCII. +#[kani::proof] +#[kani::unwind(14)] +fn canonicalize_unit_any() { + let c: u16 = kani::any(); + let r = canonicalize_unit(u32::from(c)); + assert!(r <= 0xFFFF); + if c >= 128 { + assert!(r >= 128); + } +} + +/// Simple case folding of any code point is a code point. +#[kani::proof] +#[kani::unwind(14)] +fn simple_fold_any() { + let c: u32 = kani::any(); + kani::assume(c <= 0x10FFFF); + assert!(simple_fold(c) <= 0x10FFFF); +} + +fn any_entry() -> Entry { + match kani::any::() % 4 { + 0 => Entry::Branch { + pc: kani::any(), + pos: kani::any(), + }, + 1 => Entry::Restore { + reg: kani::any(), + old: kani::any(), + }, + 2 => Entry::Run { + pc: kani::any(), + back: kani::any(), + cur: kani::any(), + limit: kani::any(), + }, + _ => Entry::LookMark { + neg: kani::any(), + pc: kani::any(), + pos: kani::any(), + }, + } +} + +/// Pushing never takes the stack past its bound, and refuses exactly when it +/// is full, whatever the bound and the entries. +#[kani::proof] +#[kani::unwind(8)] +fn stack_push_respects_the_bound() { + let max: usize = kani::any(); + kani::assume(max <= 4); + let mut s = BtStack::new(max); + for i in 0..6usize { + let before = s.len(); + let r = s.push(any_entry()); + assert!(s.len() <= max); + if before < max { + assert!(r.is_ok() && s.len() == before + 1); + } else { + assert!(r.is_err() && s.len() == before); + } + let _ = i; + } +} + +/// A pop returns the entry pushed last, and an empty stack returns nothing. +#[kani::proof] +#[kani::unwind(4)] +fn stack_pop_returns_the_last_push() { + let mut s = BtStack::new(2); + assert!(s.pop().is_none()); + let a = any_entry(); + let b = any_entry(); + assert!(s.push(a).is_ok()); + assert!(s.push(b).is_ok()); + assert!(s.pop() == Some(b)); + assert!(s.pop() == Some(a)); + assert!(s.pop().is_none()); +} + +/// A positive lookaround's commit removes the mark and everything above it +/// but the undo entries, and gives back the position the mark holds. +#[kani::proof] +#[kani::unwind(8)] +fn stack_commit_look_keeps_only_the_undos() { + let mut s = BtStack::new(4); + let below = any_entry(); + kani::assume(!matches!(below, Entry::LookMark { .. })); + let mark_pos: usize = kani::any(); + assert!(s.push(below).is_ok()); + assert!( + s.push(Entry::LookMark { + neg: false, + pc: 0, + pos: mark_pos + }) + .is_ok() + ); + let a = any_entry(); + kani::assume(!matches!(a, Entry::LookMark { .. })); + let b = any_entry(); + kani::assume(!matches!(b, Entry::LookMark { .. })); + assert!(s.push(a).is_ok()); + assert!(s.push(b).is_ok()); + let Some((pos, _)) = s.commit_look() else { + panic!("a mark is on the stack"); + }; + assert!(pos == mark_pos); + // What remains above `below` is the undo entries among `a`, `b`, in order. + let mut kept = Vec::new(); + while let Some(e) = s.pop() { + kept.push(e); + } + let undos = [a, b] + .iter() + .filter(|e| matches!(e, Entry::Restore { .. })) + .count(); + assert!(kept.len() == undos + 1); + assert!(kept.last() == Some(&below)); +} + +/// Reading a character at any position of any input of up to 3 units. +#[kani::proof] +#[kani::unwind(6)] +fn read_any_3() { + let units: [u16; 3] = kani::any(); + let len: usize = kani::any(); + kani::assume(len <= 3); + let input = units.get(..len).unwrap_or_default(); + let pos: usize = kani::any(); + kani::assume(pos <= len); + let unicode: bool = kani::any(); + let back: bool = kani::any(); + match read(input, unicode, pos, back) { + Some((ch, np)) => { + assert!(np <= len); + if back { + assert!(np < pos && pos - np <= 2); + } else { + assert!(np > pos && np - pos <= 2); + } + assert!(ch <= 0x10FFFF); + if !unicode { + assert!(ch <= 0xFFFF && np.abs_diff(pos) == 1); + } + } + None => { + if back { + assert!(pos == 0); + } else { + assert!(pos == len); + } + } + } +} diff --git a/crates/clazel-js-regexp/src/stack.rs b/crates/clazel-js-regexp/src/stack.rs new file mode 100644 index 00000000..e65c3b08 --- /dev/null +++ b/crates/clazel-js-regexp/src/stack.rs @@ -0,0 +1,126 @@ +//! The backtrack stack: a `Vec` that refuses to grow past a stated number of +//! entries. +//! +//! The matcher (ECMA-262 §22.2.2†, continuation-passing) is run as a loop over +//! this stack, never by recursion. Every choice point and every change to a +//! register that a failure must undo is an [`Entry`]. The bound is the whole +//! of the matcher's heap use that depends on the input; exceeding it is +//! [`crate::MatchError::StackOverflow`], which the engine turns into a +//! `RangeError` (a listed deviation: phase-7.md item 7.10). + +/// One entry of the backtrack stack. Three of the four kinds are 16 bytes; +/// [`Entry::Run`] makes the type 24. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum Entry { + /// A choice: on failure, resume at `pc` with the input position `pos`. + Branch { + /// The instruction to resume at. + pc: u32, + /// The input position. + pos: usize, + }, + /// An undo: on failure, put `old` back in register `reg`. + Restore { + /// The register. + reg: u32, + /// Its earlier value. + old: usize, + }, + /// The choices of a greedy loop over one character: on failure, resume at + /// `pc` one character nearer to `limit` than `cur` (forward matching + /// moves down to `limit`, backward matching up), and keep this entry until + /// `limit` is reached. + Run { + /// The instruction to resume at. + pc: u32, + /// Whether the loop matches backwards (in a lookbehind). + back: bool, + /// The end of the longest run, or of the one tried last. + cur: usize, + /// The end of the shortest run. + limit: usize, + }, + /// The start of a lookaround's body. On failure it ends a negative + /// lookaround as a success (resume at `pc`, position `pos`), and a + /// positive one as a failure. + LookMark { + /// A negative lookaround. + neg: bool, + /// Where the instruction after the lookaround is. + pc: u32, + /// The input position the lookaround started at. + pos: usize, + }, +} + +/// The stack was full. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) struct Full; + +/// A stack of at most `max` entries. +#[derive(Debug)] +pub(crate) struct BtStack { + items: Vec, + max: usize, +} + +impl BtStack { + /// An empty stack that holds at most `max` entries. + pub(crate) fn new(max: usize) -> BtStack { + BtStack { + items: Vec::new(), + max, + } + } + + /// The number of entries (the harnesses' view of the bound). + #[cfg(kani)] + pub(crate) fn len(&self) -> usize { + self.items.len() + } + + /// Pushes `e`, or says the stack is full (and leaves it as it was). + pub(crate) fn push(&mut self, e: Entry) -> Result<(), Full> { + if self.items.len() >= self.max { + return Err(Full); + } + self.items.push(e); + Ok(()) + } + + /// Pops the top entry. + pub(crate) fn pop(&mut self) -> Option { + self.items.pop() + } + + /// Removes every entry. + pub(crate) fn clear(&mut self) { + self.items.clear(); + } + + /// What a positive lookaround does when its body has matched: removes the + /// topmost [`Entry::LookMark`] and every choice above it (the body is + /// atomic), keeping the [`Entry::Restore`]s above it, so that backtracking + /// past the lookaround still undoes the captures its body set. Returns the + /// position the lookaround started at and the number of entries above the + /// mark (the work done). + pub(crate) fn commit_look(&mut self) -> Option<(usize, usize)> { + let m = self + .items + .iter() + .rposition(|e| matches!(e, Entry::LookMark { .. }))?; + let Some(&Entry::LookMark { pos, .. }) = self.items.get(m) else { + return None; + }; + let len = self.items.len(); + let mut w = m; + for r in m.saturating_add(1)..len { + if matches!(self.items.get(r), Some(Entry::Restore { .. })) { + self.items.swap(w, r); + w = w.saturating_add(1); + } + } + self.items.truncate(w); + Some((pos, len.saturating_sub(m))) + } +} diff --git a/crates/clazel-js-regexp/src/tables.rs b/crates/clazel-js-regexp/src/tables.rs new file mode 100644 index 00000000..5ad92bfd --- /dev/null +++ b/crates/clazel-js-regexp/src/tables.rs @@ -0,0 +1,22014 @@ +//! Unicode 18.0.0 tables for case folding, `\p{..}` and `\w`: generated. +//! +//! @generated by `tests/tables.rs` (`CLAZEL_WRITE_TABLES=1 cargo test -p +//! clazel-js-regexp --test tables`) from `tests/data/ucd-regexp/` (source, +//! commit and license: `SOURCE.md` there). Do not edit by hand: the test +//! `tables_are_current` fails if this file differs from what the generator +//! writes. What each table holds and which file it comes from is in the +//! header of that test file. + +/// Simple Case Folding (CaseFolding.txt, statuses C and S): code point, folded, sorted by code point. +pub static SIMPLE_FOLD: &[(u32, u32)] = &[ + (0x41, 0x61), + (0x42, 0x62), + (0x43, 0x63), + (0x44, 0x64), + (0x45, 0x65), + (0x46, 0x66), + (0x47, 0x67), + (0x48, 0x68), + (0x49, 0x69), + (0x4A, 0x6A), + (0x4B, 0x6B), + (0x4C, 0x6C), + (0x4D, 0x6D), + (0x4E, 0x6E), + (0x4F, 0x6F), + (0x50, 0x70), + (0x51, 0x71), + (0x52, 0x72), + (0x53, 0x73), + (0x54, 0x74), + (0x55, 0x75), + (0x56, 0x76), + (0x57, 0x77), + (0x58, 0x78), + (0x59, 0x79), + (0x5A, 0x7A), + (0xB5, 0x3BC), + (0xC0, 0xE0), + (0xC1, 0xE1), + (0xC2, 0xE2), + (0xC3, 0xE3), + (0xC4, 0xE4), + (0xC5, 0xE5), + (0xC6, 0xE6), + (0xC7, 0xE7), + (0xC8, 0xE8), + (0xC9, 0xE9), + (0xCA, 0xEA), + (0xCB, 0xEB), + (0xCC, 0xEC), + (0xCD, 0xED), + (0xCE, 0xEE), + (0xCF, 0xEF), + (0xD0, 0xF0), + (0xD1, 0xF1), + (0xD2, 0xF2), + (0xD3, 0xF3), + (0xD4, 0xF4), + (0xD5, 0xF5), + (0xD6, 0xF6), + (0xD8, 0xF8), + (0xD9, 0xF9), + (0xDA, 0xFA), + (0xDB, 0xFB), + (0xDC, 0xFC), + (0xDD, 0xFD), + (0xDE, 0xFE), + (0x100, 0x101), + (0x102, 0x103), + (0x104, 0x105), + (0x106, 0x107), + (0x108, 0x109), + (0x10A, 0x10B), + (0x10C, 0x10D), + (0x10E, 0x10F), + (0x110, 0x111), + (0x112, 0x113), + (0x114, 0x115), + (0x116, 0x117), + (0x118, 0x119), + (0x11A, 0x11B), + (0x11C, 0x11D), + (0x11E, 0x11F), + (0x120, 0x121), + (0x122, 0x123), + (0x124, 0x125), + (0x126, 0x127), + (0x128, 0x129), + (0x12A, 0x12B), + (0x12C, 0x12D), + (0x12E, 0x12F), + (0x132, 0x133), + (0x134, 0x135), + (0x136, 0x137), + (0x139, 0x13A), + (0x13B, 0x13C), + (0x13D, 0x13E), + (0x13F, 0x140), + (0x141, 0x142), + (0x143, 0x144), + (0x145, 0x146), + (0x147, 0x148), + (0x14A, 0x14B), + (0x14C, 0x14D), + (0x14E, 0x14F), + (0x150, 0x151), + (0x152, 0x153), + (0x154, 0x155), + (0x156, 0x157), + (0x158, 0x159), + (0x15A, 0x15B), + (0x15C, 0x15D), + (0x15E, 0x15F), + (0x160, 0x161), + (0x162, 0x163), + (0x164, 0x165), + (0x166, 0x167), + (0x168, 0x169), + (0x16A, 0x16B), + (0x16C, 0x16D), + (0x16E, 0x16F), + (0x170, 0x171), + (0x172, 0x173), + (0x174, 0x175), + (0x176, 0x177), + (0x178, 0xFF), + (0x179, 0x17A), + (0x17B, 0x17C), + (0x17D, 0x17E), + (0x17F, 0x73), + (0x181, 0x253), + (0x182, 0x183), + (0x184, 0x185), + (0x186, 0x254), + (0x187, 0x188), + (0x189, 0x256), + (0x18A, 0x257), + (0x18B, 0x18C), + (0x18E, 0x1DD), + (0x18F, 0x259), + (0x190, 0x25B), + (0x191, 0x192), + (0x193, 0x260), + (0x194, 0x263), + (0x196, 0x269), + (0x197, 0x268), + (0x198, 0x199), + (0x19C, 0x26F), + (0x19D, 0x272), + (0x19F, 0x275), + (0x1A0, 0x1A1), + (0x1A2, 0x1A3), + (0x1A4, 0x1A5), + (0x1A6, 0x280), + (0x1A7, 0x1A8), + (0x1A9, 0x283), + (0x1AC, 0x1AD), + (0x1AE, 0x288), + (0x1AF, 0x1B0), + (0x1B1, 0x28A), + (0x1B2, 0x28B), + (0x1B3, 0x1B4), + (0x1B5, 0x1B6), + (0x1B7, 0x292), + (0x1B8, 0x1B9), + (0x1BC, 0x1BD), + (0x1C4, 0x1C6), + (0x1C5, 0x1C6), + (0x1C7, 0x1C9), + (0x1C8, 0x1C9), + (0x1CA, 0x1CC), + (0x1CB, 0x1CC), + (0x1CD, 0x1CE), + (0x1CF, 0x1D0), + (0x1D1, 0x1D2), + (0x1D3, 0x1D4), + (0x1D5, 0x1D6), + (0x1D7, 0x1D8), + (0x1D9, 0x1DA), + (0x1DB, 0x1DC), + (0x1DE, 0x1DF), + (0x1E0, 0x1E1), + (0x1E2, 0x1E3), + (0x1E4, 0x1E5), + (0x1E6, 0x1E7), + (0x1E8, 0x1E9), + (0x1EA, 0x1EB), + (0x1EC, 0x1ED), + (0x1EE, 0x1EF), + (0x1F1, 0x1F3), + (0x1F2, 0x1F3), + (0x1F4, 0x1F5), + (0x1F6, 0x195), + (0x1F7, 0x1BF), + (0x1F8, 0x1F9), + (0x1FA, 0x1FB), + (0x1FC, 0x1FD), + (0x1FE, 0x1FF), + (0x200, 0x201), + (0x202, 0x203), + (0x204, 0x205), + (0x206, 0x207), + (0x208, 0x209), + (0x20A, 0x20B), + (0x20C, 0x20D), + (0x20E, 0x20F), + (0x210, 0x211), + (0x212, 0x213), + (0x214, 0x215), + (0x216, 0x217), + (0x218, 0x219), + (0x21A, 0x21B), + (0x21C, 0x21D), + (0x21E, 0x21F), + (0x220, 0x19E), + (0x222, 0x223), + (0x224, 0x225), + (0x226, 0x227), + (0x228, 0x229), + (0x22A, 0x22B), + (0x22C, 0x22D), + (0x22E, 0x22F), + (0x230, 0x231), + (0x232, 0x233), + (0x23A, 0x2C65), + (0x23B, 0x23C), + (0x23D, 0x19A), + (0x23E, 0x2C66), + (0x241, 0x242), + (0x243, 0x180), + (0x244, 0x289), + (0x245, 0x28C), + (0x246, 0x247), + (0x248, 0x249), + (0x24A, 0x24B), + (0x24C, 0x24D), + (0x24E, 0x24F), + (0x345, 0x3B9), + (0x370, 0x371), + (0x372, 0x373), + (0x376, 0x377), + (0x37F, 0x3F3), + (0x386, 0x3AC), + (0x388, 0x3AD), + (0x389, 0x3AE), + (0x38A, 0x3AF), + (0x38C, 0x3CC), + (0x38E, 0x3CD), + (0x38F, 0x3CE), + (0x391, 0x3B1), + (0x392, 0x3B2), + (0x393, 0x3B3), + (0x394, 0x3B4), + (0x395, 0x3B5), + (0x396, 0x3B6), + (0x397, 0x3B7), + (0x398, 0x3B8), + (0x399, 0x3B9), + (0x39A, 0x3BA), + (0x39B, 0x3BB), + (0x39C, 0x3BC), + (0x39D, 0x3BD), + (0x39E, 0x3BE), + (0x39F, 0x3BF), + (0x3A0, 0x3C0), + (0x3A1, 0x3C1), + (0x3A3, 0x3C3), + (0x3A4, 0x3C4), + (0x3A5, 0x3C5), + (0x3A6, 0x3C6), + (0x3A7, 0x3C7), + (0x3A8, 0x3C8), + (0x3A9, 0x3C9), + (0x3AA, 0x3CA), + (0x3AB, 0x3CB), + (0x3C2, 0x3C3), + (0x3CF, 0x3D7), + (0x3D0, 0x3B2), + (0x3D1, 0x3B8), + (0x3D5, 0x3C6), + (0x3D6, 0x3C0), + (0x3D8, 0x3D9), + (0x3DA, 0x3DB), + (0x3DC, 0x3DD), + (0x3DE, 0x3DF), + (0x3E0, 0x3E1), + (0x3E2, 0x3E3), + (0x3E4, 0x3E5), + (0x3E6, 0x3E7), + (0x3E8, 0x3E9), + (0x3EA, 0x3EB), + (0x3EC, 0x3ED), + (0x3EE, 0x3EF), + (0x3F0, 0x3BA), + (0x3F1, 0x3C1), + (0x3F4, 0x3B8), + (0x3F5, 0x3B5), + (0x3F7, 0x3F8), + (0x3F9, 0x3F2), + (0x3FA, 0x3FB), + (0x3FD, 0x37B), + (0x3FE, 0x37C), + (0x3FF, 0x37D), + (0x400, 0x450), + (0x401, 0x451), + (0x402, 0x452), + (0x403, 0x453), + (0x404, 0x454), + (0x405, 0x455), + (0x406, 0x456), + (0x407, 0x457), + (0x408, 0x458), + (0x409, 0x459), + (0x40A, 0x45A), + (0x40B, 0x45B), + (0x40C, 0x45C), + (0x40D, 0x45D), + (0x40E, 0x45E), + (0x40F, 0x45F), + (0x410, 0x430), + (0x411, 0x431), + (0x412, 0x432), + (0x413, 0x433), + (0x414, 0x434), + (0x415, 0x435), + (0x416, 0x436), + (0x417, 0x437), + (0x418, 0x438), + (0x419, 0x439), + (0x41A, 0x43A), + (0x41B, 0x43B), + (0x41C, 0x43C), + (0x41D, 0x43D), + (0x41E, 0x43E), + (0x41F, 0x43F), + (0x420, 0x440), + (0x421, 0x441), + (0x422, 0x442), + (0x423, 0x443), + (0x424, 0x444), + (0x425, 0x445), + (0x426, 0x446), + (0x427, 0x447), + (0x428, 0x448), + (0x429, 0x449), + (0x42A, 0x44A), + (0x42B, 0x44B), + (0x42C, 0x44C), + (0x42D, 0x44D), + (0x42E, 0x44E), + (0x42F, 0x44F), + (0x460, 0x461), + (0x462, 0x463), + (0x464, 0x465), + (0x466, 0x467), + (0x468, 0x469), + (0x46A, 0x46B), + (0x46C, 0x46D), + (0x46E, 0x46F), + (0x470, 0x471), + (0x472, 0x473), + (0x474, 0x475), + (0x476, 0x477), + (0x478, 0x479), + (0x47A, 0x47B), + (0x47C, 0x47D), + (0x47E, 0x47F), + (0x480, 0x481), + (0x48A, 0x48B), + (0x48C, 0x48D), + (0x48E, 0x48F), + (0x490, 0x491), + (0x492, 0x493), + (0x494, 0x495), + (0x496, 0x497), + (0x498, 0x499), + (0x49A, 0x49B), + (0x49C, 0x49D), + (0x49E, 0x49F), + (0x4A0, 0x4A1), + (0x4A2, 0x4A3), + (0x4A4, 0x4A5), + (0x4A6, 0x4A7), + (0x4A8, 0x4A9), + (0x4AA, 0x4AB), + (0x4AC, 0x4AD), + (0x4AE, 0x4AF), + (0x4B0, 0x4B1), + (0x4B2, 0x4B3), + (0x4B4, 0x4B5), + (0x4B6, 0x4B7), + (0x4B8, 0x4B9), + (0x4BA, 0x4BB), + (0x4BC, 0x4BD), + (0x4BE, 0x4BF), + (0x4C0, 0x4CF), + (0x4C1, 0x4C2), + (0x4C3, 0x4C4), + (0x4C5, 0x4C6), + (0x4C7, 0x4C8), + (0x4C9, 0x4CA), + (0x4CB, 0x4CC), + (0x4CD, 0x4CE), + (0x4D0, 0x4D1), + (0x4D2, 0x4D3), + (0x4D4, 0x4D5), + (0x4D6, 0x4D7), + (0x4D8, 0x4D9), + (0x4DA, 0x4DB), + (0x4DC, 0x4DD), + (0x4DE, 0x4DF), + (0x4E0, 0x4E1), + (0x4E2, 0x4E3), + (0x4E4, 0x4E5), + (0x4E6, 0x4E7), + (0x4E8, 0x4E9), + (0x4EA, 0x4EB), + (0x4EC, 0x4ED), + (0x4EE, 0x4EF), + (0x4F0, 0x4F1), + (0x4F2, 0x4F3), + (0x4F4, 0x4F5), + (0x4F6, 0x4F7), + (0x4F8, 0x4F9), + (0x4FA, 0x4FB), + (0x4FC, 0x4FD), + (0x4FE, 0x4FF), + (0x500, 0x501), + (0x502, 0x503), + (0x504, 0x505), + (0x506, 0x507), + (0x508, 0x509), + (0x50A, 0x50B), + (0x50C, 0x50D), + (0x50E, 0x50F), + (0x510, 0x511), + (0x512, 0x513), + (0x514, 0x515), + (0x516, 0x517), + (0x518, 0x519), + (0x51A, 0x51B), + (0x51C, 0x51D), + (0x51E, 0x51F), + (0x520, 0x521), + (0x522, 0x523), + (0x524, 0x525), + (0x526, 0x527), + (0x528, 0x529), + (0x52A, 0x52B), + (0x52C, 0x52D), + (0x52E, 0x52F), + (0x531, 0x561), + (0x532, 0x562), + (0x533, 0x563), + (0x534, 0x564), + (0x535, 0x565), + (0x536, 0x566), + (0x537, 0x567), + (0x538, 0x568), + (0x539, 0x569), + (0x53A, 0x56A), + (0x53B, 0x56B), + (0x53C, 0x56C), + (0x53D, 0x56D), + (0x53E, 0x56E), + (0x53F, 0x56F), + (0x540, 0x570), + (0x541, 0x571), + (0x542, 0x572), + (0x543, 0x573), + (0x544, 0x574), + (0x545, 0x575), + (0x546, 0x576), + (0x547, 0x577), + (0x548, 0x578), + (0x549, 0x579), + (0x54A, 0x57A), + (0x54B, 0x57B), + (0x54C, 0x57C), + (0x54D, 0x57D), + (0x54E, 0x57E), + (0x54F, 0x57F), + (0x550, 0x580), + (0x551, 0x581), + (0x552, 0x582), + (0x553, 0x583), + (0x554, 0x584), + (0x555, 0x585), + (0x556, 0x586), + (0x10A0, 0x2D00), + (0x10A1, 0x2D01), + (0x10A2, 0x2D02), + (0x10A3, 0x2D03), + (0x10A4, 0x2D04), + (0x10A5, 0x2D05), + (0x10A6, 0x2D06), + (0x10A7, 0x2D07), + (0x10A8, 0x2D08), + (0x10A9, 0x2D09), + (0x10AA, 0x2D0A), + (0x10AB, 0x2D0B), + (0x10AC, 0x2D0C), + (0x10AD, 0x2D0D), + (0x10AE, 0x2D0E), + (0x10AF, 0x2D0F), + (0x10B0, 0x2D10), + (0x10B1, 0x2D11), + (0x10B2, 0x2D12), + (0x10B3, 0x2D13), + (0x10B4, 0x2D14), + (0x10B5, 0x2D15), + (0x10B6, 0x2D16), + (0x10B7, 0x2D17), + (0x10B8, 0x2D18), + (0x10B9, 0x2D19), + (0x10BA, 0x2D1A), + (0x10BB, 0x2D1B), + (0x10BC, 0x2D1C), + (0x10BD, 0x2D1D), + (0x10BE, 0x2D1E), + (0x10BF, 0x2D1F), + (0x10C0, 0x2D20), + (0x10C1, 0x2D21), + (0x10C2, 0x2D22), + (0x10C3, 0x2D23), + (0x10C4, 0x2D24), + (0x10C5, 0x2D25), + (0x10C7, 0x2D27), + (0x10CD, 0x2D2D), + (0x13F8, 0x13F0), + (0x13F9, 0x13F1), + (0x13FA, 0x13F2), + (0x13FB, 0x13F3), + (0x13FC, 0x13F4), + (0x13FD, 0x13F5), + (0x1C80, 0x432), + (0x1C81, 0x434), + (0x1C82, 0x43E), + (0x1C83, 0x441), + (0x1C84, 0x442), + (0x1C85, 0x442), + (0x1C86, 0x44A), + (0x1C87, 0x463), + (0x1C88, 0xA64B), + (0x1C89, 0x1C8A), + (0x1C90, 0x10D0), + (0x1C91, 0x10D1), + (0x1C92, 0x10D2), + (0x1C93, 0x10D3), + (0x1C94, 0x10D4), + (0x1C95, 0x10D5), + (0x1C96, 0x10D6), + (0x1C97, 0x10D7), + (0x1C98, 0x10D8), + (0x1C99, 0x10D9), + (0x1C9A, 0x10DA), + (0x1C9B, 0x10DB), + (0x1C9C, 0x10DC), + (0x1C9D, 0x10DD), + (0x1C9E, 0x10DE), + (0x1C9F, 0x10DF), + (0x1CA0, 0x10E0), + (0x1CA1, 0x10E1), + (0x1CA2, 0x10E2), + (0x1CA3, 0x10E3), + (0x1CA4, 0x10E4), + (0x1CA5, 0x10E5), + (0x1CA6, 0x10E6), + (0x1CA7, 0x10E7), + (0x1CA8, 0x10E8), + (0x1CA9, 0x10E9), + (0x1CAA, 0x10EA), + (0x1CAB, 0x10EB), + (0x1CAC, 0x10EC), + (0x1CAD, 0x10ED), + (0x1CAE, 0x10EE), + (0x1CAF, 0x10EF), + (0x1CB0, 0x10F0), + (0x1CB1, 0x10F1), + (0x1CB2, 0x10F2), + (0x1CB3, 0x10F3), + (0x1CB4, 0x10F4), + (0x1CB5, 0x10F5), + (0x1CB6, 0x10F6), + (0x1CB7, 0x10F7), + (0x1CB8, 0x10F8), + (0x1CB9, 0x10F9), + (0x1CBA, 0x10FA), + (0x1CBD, 0x10FD), + (0x1CBE, 0x10FE), + (0x1CBF, 0x10FF), + (0x1E00, 0x1E01), + (0x1E02, 0x1E03), + (0x1E04, 0x1E05), + (0x1E06, 0x1E07), + (0x1E08, 0x1E09), + (0x1E0A, 0x1E0B), + (0x1E0C, 0x1E0D), + (0x1E0E, 0x1E0F), + (0x1E10, 0x1E11), + (0x1E12, 0x1E13), + (0x1E14, 0x1E15), + (0x1E16, 0x1E17), + (0x1E18, 0x1E19), + (0x1E1A, 0x1E1B), + (0x1E1C, 0x1E1D), + (0x1E1E, 0x1E1F), + (0x1E20, 0x1E21), + (0x1E22, 0x1E23), + (0x1E24, 0x1E25), + (0x1E26, 0x1E27), + (0x1E28, 0x1E29), + (0x1E2A, 0x1E2B), + (0x1E2C, 0x1E2D), + (0x1E2E, 0x1E2F), + (0x1E30, 0x1E31), + (0x1E32, 0x1E33), + (0x1E34, 0x1E35), + (0x1E36, 0x1E37), + (0x1E38, 0x1E39), + (0x1E3A, 0x1E3B), + (0x1E3C, 0x1E3D), + (0x1E3E, 0x1E3F), + (0x1E40, 0x1E41), + (0x1E42, 0x1E43), + (0x1E44, 0x1E45), + (0x1E46, 0x1E47), + (0x1E48, 0x1E49), + (0x1E4A, 0x1E4B), + (0x1E4C, 0x1E4D), + (0x1E4E, 0x1E4F), + (0x1E50, 0x1E51), + (0x1E52, 0x1E53), + (0x1E54, 0x1E55), + (0x1E56, 0x1E57), + (0x1E58, 0x1E59), + (0x1E5A, 0x1E5B), + (0x1E5C, 0x1E5D), + (0x1E5E, 0x1E5F), + (0x1E60, 0x1E61), + (0x1E62, 0x1E63), + (0x1E64, 0x1E65), + (0x1E66, 0x1E67), + (0x1E68, 0x1E69), + (0x1E6A, 0x1E6B), + (0x1E6C, 0x1E6D), + (0x1E6E, 0x1E6F), + (0x1E70, 0x1E71), + (0x1E72, 0x1E73), + (0x1E74, 0x1E75), + (0x1E76, 0x1E77), + (0x1E78, 0x1E79), + (0x1E7A, 0x1E7B), + (0x1E7C, 0x1E7D), + (0x1E7E, 0x1E7F), + (0x1E80, 0x1E81), + (0x1E82, 0x1E83), + (0x1E84, 0x1E85), + (0x1E86, 0x1E87), + (0x1E88, 0x1E89), + (0x1E8A, 0x1E8B), + (0x1E8C, 0x1E8D), + (0x1E8E, 0x1E8F), + (0x1E90, 0x1E91), + (0x1E92, 0x1E93), + (0x1E94, 0x1E95), + (0x1E9B, 0x1E61), + (0x1E9E, 0xDF), + (0x1EA0, 0x1EA1), + (0x1EA2, 0x1EA3), + (0x1EA4, 0x1EA5), + (0x1EA6, 0x1EA7), + (0x1EA8, 0x1EA9), + (0x1EAA, 0x1EAB), + (0x1EAC, 0x1EAD), + (0x1EAE, 0x1EAF), + (0x1EB0, 0x1EB1), + (0x1EB2, 0x1EB3), + (0x1EB4, 0x1EB5), + (0x1EB6, 0x1EB7), + (0x1EB8, 0x1EB9), + (0x1EBA, 0x1EBB), + (0x1EBC, 0x1EBD), + (0x1EBE, 0x1EBF), + (0x1EC0, 0x1EC1), + (0x1EC2, 0x1EC3), + (0x1EC4, 0x1EC5), + (0x1EC6, 0x1EC7), + (0x1EC8, 0x1EC9), + (0x1ECA, 0x1ECB), + (0x1ECC, 0x1ECD), + (0x1ECE, 0x1ECF), + (0x1ED0, 0x1ED1), + (0x1ED2, 0x1ED3), + (0x1ED4, 0x1ED5), + (0x1ED6, 0x1ED7), + (0x1ED8, 0x1ED9), + (0x1EDA, 0x1EDB), + (0x1EDC, 0x1EDD), + (0x1EDE, 0x1EDF), + (0x1EE0, 0x1EE1), + (0x1EE2, 0x1EE3), + (0x1EE4, 0x1EE5), + (0x1EE6, 0x1EE7), + (0x1EE8, 0x1EE9), + (0x1EEA, 0x1EEB), + (0x1EEC, 0x1EED), + (0x1EEE, 0x1EEF), + (0x1EF0, 0x1EF1), + (0x1EF2, 0x1EF3), + (0x1EF4, 0x1EF5), + (0x1EF6, 0x1EF7), + (0x1EF8, 0x1EF9), + (0x1EFA, 0x1EFB), + (0x1EFC, 0x1EFD), + (0x1EFE, 0x1EFF), + (0x1F08, 0x1F00), + (0x1F09, 0x1F01), + (0x1F0A, 0x1F02), + (0x1F0B, 0x1F03), + (0x1F0C, 0x1F04), + (0x1F0D, 0x1F05), + (0x1F0E, 0x1F06), + (0x1F0F, 0x1F07), + (0x1F18, 0x1F10), + (0x1F19, 0x1F11), + (0x1F1A, 0x1F12), + (0x1F1B, 0x1F13), + (0x1F1C, 0x1F14), + (0x1F1D, 0x1F15), + (0x1F28, 0x1F20), + (0x1F29, 0x1F21), + (0x1F2A, 0x1F22), + (0x1F2B, 0x1F23), + (0x1F2C, 0x1F24), + (0x1F2D, 0x1F25), + (0x1F2E, 0x1F26), + (0x1F2F, 0x1F27), + (0x1F38, 0x1F30), + (0x1F39, 0x1F31), + (0x1F3A, 0x1F32), + (0x1F3B, 0x1F33), + (0x1F3C, 0x1F34), + (0x1F3D, 0x1F35), + (0x1F3E, 0x1F36), + (0x1F3F, 0x1F37), + (0x1F48, 0x1F40), + (0x1F49, 0x1F41), + (0x1F4A, 0x1F42), + (0x1F4B, 0x1F43), + (0x1F4C, 0x1F44), + (0x1F4D, 0x1F45), + (0x1F59, 0x1F51), + (0x1F5B, 0x1F53), + (0x1F5D, 0x1F55), + (0x1F5F, 0x1F57), + (0x1F68, 0x1F60), + (0x1F69, 0x1F61), + (0x1F6A, 0x1F62), + (0x1F6B, 0x1F63), + (0x1F6C, 0x1F64), + (0x1F6D, 0x1F65), + (0x1F6E, 0x1F66), + (0x1F6F, 0x1F67), + (0x1F88, 0x1F80), + (0x1F89, 0x1F81), + (0x1F8A, 0x1F82), + (0x1F8B, 0x1F83), + (0x1F8C, 0x1F84), + (0x1F8D, 0x1F85), + (0x1F8E, 0x1F86), + (0x1F8F, 0x1F87), + (0x1F98, 0x1F90), + (0x1F99, 0x1F91), + (0x1F9A, 0x1F92), + (0x1F9B, 0x1F93), + (0x1F9C, 0x1F94), + (0x1F9D, 0x1F95), + (0x1F9E, 0x1F96), + (0x1F9F, 0x1F97), + (0x1FA8, 0x1FA0), + (0x1FA9, 0x1FA1), + (0x1FAA, 0x1FA2), + (0x1FAB, 0x1FA3), + (0x1FAC, 0x1FA4), + (0x1FAD, 0x1FA5), + (0x1FAE, 0x1FA6), + (0x1FAF, 0x1FA7), + (0x1FB8, 0x1FB0), + (0x1FB9, 0x1FB1), + (0x1FBA, 0x1F70), + (0x1FBB, 0x1F71), + (0x1FBC, 0x1FB3), + (0x1FBE, 0x3B9), + (0x1FC8, 0x1F72), + (0x1FC9, 0x1F73), + (0x1FCA, 0x1F74), + (0x1FCB, 0x1F75), + (0x1FCC, 0x1FC3), + (0x1FD3, 0x390), + (0x1FD8, 0x1FD0), + (0x1FD9, 0x1FD1), + (0x1FDA, 0x1F76), + (0x1FDB, 0x1F77), + (0x1FE3, 0x3B0), + (0x1FE8, 0x1FE0), + (0x1FE9, 0x1FE1), + (0x1FEA, 0x1F7A), + (0x1FEB, 0x1F7B), + (0x1FEC, 0x1FE5), + (0x1FF8, 0x1F78), + (0x1FF9, 0x1F79), + (0x1FFA, 0x1F7C), + (0x1FFB, 0x1F7D), + (0x1FFC, 0x1FF3), + (0x2126, 0x3C9), + (0x212A, 0x6B), + (0x212B, 0xE5), + (0x2132, 0x214E), + (0x2160, 0x2170), + (0x2161, 0x2171), + (0x2162, 0x2172), + (0x2163, 0x2173), + (0x2164, 0x2174), + (0x2165, 0x2175), + (0x2166, 0x2176), + (0x2167, 0x2177), + (0x2168, 0x2178), + (0x2169, 0x2179), + (0x216A, 0x217A), + (0x216B, 0x217B), + (0x216C, 0x217C), + (0x216D, 0x217D), + (0x216E, 0x217E), + (0x216F, 0x217F), + (0x2183, 0x2184), + (0x24B6, 0x24D0), + (0x24B7, 0x24D1), + (0x24B8, 0x24D2), + (0x24B9, 0x24D3), + (0x24BA, 0x24D4), + (0x24BB, 0x24D5), + (0x24BC, 0x24D6), + (0x24BD, 0x24D7), + (0x24BE, 0x24D8), + (0x24BF, 0x24D9), + (0x24C0, 0x24DA), + (0x24C1, 0x24DB), + (0x24C2, 0x24DC), + (0x24C3, 0x24DD), + (0x24C4, 0x24DE), + (0x24C5, 0x24DF), + (0x24C6, 0x24E0), + (0x24C7, 0x24E1), + (0x24C8, 0x24E2), + (0x24C9, 0x24E3), + (0x24CA, 0x24E4), + (0x24CB, 0x24E5), + (0x24CC, 0x24E6), + (0x24CD, 0x24E7), + (0x24CE, 0x24E8), + (0x24CF, 0x24E9), + (0x2C00, 0x2C30), + (0x2C01, 0x2C31), + (0x2C02, 0x2C32), + (0x2C03, 0x2C33), + (0x2C04, 0x2C34), + (0x2C05, 0x2C35), + (0x2C06, 0x2C36), + (0x2C07, 0x2C37), + (0x2C08, 0x2C38), + (0x2C09, 0x2C39), + (0x2C0A, 0x2C3A), + (0x2C0B, 0x2C3B), + (0x2C0C, 0x2C3C), + (0x2C0D, 0x2C3D), + (0x2C0E, 0x2C3E), + (0x2C0F, 0x2C3F), + (0x2C10, 0x2C40), + (0x2C11, 0x2C41), + (0x2C12, 0x2C42), + (0x2C13, 0x2C43), + (0x2C14, 0x2C44), + (0x2C15, 0x2C45), + (0x2C16, 0x2C46), + (0x2C17, 0x2C47), + (0x2C18, 0x2C48), + (0x2C19, 0x2C49), + (0x2C1A, 0x2C4A), + (0x2C1B, 0x2C4B), + (0x2C1C, 0x2C4C), + (0x2C1D, 0x2C4D), + (0x2C1E, 0x2C4E), + (0x2C1F, 0x2C4F), + (0x2C20, 0x2C50), + (0x2C21, 0x2C51), + (0x2C22, 0x2C52), + (0x2C23, 0x2C53), + (0x2C24, 0x2C54), + (0x2C25, 0x2C55), + (0x2C26, 0x2C56), + (0x2C27, 0x2C57), + (0x2C28, 0x2C58), + (0x2C29, 0x2C59), + (0x2C2A, 0x2C5A), + (0x2C2B, 0x2C5B), + (0x2C2C, 0x2C5C), + (0x2C2D, 0x2C5D), + (0x2C2E, 0x2C5E), + (0x2C2F, 0x2C5F), + (0x2C60, 0x2C61), + (0x2C62, 0x26B), + (0x2C63, 0x1D7D), + (0x2C64, 0x27D), + (0x2C67, 0x2C68), + (0x2C69, 0x2C6A), + (0x2C6B, 0x2C6C), + (0x2C6D, 0x251), + (0x2C6E, 0x271), + (0x2C6F, 0x250), + (0x2C70, 0x252), + (0x2C72, 0x2C73), + (0x2C75, 0x2C76), + (0x2C7E, 0x23F), + (0x2C7F, 0x240), + (0x2C80, 0x2C81), + (0x2C82, 0x2C83), + (0x2C84, 0x2C85), + (0x2C86, 0x2C87), + (0x2C88, 0x2C89), + (0x2C8A, 0x2C8B), + (0x2C8C, 0x2C8D), + (0x2C8E, 0x2C8F), + (0x2C90, 0x2C91), + (0x2C92, 0x2C93), + (0x2C94, 0x2C95), + (0x2C96, 0x2C97), + (0x2C98, 0x2C99), + (0x2C9A, 0x2C9B), + (0x2C9C, 0x2C9D), + (0x2C9E, 0x2C9F), + (0x2CA0, 0x2CA1), + (0x2CA2, 0x2CA3), + (0x2CA4, 0x2CA5), + (0x2CA6, 0x2CA7), + (0x2CA8, 0x2CA9), + (0x2CAA, 0x2CAB), + (0x2CAC, 0x2CAD), + (0x2CAE, 0x2CAF), + (0x2CB0, 0x2CB1), + (0x2CB2, 0x2CB3), + (0x2CB4, 0x2CB5), + (0x2CB6, 0x2CB7), + (0x2CB8, 0x2CB9), + (0x2CBA, 0x2CBB), + (0x2CBC, 0x2CBD), + (0x2CBE, 0x2CBF), + (0x2CC0, 0x2CC1), + (0x2CC2, 0x2CC3), + (0x2CC4, 0x2CC5), + (0x2CC6, 0x2CC7), + (0x2CC8, 0x2CC9), + (0x2CCA, 0x2CCB), + (0x2CCC, 0x2CCD), + (0x2CCE, 0x2CCF), + (0x2CD0, 0x2CD1), + (0x2CD2, 0x2CD3), + (0x2CD4, 0x2CD5), + (0x2CD6, 0x2CD7), + (0x2CD8, 0x2CD9), + (0x2CDA, 0x2CDB), + (0x2CDC, 0x2CDD), + (0x2CDE, 0x2CDF), + (0x2CE0, 0x2CE1), + (0x2CE2, 0x2CE3), + (0x2CEB, 0x2CEC), + (0x2CED, 0x2CEE), + (0x2CF2, 0x2CF3), + (0xA640, 0xA641), + (0xA642, 0xA643), + (0xA644, 0xA645), + (0xA646, 0xA647), + (0xA648, 0xA649), + (0xA64A, 0xA64B), + (0xA64C, 0xA64D), + (0xA64E, 0xA64F), + (0xA650, 0xA651), + (0xA652, 0xA653), + (0xA654, 0xA655), + (0xA656, 0xA657), + (0xA658, 0xA659), + (0xA65A, 0xA65B), + (0xA65C, 0xA65D), + (0xA65E, 0xA65F), + (0xA660, 0xA661), + (0xA662, 0xA663), + (0xA664, 0xA665), + (0xA666, 0xA667), + (0xA668, 0xA669), + (0xA66A, 0xA66B), + (0xA66C, 0xA66D), + (0xA680, 0xA681), + (0xA682, 0xA683), + (0xA684, 0xA685), + (0xA686, 0xA687), + (0xA688, 0xA689), + (0xA68A, 0xA68B), + (0xA68C, 0xA68D), + (0xA68E, 0xA68F), + (0xA690, 0xA691), + (0xA692, 0xA693), + (0xA694, 0xA695), + (0xA696, 0xA697), + (0xA698, 0xA699), + (0xA69A, 0xA69B), + (0xA722, 0xA723), + (0xA724, 0xA725), + (0xA726, 0xA727), + (0xA728, 0xA729), + (0xA72A, 0xA72B), + (0xA72C, 0xA72D), + (0xA72E, 0xA72F), + (0xA732, 0xA733), + (0xA734, 0xA735), + (0xA736, 0xA737), + (0xA738, 0xA739), + (0xA73A, 0xA73B), + (0xA73C, 0xA73D), + (0xA73E, 0xA73F), + (0xA740, 0xA741), + (0xA742, 0xA743), + (0xA744, 0xA745), + (0xA746, 0xA747), + (0xA748, 0xA749), + (0xA74A, 0xA74B), + (0xA74C, 0xA74D), + (0xA74E, 0xA74F), + (0xA750, 0xA751), + (0xA752, 0xA753), + (0xA754, 0xA755), + (0xA756, 0xA757), + (0xA758, 0xA759), + (0xA75A, 0xA75B), + (0xA75C, 0xA75D), + (0xA75E, 0xA75F), + (0xA760, 0xA761), + (0xA762, 0xA763), + (0xA764, 0xA765), + (0xA766, 0xA767), + (0xA768, 0xA769), + (0xA76A, 0xA76B), + (0xA76C, 0xA76D), + (0xA76E, 0xA76F), + (0xA779, 0xA77A), + (0xA77B, 0xA77C), + (0xA77D, 0x1D79), + (0xA77E, 0xA77F), + (0xA780, 0xA781), + (0xA782, 0xA783), + (0xA784, 0xA785), + (0xA786, 0xA787), + (0xA78B, 0xA78C), + (0xA78D, 0x265), + (0xA790, 0xA791), + (0xA792, 0xA793), + (0xA796, 0xA797), + (0xA798, 0xA799), + (0xA79A, 0xA79B), + (0xA79C, 0xA79D), + (0xA79E, 0xA79F), + (0xA7A0, 0xA7A1), + (0xA7A2, 0xA7A3), + (0xA7A4, 0xA7A5), + (0xA7A6, 0xA7A7), + (0xA7A8, 0xA7A9), + (0xA7AA, 0x266), + (0xA7AB, 0x25C), + (0xA7AC, 0x261), + (0xA7AD, 0x26C), + (0xA7AE, 0x26A), + (0xA7B0, 0x29E), + (0xA7B1, 0x287), + (0xA7B2, 0x29D), + (0xA7B3, 0xAB53), + (0xA7B4, 0xA7B5), + (0xA7B6, 0xA7B7), + (0xA7B8, 0xA7B9), + (0xA7BA, 0xA7BB), + (0xA7BC, 0xA7BD), + (0xA7BE, 0xA7BF), + (0xA7C0, 0xA7C1), + (0xA7C2, 0xA7C3), + (0xA7C4, 0xA794), + (0xA7C5, 0x282), + (0xA7C6, 0x1D8E), + (0xA7C7, 0xA7C8), + (0xA7C9, 0xA7CA), + (0xA7CB, 0x264), + (0xA7CC, 0xA7CD), + (0xA7CE, 0xA7CF), + (0xA7D0, 0xA7D1), + (0xA7D2, 0xA7D3), + (0xA7D4, 0xA7D5), + (0xA7D6, 0xA7D7), + (0xA7D8, 0xA7D9), + (0xA7DA, 0xA7DB), + (0xA7DC, 0x19B), + (0xA7DD, 0x277), + (0xA7E2, 0x27C), + (0xA7F5, 0xA7F6), + (0xAB6C, 0xAB4B), + (0xAB6D, 0xAB4C), + (0xAB70, 0x13A0), + (0xAB71, 0x13A1), + (0xAB72, 0x13A2), + (0xAB73, 0x13A3), + (0xAB74, 0x13A4), + (0xAB75, 0x13A5), + (0xAB76, 0x13A6), + (0xAB77, 0x13A7), + (0xAB78, 0x13A8), + (0xAB79, 0x13A9), + (0xAB7A, 0x13AA), + (0xAB7B, 0x13AB), + (0xAB7C, 0x13AC), + (0xAB7D, 0x13AD), + (0xAB7E, 0x13AE), + (0xAB7F, 0x13AF), + (0xAB80, 0x13B0), + (0xAB81, 0x13B1), + (0xAB82, 0x13B2), + (0xAB83, 0x13B3), + (0xAB84, 0x13B4), + (0xAB85, 0x13B5), + (0xAB86, 0x13B6), + (0xAB87, 0x13B7), + (0xAB88, 0x13B8), + (0xAB89, 0x13B9), + (0xAB8A, 0x13BA), + (0xAB8B, 0x13BB), + (0xAB8C, 0x13BC), + (0xAB8D, 0x13BD), + (0xAB8E, 0x13BE), + (0xAB8F, 0x13BF), + (0xAB90, 0x13C0), + (0xAB91, 0x13C1), + (0xAB92, 0x13C2), + (0xAB93, 0x13C3), + (0xAB94, 0x13C4), + (0xAB95, 0x13C5), + (0xAB96, 0x13C6), + (0xAB97, 0x13C7), + (0xAB98, 0x13C8), + (0xAB99, 0x13C9), + (0xAB9A, 0x13CA), + (0xAB9B, 0x13CB), + (0xAB9C, 0x13CC), + (0xAB9D, 0x13CD), + (0xAB9E, 0x13CE), + (0xAB9F, 0x13CF), + (0xABA0, 0x13D0), + (0xABA1, 0x13D1), + (0xABA2, 0x13D2), + (0xABA3, 0x13D3), + (0xABA4, 0x13D4), + (0xABA5, 0x13D5), + (0xABA6, 0x13D6), + (0xABA7, 0x13D7), + (0xABA8, 0x13D8), + (0xABA9, 0x13D9), + (0xABAA, 0x13DA), + (0xABAB, 0x13DB), + (0xABAC, 0x13DC), + (0xABAD, 0x13DD), + (0xABAE, 0x13DE), + (0xABAF, 0x13DF), + (0xABB0, 0x13E0), + (0xABB1, 0x13E1), + (0xABB2, 0x13E2), + (0xABB3, 0x13E3), + (0xABB4, 0x13E4), + (0xABB5, 0x13E5), + (0xABB6, 0x13E6), + (0xABB7, 0x13E7), + (0xABB8, 0x13E8), + (0xABB9, 0x13E9), + (0xABBA, 0x13EA), + (0xABBB, 0x13EB), + (0xABBC, 0x13EC), + (0xABBD, 0x13ED), + (0xABBE, 0x13EE), + (0xABBF, 0x13EF), + (0xFB05, 0xFB06), + (0xFF21, 0xFF41), + (0xFF22, 0xFF42), + (0xFF23, 0xFF43), + (0xFF24, 0xFF44), + (0xFF25, 0xFF45), + (0xFF26, 0xFF46), + (0xFF27, 0xFF47), + (0xFF28, 0xFF48), + (0xFF29, 0xFF49), + (0xFF2A, 0xFF4A), + (0xFF2B, 0xFF4B), + (0xFF2C, 0xFF4C), + (0xFF2D, 0xFF4D), + (0xFF2E, 0xFF4E), + (0xFF2F, 0xFF4F), + (0xFF30, 0xFF50), + (0xFF31, 0xFF51), + (0xFF32, 0xFF52), + (0xFF33, 0xFF53), + (0xFF34, 0xFF54), + (0xFF35, 0xFF55), + (0xFF36, 0xFF56), + (0xFF37, 0xFF57), + (0xFF38, 0xFF58), + (0xFF39, 0xFF59), + (0xFF3A, 0xFF5A), + (0x10400, 0x10428), + (0x10401, 0x10429), + (0x10402, 0x1042A), + (0x10403, 0x1042B), + (0x10404, 0x1042C), + (0x10405, 0x1042D), + (0x10406, 0x1042E), + (0x10407, 0x1042F), + (0x10408, 0x10430), + (0x10409, 0x10431), + (0x1040A, 0x10432), + (0x1040B, 0x10433), + (0x1040C, 0x10434), + (0x1040D, 0x10435), + (0x1040E, 0x10436), + (0x1040F, 0x10437), + (0x10410, 0x10438), + (0x10411, 0x10439), + (0x10412, 0x1043A), + (0x10413, 0x1043B), + (0x10414, 0x1043C), + (0x10415, 0x1043D), + (0x10416, 0x1043E), + (0x10417, 0x1043F), + (0x10418, 0x10440), + (0x10419, 0x10441), + (0x1041A, 0x10442), + (0x1041B, 0x10443), + (0x1041C, 0x10444), + (0x1041D, 0x10445), + (0x1041E, 0x10446), + (0x1041F, 0x10447), + (0x10420, 0x10448), + (0x10421, 0x10449), + (0x10422, 0x1044A), + (0x10423, 0x1044B), + (0x10424, 0x1044C), + (0x10425, 0x1044D), + (0x10426, 0x1044E), + (0x10427, 0x1044F), + (0x104B0, 0x104D8), + (0x104B1, 0x104D9), + (0x104B2, 0x104DA), + (0x104B3, 0x104DB), + (0x104B4, 0x104DC), + (0x104B5, 0x104DD), + (0x104B6, 0x104DE), + (0x104B7, 0x104DF), + (0x104B8, 0x104E0), + (0x104B9, 0x104E1), + (0x104BA, 0x104E2), + (0x104BB, 0x104E3), + (0x104BC, 0x104E4), + (0x104BD, 0x104E5), + (0x104BE, 0x104E6), + (0x104BF, 0x104E7), + (0x104C0, 0x104E8), + (0x104C1, 0x104E9), + (0x104C2, 0x104EA), + (0x104C3, 0x104EB), + (0x104C4, 0x104EC), + (0x104C5, 0x104ED), + (0x104C6, 0x104EE), + (0x104C7, 0x104EF), + (0x104C8, 0x104F0), + (0x104C9, 0x104F1), + (0x104CA, 0x104F2), + (0x104CB, 0x104F3), + (0x104CC, 0x104F4), + (0x104CD, 0x104F5), + (0x104CE, 0x104F6), + (0x104CF, 0x104F7), + (0x104D0, 0x104F8), + (0x104D1, 0x104F9), + (0x104D2, 0x104FA), + (0x104D3, 0x104FB), + (0x10570, 0x10597), + (0x10571, 0x10598), + (0x10572, 0x10599), + (0x10573, 0x1059A), + (0x10574, 0x1059B), + (0x10575, 0x1059C), + (0x10576, 0x1059D), + (0x10577, 0x1059E), + (0x10578, 0x1059F), + (0x10579, 0x105A0), + (0x1057A, 0x105A1), + (0x1057C, 0x105A3), + (0x1057D, 0x105A4), + (0x1057E, 0x105A5), + (0x1057F, 0x105A6), + (0x10580, 0x105A7), + (0x10581, 0x105A8), + (0x10582, 0x105A9), + (0x10583, 0x105AA), + (0x10584, 0x105AB), + (0x10585, 0x105AC), + (0x10586, 0x105AD), + (0x10587, 0x105AE), + (0x10588, 0x105AF), + (0x10589, 0x105B0), + (0x1058A, 0x105B1), + (0x1058C, 0x105B3), + (0x1058D, 0x105B4), + (0x1058E, 0x105B5), + (0x1058F, 0x105B6), + (0x10590, 0x105B7), + (0x10591, 0x105B8), + (0x10592, 0x105B9), + (0x10594, 0x105BB), + (0x10595, 0x105BC), + (0x10C80, 0x10CC0), + (0x10C81, 0x10CC1), + (0x10C82, 0x10CC2), + (0x10C83, 0x10CC3), + (0x10C84, 0x10CC4), + (0x10C85, 0x10CC5), + (0x10C86, 0x10CC6), + (0x10C87, 0x10CC7), + (0x10C88, 0x10CC8), + (0x10C89, 0x10CC9), + (0x10C8A, 0x10CCA), + (0x10C8B, 0x10CCB), + (0x10C8C, 0x10CCC), + (0x10C8D, 0x10CCD), + (0x10C8E, 0x10CCE), + (0x10C8F, 0x10CCF), + (0x10C90, 0x10CD0), + (0x10C91, 0x10CD1), + (0x10C92, 0x10CD2), + (0x10C93, 0x10CD3), + (0x10C94, 0x10CD4), + (0x10C95, 0x10CD5), + (0x10C96, 0x10CD6), + (0x10C97, 0x10CD7), + (0x10C98, 0x10CD8), + (0x10C99, 0x10CD9), + (0x10C9A, 0x10CDA), + (0x10C9B, 0x10CDB), + (0x10C9C, 0x10CDC), + (0x10C9D, 0x10CDD), + (0x10C9E, 0x10CDE), + (0x10C9F, 0x10CDF), + (0x10CA0, 0x10CE0), + (0x10CA1, 0x10CE1), + (0x10CA2, 0x10CE2), + (0x10CA3, 0x10CE3), + (0x10CA4, 0x10CE4), + (0x10CA5, 0x10CE5), + (0x10CA6, 0x10CE6), + (0x10CA7, 0x10CE7), + (0x10CA8, 0x10CE8), + (0x10CA9, 0x10CE9), + (0x10CAA, 0x10CEA), + (0x10CAB, 0x10CEB), + (0x10CAC, 0x10CEC), + (0x10CAD, 0x10CED), + (0x10CAE, 0x10CEE), + (0x10CAF, 0x10CEF), + (0x10CB0, 0x10CF0), + (0x10CB1, 0x10CF1), + (0x10CB2, 0x10CF2), + (0x10D50, 0x10D70), + (0x10D51, 0x10D71), + (0x10D52, 0x10D72), + (0x10D53, 0x10D73), + (0x10D54, 0x10D74), + (0x10D55, 0x10D75), + (0x10D56, 0x10D76), + (0x10D57, 0x10D77), + (0x10D58, 0x10D78), + (0x10D59, 0x10D79), + (0x10D5A, 0x10D7A), + (0x10D5B, 0x10D7B), + (0x10D5C, 0x10D7C), + (0x10D5D, 0x10D7D), + (0x10D5E, 0x10D7E), + (0x10D5F, 0x10D7F), + (0x10D60, 0x10D80), + (0x10D61, 0x10D81), + (0x10D62, 0x10D82), + (0x10D63, 0x10D83), + (0x10D64, 0x10D84), + (0x10D65, 0x10D85), + (0x118A0, 0x118C0), + (0x118A1, 0x118C1), + (0x118A2, 0x118C2), + (0x118A3, 0x118C3), + (0x118A4, 0x118C4), + (0x118A5, 0x118C5), + (0x118A6, 0x118C6), + (0x118A7, 0x118C7), + (0x118A8, 0x118C8), + (0x118A9, 0x118C9), + (0x118AA, 0x118CA), + (0x118AB, 0x118CB), + (0x118AC, 0x118CC), + (0x118AD, 0x118CD), + (0x118AE, 0x118CE), + (0x118AF, 0x118CF), + (0x118B0, 0x118D0), + (0x118B1, 0x118D1), + (0x118B2, 0x118D2), + (0x118B3, 0x118D3), + (0x118B4, 0x118D4), + (0x118B5, 0x118D5), + (0x118B6, 0x118D6), + (0x118B7, 0x118D7), + (0x118B8, 0x118D8), + (0x118B9, 0x118D9), + (0x118BA, 0x118DA), + (0x118BB, 0x118DB), + (0x118BC, 0x118DC), + (0x118BD, 0x118DD), + (0x118BE, 0x118DE), + (0x118BF, 0x118DF), + (0x16E40, 0x16E60), + (0x16E41, 0x16E61), + (0x16E42, 0x16E62), + (0x16E43, 0x16E63), + (0x16E44, 0x16E64), + (0x16E45, 0x16E65), + (0x16E46, 0x16E66), + (0x16E47, 0x16E67), + (0x16E48, 0x16E68), + (0x16E49, 0x16E69), + (0x16E4A, 0x16E6A), + (0x16E4B, 0x16E6B), + (0x16E4C, 0x16E6C), + (0x16E4D, 0x16E6D), + (0x16E4E, 0x16E6E), + (0x16E4F, 0x16E6F), + (0x16E50, 0x16E70), + (0x16E51, 0x16E71), + (0x16E52, 0x16E72), + (0x16E53, 0x16E73), + (0x16E54, 0x16E74), + (0x16E55, 0x16E75), + (0x16E56, 0x16E76), + (0x16E57, 0x16E77), + (0x16E58, 0x16E78), + (0x16E59, 0x16E79), + (0x16E5A, 0x16E7A), + (0x16E5B, 0x16E7B), + (0x16E5C, 0x16E7C), + (0x16E5D, 0x16E7D), + (0x16E5E, 0x16E7E), + (0x16E5F, 0x16E7F), + (0x16EA0, 0x16EBB), + (0x16EA1, 0x16EBC), + (0x16EA2, 0x16EBD), + (0x16EA3, 0x16EBE), + (0x16EA4, 0x16EBF), + (0x16EA5, 0x16EC0), + (0x16EA6, 0x16EC1), + (0x16EA7, 0x16EC2), + (0x16EA8, 0x16EC3), + (0x16EA9, 0x16EC4), + (0x16EAA, 0x16EC5), + (0x16EAB, 0x16EC6), + (0x16EAC, 0x16EC7), + (0x16EAD, 0x16EC8), + (0x16EAE, 0x16EC9), + (0x16EAF, 0x16ECA), + (0x16EB0, 0x16ECB), + (0x16EB1, 0x16ECC), + (0x16EB2, 0x16ECD), + (0x16EB3, 0x16ECE), + (0x16EB4, 0x16ECF), + (0x16EB5, 0x16ED0), + (0x16EB6, 0x16ED1), + (0x16EB7, 0x16ED2), + (0x16EB8, 0x16ED3), + (0x1DF40, 0x1DF41), + (0x1DF48, 0x1DF49), + (0x1DF4A, 0x1DF4B), + (0x1DF4D, 0x1DF4E), + (0x1DF51, 0x1DF52), + (0x1DF68, 0x1DF69), + (0x1DF6A, 0x1DF6B), + (0x1DF6C, 0x1DF6D), + (0x1DF6E, 0x1DF6F), + (0x1DF72, 0x1DF73), + (0x1DF74, 0x1DF75), + (0x1DF76, 0x1DF77), + (0x1DF78, 0x1DF79), + (0x1DF7A, 0x1DF7B), + (0x1DF7C, 0x1DF7D), + (0x1DF7E, 0x1DF7F), + (0x1DF95, 0xDF), + (0x1E900, 0x1E922), + (0x1E901, 0x1E923), + (0x1E902, 0x1E924), + (0x1E903, 0x1E925), + (0x1E904, 0x1E926), + (0x1E905, 0x1E927), + (0x1E906, 0x1E928), + (0x1E907, 0x1E929), + (0x1E908, 0x1E92A), + (0x1E909, 0x1E92B), + (0x1E90A, 0x1E92C), + (0x1E90B, 0x1E92D), + (0x1E90C, 0x1E92E), + (0x1E90D, 0x1E92F), + (0x1E90E, 0x1E930), + (0x1E90F, 0x1E931), + (0x1E910, 0x1E932), + (0x1E911, 0x1E933), + (0x1E912, 0x1E934), + (0x1E913, 0x1E935), + (0x1E914, 0x1E936), + (0x1E915, 0x1E937), + (0x1E916, 0x1E938), + (0x1E917, 0x1E939), + (0x1E918, 0x1E93A), + (0x1E919, 0x1E93B), + (0x1E91A, 0x1E93C), + (0x1E91B, 0x1E93D), + (0x1E91C, 0x1E93E), + (0x1E91D, 0x1E93F), + (0x1E91E, 0x1E940), + (0x1E91F, 0x1E941), + (0x1E920, 0x1E942), + (0x1E921, 0x1E943), +]; + +/// `SIMPLE_FOLD` as (folded, code point), sorted. +pub static SIMPLE_FOLD_INVERSE: &[(u32, u32)] = &[ + (0x61, 0x41), + (0x62, 0x42), + (0x63, 0x43), + (0x64, 0x44), + (0x65, 0x45), + (0x66, 0x46), + (0x67, 0x47), + (0x68, 0x48), + (0x69, 0x49), + (0x6A, 0x4A), + (0x6B, 0x4B), + (0x6B, 0x212A), + (0x6C, 0x4C), + (0x6D, 0x4D), + (0x6E, 0x4E), + (0x6F, 0x4F), + (0x70, 0x50), + (0x71, 0x51), + (0x72, 0x52), + (0x73, 0x53), + (0x73, 0x17F), + (0x74, 0x54), + (0x75, 0x55), + (0x76, 0x56), + (0x77, 0x57), + (0x78, 0x58), + (0x79, 0x59), + (0x7A, 0x5A), + (0xDF, 0x1E9E), + (0xDF, 0x1DF95), + (0xE0, 0xC0), + (0xE1, 0xC1), + (0xE2, 0xC2), + (0xE3, 0xC3), + (0xE4, 0xC4), + (0xE5, 0xC5), + (0xE5, 0x212B), + (0xE6, 0xC6), + (0xE7, 0xC7), + (0xE8, 0xC8), + (0xE9, 0xC9), + (0xEA, 0xCA), + (0xEB, 0xCB), + (0xEC, 0xCC), + (0xED, 0xCD), + (0xEE, 0xCE), + (0xEF, 0xCF), + (0xF0, 0xD0), + (0xF1, 0xD1), + (0xF2, 0xD2), + (0xF3, 0xD3), + (0xF4, 0xD4), + (0xF5, 0xD5), + (0xF6, 0xD6), + (0xF8, 0xD8), + (0xF9, 0xD9), + (0xFA, 0xDA), + (0xFB, 0xDB), + (0xFC, 0xDC), + (0xFD, 0xDD), + (0xFE, 0xDE), + (0xFF, 0x178), + (0x101, 0x100), + (0x103, 0x102), + (0x105, 0x104), + (0x107, 0x106), + (0x109, 0x108), + (0x10B, 0x10A), + (0x10D, 0x10C), + (0x10F, 0x10E), + (0x111, 0x110), + (0x113, 0x112), + (0x115, 0x114), + (0x117, 0x116), + (0x119, 0x118), + (0x11B, 0x11A), + (0x11D, 0x11C), + (0x11F, 0x11E), + (0x121, 0x120), + (0x123, 0x122), + (0x125, 0x124), + (0x127, 0x126), + (0x129, 0x128), + (0x12B, 0x12A), + (0x12D, 0x12C), + (0x12F, 0x12E), + (0x133, 0x132), + (0x135, 0x134), + (0x137, 0x136), + (0x13A, 0x139), + (0x13C, 0x13B), + (0x13E, 0x13D), + (0x140, 0x13F), + (0x142, 0x141), + (0x144, 0x143), + (0x146, 0x145), + (0x148, 0x147), + (0x14B, 0x14A), + (0x14D, 0x14C), + (0x14F, 0x14E), + (0x151, 0x150), + (0x153, 0x152), + (0x155, 0x154), + (0x157, 0x156), + (0x159, 0x158), + (0x15B, 0x15A), + (0x15D, 0x15C), + (0x15F, 0x15E), + (0x161, 0x160), + (0x163, 0x162), + (0x165, 0x164), + (0x167, 0x166), + (0x169, 0x168), + (0x16B, 0x16A), + (0x16D, 0x16C), + (0x16F, 0x16E), + (0x171, 0x170), + (0x173, 0x172), + (0x175, 0x174), + (0x177, 0x176), + (0x17A, 0x179), + (0x17C, 0x17B), + (0x17E, 0x17D), + (0x180, 0x243), + (0x183, 0x182), + (0x185, 0x184), + (0x188, 0x187), + (0x18C, 0x18B), + (0x192, 0x191), + (0x195, 0x1F6), + (0x199, 0x198), + (0x19A, 0x23D), + (0x19B, 0xA7DC), + (0x19E, 0x220), + (0x1A1, 0x1A0), + (0x1A3, 0x1A2), + (0x1A5, 0x1A4), + (0x1A8, 0x1A7), + (0x1AD, 0x1AC), + (0x1B0, 0x1AF), + (0x1B4, 0x1B3), + (0x1B6, 0x1B5), + (0x1B9, 0x1B8), + (0x1BD, 0x1BC), + (0x1BF, 0x1F7), + (0x1C6, 0x1C4), + (0x1C6, 0x1C5), + (0x1C9, 0x1C7), + (0x1C9, 0x1C8), + (0x1CC, 0x1CA), + (0x1CC, 0x1CB), + (0x1CE, 0x1CD), + (0x1D0, 0x1CF), + (0x1D2, 0x1D1), + (0x1D4, 0x1D3), + (0x1D6, 0x1D5), + (0x1D8, 0x1D7), + (0x1DA, 0x1D9), + (0x1DC, 0x1DB), + (0x1DD, 0x18E), + (0x1DF, 0x1DE), + (0x1E1, 0x1E0), + (0x1E3, 0x1E2), + (0x1E5, 0x1E4), + (0x1E7, 0x1E6), + (0x1E9, 0x1E8), + (0x1EB, 0x1EA), + (0x1ED, 0x1EC), + (0x1EF, 0x1EE), + (0x1F3, 0x1F1), + (0x1F3, 0x1F2), + (0x1F5, 0x1F4), + (0x1F9, 0x1F8), + (0x1FB, 0x1FA), + (0x1FD, 0x1FC), + (0x1FF, 0x1FE), + (0x201, 0x200), + (0x203, 0x202), + (0x205, 0x204), + (0x207, 0x206), + (0x209, 0x208), + (0x20B, 0x20A), + (0x20D, 0x20C), + (0x20F, 0x20E), + (0x211, 0x210), + (0x213, 0x212), + (0x215, 0x214), + (0x217, 0x216), + (0x219, 0x218), + (0x21B, 0x21A), + (0x21D, 0x21C), + (0x21F, 0x21E), + (0x223, 0x222), + (0x225, 0x224), + (0x227, 0x226), + (0x229, 0x228), + (0x22B, 0x22A), + (0x22D, 0x22C), + (0x22F, 0x22E), + (0x231, 0x230), + (0x233, 0x232), + (0x23C, 0x23B), + (0x23F, 0x2C7E), + (0x240, 0x2C7F), + (0x242, 0x241), + (0x247, 0x246), + (0x249, 0x248), + (0x24B, 0x24A), + (0x24D, 0x24C), + (0x24F, 0x24E), + (0x250, 0x2C6F), + (0x251, 0x2C6D), + (0x252, 0x2C70), + (0x253, 0x181), + (0x254, 0x186), + (0x256, 0x189), + (0x257, 0x18A), + (0x259, 0x18F), + (0x25B, 0x190), + (0x25C, 0xA7AB), + (0x260, 0x193), + (0x261, 0xA7AC), + (0x263, 0x194), + (0x264, 0xA7CB), + (0x265, 0xA78D), + (0x266, 0xA7AA), + (0x268, 0x197), + (0x269, 0x196), + (0x26A, 0xA7AE), + (0x26B, 0x2C62), + (0x26C, 0xA7AD), + (0x26F, 0x19C), + (0x271, 0x2C6E), + (0x272, 0x19D), + (0x275, 0x19F), + (0x277, 0xA7DD), + (0x27C, 0xA7E2), + (0x27D, 0x2C64), + (0x280, 0x1A6), + (0x282, 0xA7C5), + (0x283, 0x1A9), + (0x287, 0xA7B1), + (0x288, 0x1AE), + (0x289, 0x244), + (0x28A, 0x1B1), + (0x28B, 0x1B2), + (0x28C, 0x245), + (0x292, 0x1B7), + (0x29D, 0xA7B2), + (0x29E, 0xA7B0), + (0x371, 0x370), + (0x373, 0x372), + (0x377, 0x376), + (0x37B, 0x3FD), + (0x37C, 0x3FE), + (0x37D, 0x3FF), + (0x390, 0x1FD3), + (0x3AC, 0x386), + (0x3AD, 0x388), + (0x3AE, 0x389), + (0x3AF, 0x38A), + (0x3B0, 0x1FE3), + (0x3B1, 0x391), + (0x3B2, 0x392), + (0x3B2, 0x3D0), + (0x3B3, 0x393), + (0x3B4, 0x394), + (0x3B5, 0x395), + (0x3B5, 0x3F5), + (0x3B6, 0x396), + (0x3B7, 0x397), + (0x3B8, 0x398), + (0x3B8, 0x3D1), + (0x3B8, 0x3F4), + (0x3B9, 0x345), + (0x3B9, 0x399), + (0x3B9, 0x1FBE), + (0x3BA, 0x39A), + (0x3BA, 0x3F0), + (0x3BB, 0x39B), + (0x3BC, 0xB5), + (0x3BC, 0x39C), + (0x3BD, 0x39D), + (0x3BE, 0x39E), + (0x3BF, 0x39F), + (0x3C0, 0x3A0), + (0x3C0, 0x3D6), + (0x3C1, 0x3A1), + (0x3C1, 0x3F1), + (0x3C3, 0x3A3), + (0x3C3, 0x3C2), + (0x3C4, 0x3A4), + (0x3C5, 0x3A5), + (0x3C6, 0x3A6), + (0x3C6, 0x3D5), + (0x3C7, 0x3A7), + (0x3C8, 0x3A8), + (0x3C9, 0x3A9), + (0x3C9, 0x2126), + (0x3CA, 0x3AA), + (0x3CB, 0x3AB), + (0x3CC, 0x38C), + (0x3CD, 0x38E), + (0x3CE, 0x38F), + (0x3D7, 0x3CF), + (0x3D9, 0x3D8), + (0x3DB, 0x3DA), + (0x3DD, 0x3DC), + (0x3DF, 0x3DE), + (0x3E1, 0x3E0), + (0x3E3, 0x3E2), + (0x3E5, 0x3E4), + (0x3E7, 0x3E6), + (0x3E9, 0x3E8), + (0x3EB, 0x3EA), + (0x3ED, 0x3EC), + (0x3EF, 0x3EE), + (0x3F2, 0x3F9), + (0x3F3, 0x37F), + (0x3F8, 0x3F7), + (0x3FB, 0x3FA), + (0x430, 0x410), + (0x431, 0x411), + (0x432, 0x412), + (0x432, 0x1C80), + (0x433, 0x413), + (0x434, 0x414), + (0x434, 0x1C81), + (0x435, 0x415), + (0x436, 0x416), + (0x437, 0x417), + (0x438, 0x418), + (0x439, 0x419), + (0x43A, 0x41A), + (0x43B, 0x41B), + (0x43C, 0x41C), + (0x43D, 0x41D), + (0x43E, 0x41E), + (0x43E, 0x1C82), + (0x43F, 0x41F), + (0x440, 0x420), + (0x441, 0x421), + (0x441, 0x1C83), + (0x442, 0x422), + (0x442, 0x1C84), + (0x442, 0x1C85), + (0x443, 0x423), + (0x444, 0x424), + (0x445, 0x425), + (0x446, 0x426), + (0x447, 0x427), + (0x448, 0x428), + (0x449, 0x429), + (0x44A, 0x42A), + (0x44A, 0x1C86), + (0x44B, 0x42B), + (0x44C, 0x42C), + (0x44D, 0x42D), + (0x44E, 0x42E), + (0x44F, 0x42F), + (0x450, 0x400), + (0x451, 0x401), + (0x452, 0x402), + (0x453, 0x403), + (0x454, 0x404), + (0x455, 0x405), + (0x456, 0x406), + (0x457, 0x407), + (0x458, 0x408), + (0x459, 0x409), + (0x45A, 0x40A), + (0x45B, 0x40B), + (0x45C, 0x40C), + (0x45D, 0x40D), + (0x45E, 0x40E), + (0x45F, 0x40F), + (0x461, 0x460), + (0x463, 0x462), + (0x463, 0x1C87), + (0x465, 0x464), + (0x467, 0x466), + (0x469, 0x468), + (0x46B, 0x46A), + (0x46D, 0x46C), + (0x46F, 0x46E), + (0x471, 0x470), + (0x473, 0x472), + (0x475, 0x474), + (0x477, 0x476), + (0x479, 0x478), + (0x47B, 0x47A), + (0x47D, 0x47C), + (0x47F, 0x47E), + (0x481, 0x480), + (0x48B, 0x48A), + (0x48D, 0x48C), + (0x48F, 0x48E), + (0x491, 0x490), + (0x493, 0x492), + (0x495, 0x494), + (0x497, 0x496), + (0x499, 0x498), + (0x49B, 0x49A), + (0x49D, 0x49C), + (0x49F, 0x49E), + (0x4A1, 0x4A0), + (0x4A3, 0x4A2), + (0x4A5, 0x4A4), + (0x4A7, 0x4A6), + (0x4A9, 0x4A8), + (0x4AB, 0x4AA), + (0x4AD, 0x4AC), + (0x4AF, 0x4AE), + (0x4B1, 0x4B0), + (0x4B3, 0x4B2), + (0x4B5, 0x4B4), + (0x4B7, 0x4B6), + (0x4B9, 0x4B8), + (0x4BB, 0x4BA), + (0x4BD, 0x4BC), + (0x4BF, 0x4BE), + (0x4C2, 0x4C1), + (0x4C4, 0x4C3), + (0x4C6, 0x4C5), + (0x4C8, 0x4C7), + (0x4CA, 0x4C9), + (0x4CC, 0x4CB), + (0x4CE, 0x4CD), + (0x4CF, 0x4C0), + (0x4D1, 0x4D0), + (0x4D3, 0x4D2), + (0x4D5, 0x4D4), + (0x4D7, 0x4D6), + (0x4D9, 0x4D8), + (0x4DB, 0x4DA), + (0x4DD, 0x4DC), + (0x4DF, 0x4DE), + (0x4E1, 0x4E0), + (0x4E3, 0x4E2), + (0x4E5, 0x4E4), + (0x4E7, 0x4E6), + (0x4E9, 0x4E8), + (0x4EB, 0x4EA), + (0x4ED, 0x4EC), + (0x4EF, 0x4EE), + (0x4F1, 0x4F0), + (0x4F3, 0x4F2), + (0x4F5, 0x4F4), + (0x4F7, 0x4F6), + (0x4F9, 0x4F8), + (0x4FB, 0x4FA), + (0x4FD, 0x4FC), + (0x4FF, 0x4FE), + (0x501, 0x500), + (0x503, 0x502), + (0x505, 0x504), + (0x507, 0x506), + (0x509, 0x508), + (0x50B, 0x50A), + (0x50D, 0x50C), + (0x50F, 0x50E), + (0x511, 0x510), + (0x513, 0x512), + (0x515, 0x514), + (0x517, 0x516), + (0x519, 0x518), + (0x51B, 0x51A), + (0x51D, 0x51C), + (0x51F, 0x51E), + (0x521, 0x520), + (0x523, 0x522), + (0x525, 0x524), + (0x527, 0x526), + (0x529, 0x528), + (0x52B, 0x52A), + (0x52D, 0x52C), + (0x52F, 0x52E), + (0x561, 0x531), + (0x562, 0x532), + (0x563, 0x533), + (0x564, 0x534), + (0x565, 0x535), + (0x566, 0x536), + (0x567, 0x537), + (0x568, 0x538), + (0x569, 0x539), + (0x56A, 0x53A), + (0x56B, 0x53B), + (0x56C, 0x53C), + (0x56D, 0x53D), + (0x56E, 0x53E), + (0x56F, 0x53F), + (0x570, 0x540), + (0x571, 0x541), + (0x572, 0x542), + (0x573, 0x543), + (0x574, 0x544), + (0x575, 0x545), + (0x576, 0x546), + (0x577, 0x547), + (0x578, 0x548), + (0x579, 0x549), + (0x57A, 0x54A), + (0x57B, 0x54B), + (0x57C, 0x54C), + (0x57D, 0x54D), + (0x57E, 0x54E), + (0x57F, 0x54F), + (0x580, 0x550), + (0x581, 0x551), + (0x582, 0x552), + (0x583, 0x553), + (0x584, 0x554), + (0x585, 0x555), + (0x586, 0x556), + (0x10D0, 0x1C90), + (0x10D1, 0x1C91), + (0x10D2, 0x1C92), + (0x10D3, 0x1C93), + (0x10D4, 0x1C94), + (0x10D5, 0x1C95), + (0x10D6, 0x1C96), + (0x10D7, 0x1C97), + (0x10D8, 0x1C98), + (0x10D9, 0x1C99), + (0x10DA, 0x1C9A), + (0x10DB, 0x1C9B), + (0x10DC, 0x1C9C), + (0x10DD, 0x1C9D), + (0x10DE, 0x1C9E), + (0x10DF, 0x1C9F), + (0x10E0, 0x1CA0), + (0x10E1, 0x1CA1), + (0x10E2, 0x1CA2), + (0x10E3, 0x1CA3), + (0x10E4, 0x1CA4), + (0x10E5, 0x1CA5), + (0x10E6, 0x1CA6), + (0x10E7, 0x1CA7), + (0x10E8, 0x1CA8), + (0x10E9, 0x1CA9), + (0x10EA, 0x1CAA), + (0x10EB, 0x1CAB), + (0x10EC, 0x1CAC), + (0x10ED, 0x1CAD), + (0x10EE, 0x1CAE), + (0x10EF, 0x1CAF), + (0x10F0, 0x1CB0), + (0x10F1, 0x1CB1), + (0x10F2, 0x1CB2), + (0x10F3, 0x1CB3), + (0x10F4, 0x1CB4), + (0x10F5, 0x1CB5), + (0x10F6, 0x1CB6), + (0x10F7, 0x1CB7), + (0x10F8, 0x1CB8), + (0x10F9, 0x1CB9), + (0x10FA, 0x1CBA), + (0x10FD, 0x1CBD), + (0x10FE, 0x1CBE), + (0x10FF, 0x1CBF), + (0x13A0, 0xAB70), + (0x13A1, 0xAB71), + (0x13A2, 0xAB72), + (0x13A3, 0xAB73), + (0x13A4, 0xAB74), + (0x13A5, 0xAB75), + (0x13A6, 0xAB76), + (0x13A7, 0xAB77), + (0x13A8, 0xAB78), + (0x13A9, 0xAB79), + (0x13AA, 0xAB7A), + (0x13AB, 0xAB7B), + (0x13AC, 0xAB7C), + (0x13AD, 0xAB7D), + (0x13AE, 0xAB7E), + (0x13AF, 0xAB7F), + (0x13B0, 0xAB80), + (0x13B1, 0xAB81), + (0x13B2, 0xAB82), + (0x13B3, 0xAB83), + (0x13B4, 0xAB84), + (0x13B5, 0xAB85), + (0x13B6, 0xAB86), + (0x13B7, 0xAB87), + (0x13B8, 0xAB88), + (0x13B9, 0xAB89), + (0x13BA, 0xAB8A), + (0x13BB, 0xAB8B), + (0x13BC, 0xAB8C), + (0x13BD, 0xAB8D), + (0x13BE, 0xAB8E), + (0x13BF, 0xAB8F), + (0x13C0, 0xAB90), + (0x13C1, 0xAB91), + (0x13C2, 0xAB92), + (0x13C3, 0xAB93), + (0x13C4, 0xAB94), + (0x13C5, 0xAB95), + (0x13C6, 0xAB96), + (0x13C7, 0xAB97), + (0x13C8, 0xAB98), + (0x13C9, 0xAB99), + (0x13CA, 0xAB9A), + (0x13CB, 0xAB9B), + (0x13CC, 0xAB9C), + (0x13CD, 0xAB9D), + (0x13CE, 0xAB9E), + (0x13CF, 0xAB9F), + (0x13D0, 0xABA0), + (0x13D1, 0xABA1), + (0x13D2, 0xABA2), + (0x13D3, 0xABA3), + (0x13D4, 0xABA4), + (0x13D5, 0xABA5), + (0x13D6, 0xABA6), + (0x13D7, 0xABA7), + (0x13D8, 0xABA8), + (0x13D9, 0xABA9), + (0x13DA, 0xABAA), + (0x13DB, 0xABAB), + (0x13DC, 0xABAC), + (0x13DD, 0xABAD), + (0x13DE, 0xABAE), + (0x13DF, 0xABAF), + (0x13E0, 0xABB0), + (0x13E1, 0xABB1), + (0x13E2, 0xABB2), + (0x13E3, 0xABB3), + (0x13E4, 0xABB4), + (0x13E5, 0xABB5), + (0x13E6, 0xABB6), + (0x13E7, 0xABB7), + (0x13E8, 0xABB8), + (0x13E9, 0xABB9), + (0x13EA, 0xABBA), + (0x13EB, 0xABBB), + (0x13EC, 0xABBC), + (0x13ED, 0xABBD), + (0x13EE, 0xABBE), + (0x13EF, 0xABBF), + (0x13F0, 0x13F8), + (0x13F1, 0x13F9), + (0x13F2, 0x13FA), + (0x13F3, 0x13FB), + (0x13F4, 0x13FC), + (0x13F5, 0x13FD), + (0x1C8A, 0x1C89), + (0x1D79, 0xA77D), + (0x1D7D, 0x2C63), + (0x1D8E, 0xA7C6), + (0x1E01, 0x1E00), + (0x1E03, 0x1E02), + (0x1E05, 0x1E04), + (0x1E07, 0x1E06), + (0x1E09, 0x1E08), + (0x1E0B, 0x1E0A), + (0x1E0D, 0x1E0C), + (0x1E0F, 0x1E0E), + (0x1E11, 0x1E10), + (0x1E13, 0x1E12), + (0x1E15, 0x1E14), + (0x1E17, 0x1E16), + (0x1E19, 0x1E18), + (0x1E1B, 0x1E1A), + (0x1E1D, 0x1E1C), + (0x1E1F, 0x1E1E), + (0x1E21, 0x1E20), + (0x1E23, 0x1E22), + (0x1E25, 0x1E24), + (0x1E27, 0x1E26), + (0x1E29, 0x1E28), + (0x1E2B, 0x1E2A), + (0x1E2D, 0x1E2C), + (0x1E2F, 0x1E2E), + (0x1E31, 0x1E30), + (0x1E33, 0x1E32), + (0x1E35, 0x1E34), + (0x1E37, 0x1E36), + (0x1E39, 0x1E38), + (0x1E3B, 0x1E3A), + (0x1E3D, 0x1E3C), + (0x1E3F, 0x1E3E), + (0x1E41, 0x1E40), + (0x1E43, 0x1E42), + (0x1E45, 0x1E44), + (0x1E47, 0x1E46), + (0x1E49, 0x1E48), + (0x1E4B, 0x1E4A), + (0x1E4D, 0x1E4C), + (0x1E4F, 0x1E4E), + (0x1E51, 0x1E50), + (0x1E53, 0x1E52), + (0x1E55, 0x1E54), + (0x1E57, 0x1E56), + (0x1E59, 0x1E58), + (0x1E5B, 0x1E5A), + (0x1E5D, 0x1E5C), + (0x1E5F, 0x1E5E), + (0x1E61, 0x1E60), + (0x1E61, 0x1E9B), + (0x1E63, 0x1E62), + (0x1E65, 0x1E64), + (0x1E67, 0x1E66), + (0x1E69, 0x1E68), + (0x1E6B, 0x1E6A), + (0x1E6D, 0x1E6C), + (0x1E6F, 0x1E6E), + (0x1E71, 0x1E70), + (0x1E73, 0x1E72), + (0x1E75, 0x1E74), + (0x1E77, 0x1E76), + (0x1E79, 0x1E78), + (0x1E7B, 0x1E7A), + (0x1E7D, 0x1E7C), + (0x1E7F, 0x1E7E), + (0x1E81, 0x1E80), + (0x1E83, 0x1E82), + (0x1E85, 0x1E84), + (0x1E87, 0x1E86), + (0x1E89, 0x1E88), + (0x1E8B, 0x1E8A), + (0x1E8D, 0x1E8C), + (0x1E8F, 0x1E8E), + (0x1E91, 0x1E90), + (0x1E93, 0x1E92), + (0x1E95, 0x1E94), + (0x1EA1, 0x1EA0), + (0x1EA3, 0x1EA2), + (0x1EA5, 0x1EA4), + (0x1EA7, 0x1EA6), + (0x1EA9, 0x1EA8), + (0x1EAB, 0x1EAA), + (0x1EAD, 0x1EAC), + (0x1EAF, 0x1EAE), + (0x1EB1, 0x1EB0), + (0x1EB3, 0x1EB2), + (0x1EB5, 0x1EB4), + (0x1EB7, 0x1EB6), + (0x1EB9, 0x1EB8), + (0x1EBB, 0x1EBA), + (0x1EBD, 0x1EBC), + (0x1EBF, 0x1EBE), + (0x1EC1, 0x1EC0), + (0x1EC3, 0x1EC2), + (0x1EC5, 0x1EC4), + (0x1EC7, 0x1EC6), + (0x1EC9, 0x1EC8), + (0x1ECB, 0x1ECA), + (0x1ECD, 0x1ECC), + (0x1ECF, 0x1ECE), + (0x1ED1, 0x1ED0), + (0x1ED3, 0x1ED2), + (0x1ED5, 0x1ED4), + (0x1ED7, 0x1ED6), + (0x1ED9, 0x1ED8), + (0x1EDB, 0x1EDA), + (0x1EDD, 0x1EDC), + (0x1EDF, 0x1EDE), + (0x1EE1, 0x1EE0), + (0x1EE3, 0x1EE2), + (0x1EE5, 0x1EE4), + (0x1EE7, 0x1EE6), + (0x1EE9, 0x1EE8), + (0x1EEB, 0x1EEA), + (0x1EED, 0x1EEC), + (0x1EEF, 0x1EEE), + (0x1EF1, 0x1EF0), + (0x1EF3, 0x1EF2), + (0x1EF5, 0x1EF4), + (0x1EF7, 0x1EF6), + (0x1EF9, 0x1EF8), + (0x1EFB, 0x1EFA), + (0x1EFD, 0x1EFC), + (0x1EFF, 0x1EFE), + (0x1F00, 0x1F08), + (0x1F01, 0x1F09), + (0x1F02, 0x1F0A), + (0x1F03, 0x1F0B), + (0x1F04, 0x1F0C), + (0x1F05, 0x1F0D), + (0x1F06, 0x1F0E), + (0x1F07, 0x1F0F), + (0x1F10, 0x1F18), + (0x1F11, 0x1F19), + (0x1F12, 0x1F1A), + (0x1F13, 0x1F1B), + (0x1F14, 0x1F1C), + (0x1F15, 0x1F1D), + (0x1F20, 0x1F28), + (0x1F21, 0x1F29), + (0x1F22, 0x1F2A), + (0x1F23, 0x1F2B), + (0x1F24, 0x1F2C), + (0x1F25, 0x1F2D), + (0x1F26, 0x1F2E), + (0x1F27, 0x1F2F), + (0x1F30, 0x1F38), + (0x1F31, 0x1F39), + (0x1F32, 0x1F3A), + (0x1F33, 0x1F3B), + (0x1F34, 0x1F3C), + (0x1F35, 0x1F3D), + (0x1F36, 0x1F3E), + (0x1F37, 0x1F3F), + (0x1F40, 0x1F48), + (0x1F41, 0x1F49), + (0x1F42, 0x1F4A), + (0x1F43, 0x1F4B), + (0x1F44, 0x1F4C), + (0x1F45, 0x1F4D), + (0x1F51, 0x1F59), + (0x1F53, 0x1F5B), + (0x1F55, 0x1F5D), + (0x1F57, 0x1F5F), + (0x1F60, 0x1F68), + (0x1F61, 0x1F69), + (0x1F62, 0x1F6A), + (0x1F63, 0x1F6B), + (0x1F64, 0x1F6C), + (0x1F65, 0x1F6D), + (0x1F66, 0x1F6E), + (0x1F67, 0x1F6F), + (0x1F70, 0x1FBA), + (0x1F71, 0x1FBB), + (0x1F72, 0x1FC8), + (0x1F73, 0x1FC9), + (0x1F74, 0x1FCA), + (0x1F75, 0x1FCB), + (0x1F76, 0x1FDA), + (0x1F77, 0x1FDB), + (0x1F78, 0x1FF8), + (0x1F79, 0x1FF9), + (0x1F7A, 0x1FEA), + (0x1F7B, 0x1FEB), + (0x1F7C, 0x1FFA), + (0x1F7D, 0x1FFB), + (0x1F80, 0x1F88), + (0x1F81, 0x1F89), + (0x1F82, 0x1F8A), + (0x1F83, 0x1F8B), + (0x1F84, 0x1F8C), + (0x1F85, 0x1F8D), + (0x1F86, 0x1F8E), + (0x1F87, 0x1F8F), + (0x1F90, 0x1F98), + (0x1F91, 0x1F99), + (0x1F92, 0x1F9A), + (0x1F93, 0x1F9B), + (0x1F94, 0x1F9C), + (0x1F95, 0x1F9D), + (0x1F96, 0x1F9E), + (0x1F97, 0x1F9F), + (0x1FA0, 0x1FA8), + (0x1FA1, 0x1FA9), + (0x1FA2, 0x1FAA), + (0x1FA3, 0x1FAB), + (0x1FA4, 0x1FAC), + (0x1FA5, 0x1FAD), + (0x1FA6, 0x1FAE), + (0x1FA7, 0x1FAF), + (0x1FB0, 0x1FB8), + (0x1FB1, 0x1FB9), + (0x1FB3, 0x1FBC), + (0x1FC3, 0x1FCC), + (0x1FD0, 0x1FD8), + (0x1FD1, 0x1FD9), + (0x1FE0, 0x1FE8), + (0x1FE1, 0x1FE9), + (0x1FE5, 0x1FEC), + (0x1FF3, 0x1FFC), + (0x214E, 0x2132), + (0x2170, 0x2160), + (0x2171, 0x2161), + (0x2172, 0x2162), + (0x2173, 0x2163), + (0x2174, 0x2164), + (0x2175, 0x2165), + (0x2176, 0x2166), + (0x2177, 0x2167), + (0x2178, 0x2168), + (0x2179, 0x2169), + (0x217A, 0x216A), + (0x217B, 0x216B), + (0x217C, 0x216C), + (0x217D, 0x216D), + (0x217E, 0x216E), + (0x217F, 0x216F), + (0x2184, 0x2183), + (0x24D0, 0x24B6), + (0x24D1, 0x24B7), + (0x24D2, 0x24B8), + (0x24D3, 0x24B9), + (0x24D4, 0x24BA), + (0x24D5, 0x24BB), + (0x24D6, 0x24BC), + (0x24D7, 0x24BD), + (0x24D8, 0x24BE), + (0x24D9, 0x24BF), + (0x24DA, 0x24C0), + (0x24DB, 0x24C1), + (0x24DC, 0x24C2), + (0x24DD, 0x24C3), + (0x24DE, 0x24C4), + (0x24DF, 0x24C5), + (0x24E0, 0x24C6), + (0x24E1, 0x24C7), + (0x24E2, 0x24C8), + (0x24E3, 0x24C9), + (0x24E4, 0x24CA), + (0x24E5, 0x24CB), + (0x24E6, 0x24CC), + (0x24E7, 0x24CD), + (0x24E8, 0x24CE), + (0x24E9, 0x24CF), + (0x2C30, 0x2C00), + (0x2C31, 0x2C01), + (0x2C32, 0x2C02), + (0x2C33, 0x2C03), + (0x2C34, 0x2C04), + (0x2C35, 0x2C05), + (0x2C36, 0x2C06), + (0x2C37, 0x2C07), + (0x2C38, 0x2C08), + (0x2C39, 0x2C09), + (0x2C3A, 0x2C0A), + (0x2C3B, 0x2C0B), + (0x2C3C, 0x2C0C), + (0x2C3D, 0x2C0D), + (0x2C3E, 0x2C0E), + (0x2C3F, 0x2C0F), + (0x2C40, 0x2C10), + (0x2C41, 0x2C11), + (0x2C42, 0x2C12), + (0x2C43, 0x2C13), + (0x2C44, 0x2C14), + (0x2C45, 0x2C15), + (0x2C46, 0x2C16), + (0x2C47, 0x2C17), + (0x2C48, 0x2C18), + (0x2C49, 0x2C19), + (0x2C4A, 0x2C1A), + (0x2C4B, 0x2C1B), + (0x2C4C, 0x2C1C), + (0x2C4D, 0x2C1D), + (0x2C4E, 0x2C1E), + (0x2C4F, 0x2C1F), + (0x2C50, 0x2C20), + (0x2C51, 0x2C21), + (0x2C52, 0x2C22), + (0x2C53, 0x2C23), + (0x2C54, 0x2C24), + (0x2C55, 0x2C25), + (0x2C56, 0x2C26), + (0x2C57, 0x2C27), + (0x2C58, 0x2C28), + (0x2C59, 0x2C29), + (0x2C5A, 0x2C2A), + (0x2C5B, 0x2C2B), + (0x2C5C, 0x2C2C), + (0x2C5D, 0x2C2D), + (0x2C5E, 0x2C2E), + (0x2C5F, 0x2C2F), + (0x2C61, 0x2C60), + (0x2C65, 0x23A), + (0x2C66, 0x23E), + (0x2C68, 0x2C67), + (0x2C6A, 0x2C69), + (0x2C6C, 0x2C6B), + (0x2C73, 0x2C72), + (0x2C76, 0x2C75), + (0x2C81, 0x2C80), + (0x2C83, 0x2C82), + (0x2C85, 0x2C84), + (0x2C87, 0x2C86), + (0x2C89, 0x2C88), + (0x2C8B, 0x2C8A), + (0x2C8D, 0x2C8C), + (0x2C8F, 0x2C8E), + (0x2C91, 0x2C90), + (0x2C93, 0x2C92), + (0x2C95, 0x2C94), + (0x2C97, 0x2C96), + (0x2C99, 0x2C98), + (0x2C9B, 0x2C9A), + (0x2C9D, 0x2C9C), + (0x2C9F, 0x2C9E), + (0x2CA1, 0x2CA0), + (0x2CA3, 0x2CA2), + (0x2CA5, 0x2CA4), + (0x2CA7, 0x2CA6), + (0x2CA9, 0x2CA8), + (0x2CAB, 0x2CAA), + (0x2CAD, 0x2CAC), + (0x2CAF, 0x2CAE), + (0x2CB1, 0x2CB0), + (0x2CB3, 0x2CB2), + (0x2CB5, 0x2CB4), + (0x2CB7, 0x2CB6), + (0x2CB9, 0x2CB8), + (0x2CBB, 0x2CBA), + (0x2CBD, 0x2CBC), + (0x2CBF, 0x2CBE), + (0x2CC1, 0x2CC0), + (0x2CC3, 0x2CC2), + (0x2CC5, 0x2CC4), + (0x2CC7, 0x2CC6), + (0x2CC9, 0x2CC8), + (0x2CCB, 0x2CCA), + (0x2CCD, 0x2CCC), + (0x2CCF, 0x2CCE), + (0x2CD1, 0x2CD0), + (0x2CD3, 0x2CD2), + (0x2CD5, 0x2CD4), + (0x2CD7, 0x2CD6), + (0x2CD9, 0x2CD8), + (0x2CDB, 0x2CDA), + (0x2CDD, 0x2CDC), + (0x2CDF, 0x2CDE), + (0x2CE1, 0x2CE0), + (0x2CE3, 0x2CE2), + (0x2CEC, 0x2CEB), + (0x2CEE, 0x2CED), + (0x2CF3, 0x2CF2), + (0x2D00, 0x10A0), + (0x2D01, 0x10A1), + (0x2D02, 0x10A2), + (0x2D03, 0x10A3), + (0x2D04, 0x10A4), + (0x2D05, 0x10A5), + (0x2D06, 0x10A6), + (0x2D07, 0x10A7), + (0x2D08, 0x10A8), + (0x2D09, 0x10A9), + (0x2D0A, 0x10AA), + (0x2D0B, 0x10AB), + (0x2D0C, 0x10AC), + (0x2D0D, 0x10AD), + (0x2D0E, 0x10AE), + (0x2D0F, 0x10AF), + (0x2D10, 0x10B0), + (0x2D11, 0x10B1), + (0x2D12, 0x10B2), + (0x2D13, 0x10B3), + (0x2D14, 0x10B4), + (0x2D15, 0x10B5), + (0x2D16, 0x10B6), + (0x2D17, 0x10B7), + (0x2D18, 0x10B8), + (0x2D19, 0x10B9), + (0x2D1A, 0x10BA), + (0x2D1B, 0x10BB), + (0x2D1C, 0x10BC), + (0x2D1D, 0x10BD), + (0x2D1E, 0x10BE), + (0x2D1F, 0x10BF), + (0x2D20, 0x10C0), + (0x2D21, 0x10C1), + (0x2D22, 0x10C2), + (0x2D23, 0x10C3), + (0x2D24, 0x10C4), + (0x2D25, 0x10C5), + (0x2D27, 0x10C7), + (0x2D2D, 0x10CD), + (0xA641, 0xA640), + (0xA643, 0xA642), + (0xA645, 0xA644), + (0xA647, 0xA646), + (0xA649, 0xA648), + (0xA64B, 0x1C88), + (0xA64B, 0xA64A), + (0xA64D, 0xA64C), + (0xA64F, 0xA64E), + (0xA651, 0xA650), + (0xA653, 0xA652), + (0xA655, 0xA654), + (0xA657, 0xA656), + (0xA659, 0xA658), + (0xA65B, 0xA65A), + (0xA65D, 0xA65C), + (0xA65F, 0xA65E), + (0xA661, 0xA660), + (0xA663, 0xA662), + (0xA665, 0xA664), + (0xA667, 0xA666), + (0xA669, 0xA668), + (0xA66B, 0xA66A), + (0xA66D, 0xA66C), + (0xA681, 0xA680), + (0xA683, 0xA682), + (0xA685, 0xA684), + (0xA687, 0xA686), + (0xA689, 0xA688), + (0xA68B, 0xA68A), + (0xA68D, 0xA68C), + (0xA68F, 0xA68E), + (0xA691, 0xA690), + (0xA693, 0xA692), + (0xA695, 0xA694), + (0xA697, 0xA696), + (0xA699, 0xA698), + (0xA69B, 0xA69A), + (0xA723, 0xA722), + (0xA725, 0xA724), + (0xA727, 0xA726), + (0xA729, 0xA728), + (0xA72B, 0xA72A), + (0xA72D, 0xA72C), + (0xA72F, 0xA72E), + (0xA733, 0xA732), + (0xA735, 0xA734), + (0xA737, 0xA736), + (0xA739, 0xA738), + (0xA73B, 0xA73A), + (0xA73D, 0xA73C), + (0xA73F, 0xA73E), + (0xA741, 0xA740), + (0xA743, 0xA742), + (0xA745, 0xA744), + (0xA747, 0xA746), + (0xA749, 0xA748), + (0xA74B, 0xA74A), + (0xA74D, 0xA74C), + (0xA74F, 0xA74E), + (0xA751, 0xA750), + (0xA753, 0xA752), + (0xA755, 0xA754), + (0xA757, 0xA756), + (0xA759, 0xA758), + (0xA75B, 0xA75A), + (0xA75D, 0xA75C), + (0xA75F, 0xA75E), + (0xA761, 0xA760), + (0xA763, 0xA762), + (0xA765, 0xA764), + (0xA767, 0xA766), + (0xA769, 0xA768), + (0xA76B, 0xA76A), + (0xA76D, 0xA76C), + (0xA76F, 0xA76E), + (0xA77A, 0xA779), + (0xA77C, 0xA77B), + (0xA77F, 0xA77E), + (0xA781, 0xA780), + (0xA783, 0xA782), + (0xA785, 0xA784), + (0xA787, 0xA786), + (0xA78C, 0xA78B), + (0xA791, 0xA790), + (0xA793, 0xA792), + (0xA794, 0xA7C4), + (0xA797, 0xA796), + (0xA799, 0xA798), + (0xA79B, 0xA79A), + (0xA79D, 0xA79C), + (0xA79F, 0xA79E), + (0xA7A1, 0xA7A0), + (0xA7A3, 0xA7A2), + (0xA7A5, 0xA7A4), + (0xA7A7, 0xA7A6), + (0xA7A9, 0xA7A8), + (0xA7B5, 0xA7B4), + (0xA7B7, 0xA7B6), + (0xA7B9, 0xA7B8), + (0xA7BB, 0xA7BA), + (0xA7BD, 0xA7BC), + (0xA7BF, 0xA7BE), + (0xA7C1, 0xA7C0), + (0xA7C3, 0xA7C2), + (0xA7C8, 0xA7C7), + (0xA7CA, 0xA7C9), + (0xA7CD, 0xA7CC), + (0xA7CF, 0xA7CE), + (0xA7D1, 0xA7D0), + (0xA7D3, 0xA7D2), + (0xA7D5, 0xA7D4), + (0xA7D7, 0xA7D6), + (0xA7D9, 0xA7D8), + (0xA7DB, 0xA7DA), + (0xA7F6, 0xA7F5), + (0xAB4B, 0xAB6C), + (0xAB4C, 0xAB6D), + (0xAB53, 0xA7B3), + (0xFB06, 0xFB05), + (0xFF41, 0xFF21), + (0xFF42, 0xFF22), + (0xFF43, 0xFF23), + (0xFF44, 0xFF24), + (0xFF45, 0xFF25), + (0xFF46, 0xFF26), + (0xFF47, 0xFF27), + (0xFF48, 0xFF28), + (0xFF49, 0xFF29), + (0xFF4A, 0xFF2A), + (0xFF4B, 0xFF2B), + (0xFF4C, 0xFF2C), + (0xFF4D, 0xFF2D), + (0xFF4E, 0xFF2E), + (0xFF4F, 0xFF2F), + (0xFF50, 0xFF30), + (0xFF51, 0xFF31), + (0xFF52, 0xFF32), + (0xFF53, 0xFF33), + (0xFF54, 0xFF34), + (0xFF55, 0xFF35), + (0xFF56, 0xFF36), + (0xFF57, 0xFF37), + (0xFF58, 0xFF38), + (0xFF59, 0xFF39), + (0xFF5A, 0xFF3A), + (0x10428, 0x10400), + (0x10429, 0x10401), + (0x1042A, 0x10402), + (0x1042B, 0x10403), + (0x1042C, 0x10404), + (0x1042D, 0x10405), + (0x1042E, 0x10406), + (0x1042F, 0x10407), + (0x10430, 0x10408), + (0x10431, 0x10409), + (0x10432, 0x1040A), + (0x10433, 0x1040B), + (0x10434, 0x1040C), + (0x10435, 0x1040D), + (0x10436, 0x1040E), + (0x10437, 0x1040F), + (0x10438, 0x10410), + (0x10439, 0x10411), + (0x1043A, 0x10412), + (0x1043B, 0x10413), + (0x1043C, 0x10414), + (0x1043D, 0x10415), + (0x1043E, 0x10416), + (0x1043F, 0x10417), + (0x10440, 0x10418), + (0x10441, 0x10419), + (0x10442, 0x1041A), + (0x10443, 0x1041B), + (0x10444, 0x1041C), + (0x10445, 0x1041D), + (0x10446, 0x1041E), + (0x10447, 0x1041F), + (0x10448, 0x10420), + (0x10449, 0x10421), + (0x1044A, 0x10422), + (0x1044B, 0x10423), + (0x1044C, 0x10424), + (0x1044D, 0x10425), + (0x1044E, 0x10426), + (0x1044F, 0x10427), + (0x104D8, 0x104B0), + (0x104D9, 0x104B1), + (0x104DA, 0x104B2), + (0x104DB, 0x104B3), + (0x104DC, 0x104B4), + (0x104DD, 0x104B5), + (0x104DE, 0x104B6), + (0x104DF, 0x104B7), + (0x104E0, 0x104B8), + (0x104E1, 0x104B9), + (0x104E2, 0x104BA), + (0x104E3, 0x104BB), + (0x104E4, 0x104BC), + (0x104E5, 0x104BD), + (0x104E6, 0x104BE), + (0x104E7, 0x104BF), + (0x104E8, 0x104C0), + (0x104E9, 0x104C1), + (0x104EA, 0x104C2), + (0x104EB, 0x104C3), + (0x104EC, 0x104C4), + (0x104ED, 0x104C5), + (0x104EE, 0x104C6), + (0x104EF, 0x104C7), + (0x104F0, 0x104C8), + (0x104F1, 0x104C9), + (0x104F2, 0x104CA), + (0x104F3, 0x104CB), + (0x104F4, 0x104CC), + (0x104F5, 0x104CD), + (0x104F6, 0x104CE), + (0x104F7, 0x104CF), + (0x104F8, 0x104D0), + (0x104F9, 0x104D1), + (0x104FA, 0x104D2), + (0x104FB, 0x104D3), + (0x10597, 0x10570), + (0x10598, 0x10571), + (0x10599, 0x10572), + (0x1059A, 0x10573), + (0x1059B, 0x10574), + (0x1059C, 0x10575), + (0x1059D, 0x10576), + (0x1059E, 0x10577), + (0x1059F, 0x10578), + (0x105A0, 0x10579), + (0x105A1, 0x1057A), + (0x105A3, 0x1057C), + (0x105A4, 0x1057D), + (0x105A5, 0x1057E), + (0x105A6, 0x1057F), + (0x105A7, 0x10580), + (0x105A8, 0x10581), + (0x105A9, 0x10582), + (0x105AA, 0x10583), + (0x105AB, 0x10584), + (0x105AC, 0x10585), + (0x105AD, 0x10586), + (0x105AE, 0x10587), + (0x105AF, 0x10588), + (0x105B0, 0x10589), + (0x105B1, 0x1058A), + (0x105B3, 0x1058C), + (0x105B4, 0x1058D), + (0x105B5, 0x1058E), + (0x105B6, 0x1058F), + (0x105B7, 0x10590), + (0x105B8, 0x10591), + (0x105B9, 0x10592), + (0x105BB, 0x10594), + (0x105BC, 0x10595), + (0x10CC0, 0x10C80), + (0x10CC1, 0x10C81), + (0x10CC2, 0x10C82), + (0x10CC3, 0x10C83), + (0x10CC4, 0x10C84), + (0x10CC5, 0x10C85), + (0x10CC6, 0x10C86), + (0x10CC7, 0x10C87), + (0x10CC8, 0x10C88), + (0x10CC9, 0x10C89), + (0x10CCA, 0x10C8A), + (0x10CCB, 0x10C8B), + (0x10CCC, 0x10C8C), + (0x10CCD, 0x10C8D), + (0x10CCE, 0x10C8E), + (0x10CCF, 0x10C8F), + (0x10CD0, 0x10C90), + (0x10CD1, 0x10C91), + (0x10CD2, 0x10C92), + (0x10CD3, 0x10C93), + (0x10CD4, 0x10C94), + (0x10CD5, 0x10C95), + (0x10CD6, 0x10C96), + (0x10CD7, 0x10C97), + (0x10CD8, 0x10C98), + (0x10CD9, 0x10C99), + (0x10CDA, 0x10C9A), + (0x10CDB, 0x10C9B), + (0x10CDC, 0x10C9C), + (0x10CDD, 0x10C9D), + (0x10CDE, 0x10C9E), + (0x10CDF, 0x10C9F), + (0x10CE0, 0x10CA0), + (0x10CE1, 0x10CA1), + (0x10CE2, 0x10CA2), + (0x10CE3, 0x10CA3), + (0x10CE4, 0x10CA4), + (0x10CE5, 0x10CA5), + (0x10CE6, 0x10CA6), + (0x10CE7, 0x10CA7), + (0x10CE8, 0x10CA8), + (0x10CE9, 0x10CA9), + (0x10CEA, 0x10CAA), + (0x10CEB, 0x10CAB), + (0x10CEC, 0x10CAC), + (0x10CED, 0x10CAD), + (0x10CEE, 0x10CAE), + (0x10CEF, 0x10CAF), + (0x10CF0, 0x10CB0), + (0x10CF1, 0x10CB1), + (0x10CF2, 0x10CB2), + (0x10D70, 0x10D50), + (0x10D71, 0x10D51), + (0x10D72, 0x10D52), + (0x10D73, 0x10D53), + (0x10D74, 0x10D54), + (0x10D75, 0x10D55), + (0x10D76, 0x10D56), + (0x10D77, 0x10D57), + (0x10D78, 0x10D58), + (0x10D79, 0x10D59), + (0x10D7A, 0x10D5A), + (0x10D7B, 0x10D5B), + (0x10D7C, 0x10D5C), + (0x10D7D, 0x10D5D), + (0x10D7E, 0x10D5E), + (0x10D7F, 0x10D5F), + (0x10D80, 0x10D60), + (0x10D81, 0x10D61), + (0x10D82, 0x10D62), + (0x10D83, 0x10D63), + (0x10D84, 0x10D64), + (0x10D85, 0x10D65), + (0x118C0, 0x118A0), + (0x118C1, 0x118A1), + (0x118C2, 0x118A2), + (0x118C3, 0x118A3), + (0x118C4, 0x118A4), + (0x118C5, 0x118A5), + (0x118C6, 0x118A6), + (0x118C7, 0x118A7), + (0x118C8, 0x118A8), + (0x118C9, 0x118A9), + (0x118CA, 0x118AA), + (0x118CB, 0x118AB), + (0x118CC, 0x118AC), + (0x118CD, 0x118AD), + (0x118CE, 0x118AE), + (0x118CF, 0x118AF), + (0x118D0, 0x118B0), + (0x118D1, 0x118B1), + (0x118D2, 0x118B2), + (0x118D3, 0x118B3), + (0x118D4, 0x118B4), + (0x118D5, 0x118B5), + (0x118D6, 0x118B6), + (0x118D7, 0x118B7), + (0x118D8, 0x118B8), + (0x118D9, 0x118B9), + (0x118DA, 0x118BA), + (0x118DB, 0x118BB), + (0x118DC, 0x118BC), + (0x118DD, 0x118BD), + (0x118DE, 0x118BE), + (0x118DF, 0x118BF), + (0x16E60, 0x16E40), + (0x16E61, 0x16E41), + (0x16E62, 0x16E42), + (0x16E63, 0x16E43), + (0x16E64, 0x16E44), + (0x16E65, 0x16E45), + (0x16E66, 0x16E46), + (0x16E67, 0x16E47), + (0x16E68, 0x16E48), + (0x16E69, 0x16E49), + (0x16E6A, 0x16E4A), + (0x16E6B, 0x16E4B), + (0x16E6C, 0x16E4C), + (0x16E6D, 0x16E4D), + (0x16E6E, 0x16E4E), + (0x16E6F, 0x16E4F), + (0x16E70, 0x16E50), + (0x16E71, 0x16E51), + (0x16E72, 0x16E52), + (0x16E73, 0x16E53), + (0x16E74, 0x16E54), + (0x16E75, 0x16E55), + (0x16E76, 0x16E56), + (0x16E77, 0x16E57), + (0x16E78, 0x16E58), + (0x16E79, 0x16E59), + (0x16E7A, 0x16E5A), + (0x16E7B, 0x16E5B), + (0x16E7C, 0x16E5C), + (0x16E7D, 0x16E5D), + (0x16E7E, 0x16E5E), + (0x16E7F, 0x16E5F), + (0x16EBB, 0x16EA0), + (0x16EBC, 0x16EA1), + (0x16EBD, 0x16EA2), + (0x16EBE, 0x16EA3), + (0x16EBF, 0x16EA4), + (0x16EC0, 0x16EA5), + (0x16EC1, 0x16EA6), + (0x16EC2, 0x16EA7), + (0x16EC3, 0x16EA8), + (0x16EC4, 0x16EA9), + (0x16EC5, 0x16EAA), + (0x16EC6, 0x16EAB), + (0x16EC7, 0x16EAC), + (0x16EC8, 0x16EAD), + (0x16EC9, 0x16EAE), + (0x16ECA, 0x16EAF), + (0x16ECB, 0x16EB0), + (0x16ECC, 0x16EB1), + (0x16ECD, 0x16EB2), + (0x16ECE, 0x16EB3), + (0x16ECF, 0x16EB4), + (0x16ED0, 0x16EB5), + (0x16ED1, 0x16EB6), + (0x16ED2, 0x16EB7), + (0x16ED3, 0x16EB8), + (0x1DF41, 0x1DF40), + (0x1DF49, 0x1DF48), + (0x1DF4B, 0x1DF4A), + (0x1DF4E, 0x1DF4D), + (0x1DF52, 0x1DF51), + (0x1DF69, 0x1DF68), + (0x1DF6B, 0x1DF6A), + (0x1DF6D, 0x1DF6C), + (0x1DF6F, 0x1DF6E), + (0x1DF73, 0x1DF72), + (0x1DF75, 0x1DF74), + (0x1DF77, 0x1DF76), + (0x1DF79, 0x1DF78), + (0x1DF7B, 0x1DF7A), + (0x1DF7D, 0x1DF7C), + (0x1DF7F, 0x1DF7E), + (0x1E922, 0x1E900), + (0x1E923, 0x1E901), + (0x1E924, 0x1E902), + (0x1E925, 0x1E903), + (0x1E926, 0x1E904), + (0x1E927, 0x1E905), + (0x1E928, 0x1E906), + (0x1E929, 0x1E907), + (0x1E92A, 0x1E908), + (0x1E92B, 0x1E909), + (0x1E92C, 0x1E90A), + (0x1E92D, 0x1E90B), + (0x1E92E, 0x1E90C), + (0x1E92F, 0x1E90D), + (0x1E930, 0x1E90E), + (0x1E931, 0x1E90F), + (0x1E932, 0x1E910), + (0x1E933, 0x1E911), + (0x1E934, 0x1E912), + (0x1E935, 0x1E913), + (0x1E936, 0x1E914), + (0x1E937, 0x1E915), + (0x1E938, 0x1E916), + (0x1E939, 0x1E917), + (0x1E93A, 0x1E918), + (0x1E93B, 0x1E919), + (0x1E93C, 0x1E91A), + (0x1E93D, 0x1E91B), + (0x1E93E, 0x1E91C), + (0x1E93F, 0x1E91D), + (0x1E940, 0x1E91E), + (0x1E941, 0x1E91F), + (0x1E942, 0x1E920), + (0x1E943, 0x1E921), +]; + +/// toUppercase of a BMP code point where it is one different BMP code point, and not ASCII for a non-ASCII argument: code point, upper case, sorted by code point. +pub static UPPER: &[(u32, u32)] = &[ + (0x61, 0x41), + (0x62, 0x42), + (0x63, 0x43), + (0x64, 0x44), + (0x65, 0x45), + (0x66, 0x46), + (0x67, 0x47), + (0x68, 0x48), + (0x69, 0x49), + (0x6A, 0x4A), + (0x6B, 0x4B), + (0x6C, 0x4C), + (0x6D, 0x4D), + (0x6E, 0x4E), + (0x6F, 0x4F), + (0x70, 0x50), + (0x71, 0x51), + (0x72, 0x52), + (0x73, 0x53), + (0x74, 0x54), + (0x75, 0x55), + (0x76, 0x56), + (0x77, 0x57), + (0x78, 0x58), + (0x79, 0x59), + (0x7A, 0x5A), + (0xB5, 0x39C), + (0xE0, 0xC0), + (0xE1, 0xC1), + (0xE2, 0xC2), + (0xE3, 0xC3), + (0xE4, 0xC4), + (0xE5, 0xC5), + (0xE6, 0xC6), + (0xE7, 0xC7), + (0xE8, 0xC8), + (0xE9, 0xC9), + (0xEA, 0xCA), + (0xEB, 0xCB), + (0xEC, 0xCC), + (0xED, 0xCD), + (0xEE, 0xCE), + (0xEF, 0xCF), + (0xF0, 0xD0), + (0xF1, 0xD1), + (0xF2, 0xD2), + (0xF3, 0xD3), + (0xF4, 0xD4), + (0xF5, 0xD5), + (0xF6, 0xD6), + (0xF8, 0xD8), + (0xF9, 0xD9), + (0xFA, 0xDA), + (0xFB, 0xDB), + (0xFC, 0xDC), + (0xFD, 0xDD), + (0xFE, 0xDE), + (0xFF, 0x178), + (0x101, 0x100), + (0x103, 0x102), + (0x105, 0x104), + (0x107, 0x106), + (0x109, 0x108), + (0x10B, 0x10A), + (0x10D, 0x10C), + (0x10F, 0x10E), + (0x111, 0x110), + (0x113, 0x112), + (0x115, 0x114), + (0x117, 0x116), + (0x119, 0x118), + (0x11B, 0x11A), + (0x11D, 0x11C), + (0x11F, 0x11E), + (0x121, 0x120), + (0x123, 0x122), + (0x125, 0x124), + (0x127, 0x126), + (0x129, 0x128), + (0x12B, 0x12A), + (0x12D, 0x12C), + (0x12F, 0x12E), + (0x133, 0x132), + (0x135, 0x134), + (0x137, 0x136), + (0x13A, 0x139), + (0x13C, 0x13B), + (0x13E, 0x13D), + (0x140, 0x13F), + (0x142, 0x141), + (0x144, 0x143), + (0x146, 0x145), + (0x148, 0x147), + (0x14B, 0x14A), + (0x14D, 0x14C), + (0x14F, 0x14E), + (0x151, 0x150), + (0x153, 0x152), + (0x155, 0x154), + (0x157, 0x156), + (0x159, 0x158), + (0x15B, 0x15A), + (0x15D, 0x15C), + (0x15F, 0x15E), + (0x161, 0x160), + (0x163, 0x162), + (0x165, 0x164), + (0x167, 0x166), + (0x169, 0x168), + (0x16B, 0x16A), + (0x16D, 0x16C), + (0x16F, 0x16E), + (0x171, 0x170), + (0x173, 0x172), + (0x175, 0x174), + (0x177, 0x176), + (0x17A, 0x179), + (0x17C, 0x17B), + (0x17E, 0x17D), + (0x180, 0x243), + (0x183, 0x182), + (0x185, 0x184), + (0x188, 0x187), + (0x18C, 0x18B), + (0x192, 0x191), + (0x195, 0x1F6), + (0x199, 0x198), + (0x19A, 0x23D), + (0x19B, 0xA7DC), + (0x19E, 0x220), + (0x1A1, 0x1A0), + (0x1A3, 0x1A2), + (0x1A5, 0x1A4), + (0x1A8, 0x1A7), + (0x1AD, 0x1AC), + (0x1B0, 0x1AF), + (0x1B4, 0x1B3), + (0x1B6, 0x1B5), + (0x1B9, 0x1B8), + (0x1BD, 0x1BC), + (0x1BF, 0x1F7), + (0x1C5, 0x1C4), + (0x1C6, 0x1C4), + (0x1C8, 0x1C7), + (0x1C9, 0x1C7), + (0x1CB, 0x1CA), + (0x1CC, 0x1CA), + (0x1CE, 0x1CD), + (0x1D0, 0x1CF), + (0x1D2, 0x1D1), + (0x1D4, 0x1D3), + (0x1D6, 0x1D5), + (0x1D8, 0x1D7), + (0x1DA, 0x1D9), + (0x1DC, 0x1DB), + (0x1DD, 0x18E), + (0x1DF, 0x1DE), + (0x1E1, 0x1E0), + (0x1E3, 0x1E2), + (0x1E5, 0x1E4), + (0x1E7, 0x1E6), + (0x1E9, 0x1E8), + (0x1EB, 0x1EA), + (0x1ED, 0x1EC), + (0x1EF, 0x1EE), + (0x1F2, 0x1F1), + (0x1F3, 0x1F1), + (0x1F5, 0x1F4), + (0x1F9, 0x1F8), + (0x1FB, 0x1FA), + (0x1FD, 0x1FC), + (0x1FF, 0x1FE), + (0x201, 0x200), + (0x203, 0x202), + (0x205, 0x204), + (0x207, 0x206), + (0x209, 0x208), + (0x20B, 0x20A), + (0x20D, 0x20C), + (0x20F, 0x20E), + (0x211, 0x210), + (0x213, 0x212), + (0x215, 0x214), + (0x217, 0x216), + (0x219, 0x218), + (0x21B, 0x21A), + (0x21D, 0x21C), + (0x21F, 0x21E), + (0x223, 0x222), + (0x225, 0x224), + (0x227, 0x226), + (0x229, 0x228), + (0x22B, 0x22A), + (0x22D, 0x22C), + (0x22F, 0x22E), + (0x231, 0x230), + (0x233, 0x232), + (0x23C, 0x23B), + (0x23F, 0x2C7E), + (0x240, 0x2C7F), + (0x242, 0x241), + (0x247, 0x246), + (0x249, 0x248), + (0x24B, 0x24A), + (0x24D, 0x24C), + (0x24F, 0x24E), + (0x250, 0x2C6F), + (0x251, 0x2C6D), + (0x252, 0x2C70), + (0x253, 0x181), + (0x254, 0x186), + (0x256, 0x189), + (0x257, 0x18A), + (0x259, 0x18F), + (0x25B, 0x190), + (0x25C, 0xA7AB), + (0x260, 0x193), + (0x261, 0xA7AC), + (0x263, 0x194), + (0x264, 0xA7CB), + (0x265, 0xA78D), + (0x266, 0xA7AA), + (0x268, 0x197), + (0x269, 0x196), + (0x26A, 0xA7AE), + (0x26B, 0x2C62), + (0x26C, 0xA7AD), + (0x26F, 0x19C), + (0x271, 0x2C6E), + (0x272, 0x19D), + (0x275, 0x19F), + (0x277, 0xA7DD), + (0x27C, 0xA7E2), + (0x27D, 0x2C64), + (0x280, 0x1A6), + (0x282, 0xA7C5), + (0x283, 0x1A9), + (0x287, 0xA7B1), + (0x288, 0x1AE), + (0x289, 0x244), + (0x28A, 0x1B1), + (0x28B, 0x1B2), + (0x28C, 0x245), + (0x292, 0x1B7), + (0x29D, 0xA7B2), + (0x29E, 0xA7B0), + (0x345, 0x399), + (0x371, 0x370), + (0x373, 0x372), + (0x377, 0x376), + (0x37B, 0x3FD), + (0x37C, 0x3FE), + (0x37D, 0x3FF), + (0x3AC, 0x386), + (0x3AD, 0x388), + (0x3AE, 0x389), + (0x3AF, 0x38A), + (0x3B1, 0x391), + (0x3B2, 0x392), + (0x3B3, 0x393), + (0x3B4, 0x394), + (0x3B5, 0x395), + (0x3B6, 0x396), + (0x3B7, 0x397), + (0x3B8, 0x398), + (0x3B9, 0x399), + (0x3BA, 0x39A), + (0x3BB, 0x39B), + (0x3BC, 0x39C), + (0x3BD, 0x39D), + (0x3BE, 0x39E), + (0x3BF, 0x39F), + (0x3C0, 0x3A0), + (0x3C1, 0x3A1), + (0x3C2, 0x3A3), + (0x3C3, 0x3A3), + (0x3C4, 0x3A4), + (0x3C5, 0x3A5), + (0x3C6, 0x3A6), + (0x3C7, 0x3A7), + (0x3C8, 0x3A8), + (0x3C9, 0x3A9), + (0x3CA, 0x3AA), + (0x3CB, 0x3AB), + (0x3CC, 0x38C), + (0x3CD, 0x38E), + (0x3CE, 0x38F), + (0x3D0, 0x392), + (0x3D1, 0x398), + (0x3D5, 0x3A6), + (0x3D6, 0x3A0), + (0x3D7, 0x3CF), + (0x3D9, 0x3D8), + (0x3DB, 0x3DA), + (0x3DD, 0x3DC), + (0x3DF, 0x3DE), + (0x3E1, 0x3E0), + (0x3E3, 0x3E2), + (0x3E5, 0x3E4), + (0x3E7, 0x3E6), + (0x3E9, 0x3E8), + (0x3EB, 0x3EA), + (0x3ED, 0x3EC), + (0x3EF, 0x3EE), + (0x3F0, 0x39A), + (0x3F1, 0x3A1), + (0x3F2, 0x3F9), + (0x3F3, 0x37F), + (0x3F5, 0x395), + (0x3F8, 0x3F7), + (0x3FB, 0x3FA), + (0x430, 0x410), + (0x431, 0x411), + (0x432, 0x412), + (0x433, 0x413), + (0x434, 0x414), + (0x435, 0x415), + (0x436, 0x416), + (0x437, 0x417), + (0x438, 0x418), + (0x439, 0x419), + (0x43A, 0x41A), + (0x43B, 0x41B), + (0x43C, 0x41C), + (0x43D, 0x41D), + (0x43E, 0x41E), + (0x43F, 0x41F), + (0x440, 0x420), + (0x441, 0x421), + (0x442, 0x422), + (0x443, 0x423), + (0x444, 0x424), + (0x445, 0x425), + (0x446, 0x426), + (0x447, 0x427), + (0x448, 0x428), + (0x449, 0x429), + (0x44A, 0x42A), + (0x44B, 0x42B), + (0x44C, 0x42C), + (0x44D, 0x42D), + (0x44E, 0x42E), + (0x44F, 0x42F), + (0x450, 0x400), + (0x451, 0x401), + (0x452, 0x402), + (0x453, 0x403), + (0x454, 0x404), + (0x455, 0x405), + (0x456, 0x406), + (0x457, 0x407), + (0x458, 0x408), + (0x459, 0x409), + (0x45A, 0x40A), + (0x45B, 0x40B), + (0x45C, 0x40C), + (0x45D, 0x40D), + (0x45E, 0x40E), + (0x45F, 0x40F), + (0x461, 0x460), + (0x463, 0x462), + (0x465, 0x464), + (0x467, 0x466), + (0x469, 0x468), + (0x46B, 0x46A), + (0x46D, 0x46C), + (0x46F, 0x46E), + (0x471, 0x470), + (0x473, 0x472), + (0x475, 0x474), + (0x477, 0x476), + (0x479, 0x478), + (0x47B, 0x47A), + (0x47D, 0x47C), + (0x47F, 0x47E), + (0x481, 0x480), + (0x48B, 0x48A), + (0x48D, 0x48C), + (0x48F, 0x48E), + (0x491, 0x490), + (0x493, 0x492), + (0x495, 0x494), + (0x497, 0x496), + (0x499, 0x498), + (0x49B, 0x49A), + (0x49D, 0x49C), + (0x49F, 0x49E), + (0x4A1, 0x4A0), + (0x4A3, 0x4A2), + (0x4A5, 0x4A4), + (0x4A7, 0x4A6), + (0x4A9, 0x4A8), + (0x4AB, 0x4AA), + (0x4AD, 0x4AC), + (0x4AF, 0x4AE), + (0x4B1, 0x4B0), + (0x4B3, 0x4B2), + (0x4B5, 0x4B4), + (0x4B7, 0x4B6), + (0x4B9, 0x4B8), + (0x4BB, 0x4BA), + (0x4BD, 0x4BC), + (0x4BF, 0x4BE), + (0x4C2, 0x4C1), + (0x4C4, 0x4C3), + (0x4C6, 0x4C5), + (0x4C8, 0x4C7), + (0x4CA, 0x4C9), + (0x4CC, 0x4CB), + (0x4CE, 0x4CD), + (0x4CF, 0x4C0), + (0x4D1, 0x4D0), + (0x4D3, 0x4D2), + (0x4D5, 0x4D4), + (0x4D7, 0x4D6), + (0x4D9, 0x4D8), + (0x4DB, 0x4DA), + (0x4DD, 0x4DC), + (0x4DF, 0x4DE), + (0x4E1, 0x4E0), + (0x4E3, 0x4E2), + (0x4E5, 0x4E4), + (0x4E7, 0x4E6), + (0x4E9, 0x4E8), + (0x4EB, 0x4EA), + (0x4ED, 0x4EC), + (0x4EF, 0x4EE), + (0x4F1, 0x4F0), + (0x4F3, 0x4F2), + (0x4F5, 0x4F4), + (0x4F7, 0x4F6), + (0x4F9, 0x4F8), + (0x4FB, 0x4FA), + (0x4FD, 0x4FC), + (0x4FF, 0x4FE), + (0x501, 0x500), + (0x503, 0x502), + (0x505, 0x504), + (0x507, 0x506), + (0x509, 0x508), + (0x50B, 0x50A), + (0x50D, 0x50C), + (0x50F, 0x50E), + (0x511, 0x510), + (0x513, 0x512), + (0x515, 0x514), + (0x517, 0x516), + (0x519, 0x518), + (0x51B, 0x51A), + (0x51D, 0x51C), + (0x51F, 0x51E), + (0x521, 0x520), + (0x523, 0x522), + (0x525, 0x524), + (0x527, 0x526), + (0x529, 0x528), + (0x52B, 0x52A), + (0x52D, 0x52C), + (0x52F, 0x52E), + (0x561, 0x531), + (0x562, 0x532), + (0x563, 0x533), + (0x564, 0x534), + (0x565, 0x535), + (0x566, 0x536), + (0x567, 0x537), + (0x568, 0x538), + (0x569, 0x539), + (0x56A, 0x53A), + (0x56B, 0x53B), + (0x56C, 0x53C), + (0x56D, 0x53D), + (0x56E, 0x53E), + (0x56F, 0x53F), + (0x570, 0x540), + (0x571, 0x541), + (0x572, 0x542), + (0x573, 0x543), + (0x574, 0x544), + (0x575, 0x545), + (0x576, 0x546), + (0x577, 0x547), + (0x578, 0x548), + (0x579, 0x549), + (0x57A, 0x54A), + (0x57B, 0x54B), + (0x57C, 0x54C), + (0x57D, 0x54D), + (0x57E, 0x54E), + (0x57F, 0x54F), + (0x580, 0x550), + (0x581, 0x551), + (0x582, 0x552), + (0x583, 0x553), + (0x584, 0x554), + (0x585, 0x555), + (0x586, 0x556), + (0x10D0, 0x1C90), + (0x10D1, 0x1C91), + (0x10D2, 0x1C92), + (0x10D3, 0x1C93), + (0x10D4, 0x1C94), + (0x10D5, 0x1C95), + (0x10D6, 0x1C96), + (0x10D7, 0x1C97), + (0x10D8, 0x1C98), + (0x10D9, 0x1C99), + (0x10DA, 0x1C9A), + (0x10DB, 0x1C9B), + (0x10DC, 0x1C9C), + (0x10DD, 0x1C9D), + (0x10DE, 0x1C9E), + (0x10DF, 0x1C9F), + (0x10E0, 0x1CA0), + (0x10E1, 0x1CA1), + (0x10E2, 0x1CA2), + (0x10E3, 0x1CA3), + (0x10E4, 0x1CA4), + (0x10E5, 0x1CA5), + (0x10E6, 0x1CA6), + (0x10E7, 0x1CA7), + (0x10E8, 0x1CA8), + (0x10E9, 0x1CA9), + (0x10EA, 0x1CAA), + (0x10EB, 0x1CAB), + (0x10EC, 0x1CAC), + (0x10ED, 0x1CAD), + (0x10EE, 0x1CAE), + (0x10EF, 0x1CAF), + (0x10F0, 0x1CB0), + (0x10F1, 0x1CB1), + (0x10F2, 0x1CB2), + (0x10F3, 0x1CB3), + (0x10F4, 0x1CB4), + (0x10F5, 0x1CB5), + (0x10F6, 0x1CB6), + (0x10F7, 0x1CB7), + (0x10F8, 0x1CB8), + (0x10F9, 0x1CB9), + (0x10FA, 0x1CBA), + (0x10FD, 0x1CBD), + (0x10FE, 0x1CBE), + (0x10FF, 0x1CBF), + (0x13F8, 0x13F0), + (0x13F9, 0x13F1), + (0x13FA, 0x13F2), + (0x13FB, 0x13F3), + (0x13FC, 0x13F4), + (0x13FD, 0x13F5), + (0x1C80, 0x412), + (0x1C81, 0x414), + (0x1C82, 0x41E), + (0x1C83, 0x421), + (0x1C84, 0x422), + (0x1C85, 0x422), + (0x1C86, 0x42A), + (0x1C87, 0x462), + (0x1C88, 0xA64A), + (0x1C8A, 0x1C89), + (0x1D79, 0xA77D), + (0x1D7D, 0x2C63), + (0x1D8E, 0xA7C6), + (0x1E01, 0x1E00), + (0x1E03, 0x1E02), + (0x1E05, 0x1E04), + (0x1E07, 0x1E06), + (0x1E09, 0x1E08), + (0x1E0B, 0x1E0A), + (0x1E0D, 0x1E0C), + (0x1E0F, 0x1E0E), + (0x1E11, 0x1E10), + (0x1E13, 0x1E12), + (0x1E15, 0x1E14), + (0x1E17, 0x1E16), + (0x1E19, 0x1E18), + (0x1E1B, 0x1E1A), + (0x1E1D, 0x1E1C), + (0x1E1F, 0x1E1E), + (0x1E21, 0x1E20), + (0x1E23, 0x1E22), + (0x1E25, 0x1E24), + (0x1E27, 0x1E26), + (0x1E29, 0x1E28), + (0x1E2B, 0x1E2A), + (0x1E2D, 0x1E2C), + (0x1E2F, 0x1E2E), + (0x1E31, 0x1E30), + (0x1E33, 0x1E32), + (0x1E35, 0x1E34), + (0x1E37, 0x1E36), + (0x1E39, 0x1E38), + (0x1E3B, 0x1E3A), + (0x1E3D, 0x1E3C), + (0x1E3F, 0x1E3E), + (0x1E41, 0x1E40), + (0x1E43, 0x1E42), + (0x1E45, 0x1E44), + (0x1E47, 0x1E46), + (0x1E49, 0x1E48), + (0x1E4B, 0x1E4A), + (0x1E4D, 0x1E4C), + (0x1E4F, 0x1E4E), + (0x1E51, 0x1E50), + (0x1E53, 0x1E52), + (0x1E55, 0x1E54), + (0x1E57, 0x1E56), + (0x1E59, 0x1E58), + (0x1E5B, 0x1E5A), + (0x1E5D, 0x1E5C), + (0x1E5F, 0x1E5E), + (0x1E61, 0x1E60), + (0x1E63, 0x1E62), + (0x1E65, 0x1E64), + (0x1E67, 0x1E66), + (0x1E69, 0x1E68), + (0x1E6B, 0x1E6A), + (0x1E6D, 0x1E6C), + (0x1E6F, 0x1E6E), + (0x1E71, 0x1E70), + (0x1E73, 0x1E72), + (0x1E75, 0x1E74), + (0x1E77, 0x1E76), + (0x1E79, 0x1E78), + (0x1E7B, 0x1E7A), + (0x1E7D, 0x1E7C), + (0x1E7F, 0x1E7E), + (0x1E81, 0x1E80), + (0x1E83, 0x1E82), + (0x1E85, 0x1E84), + (0x1E87, 0x1E86), + (0x1E89, 0x1E88), + (0x1E8B, 0x1E8A), + (0x1E8D, 0x1E8C), + (0x1E8F, 0x1E8E), + (0x1E91, 0x1E90), + (0x1E93, 0x1E92), + (0x1E95, 0x1E94), + (0x1E9B, 0x1E60), + (0x1EA1, 0x1EA0), + (0x1EA3, 0x1EA2), + (0x1EA5, 0x1EA4), + (0x1EA7, 0x1EA6), + (0x1EA9, 0x1EA8), + (0x1EAB, 0x1EAA), + (0x1EAD, 0x1EAC), + (0x1EAF, 0x1EAE), + (0x1EB1, 0x1EB0), + (0x1EB3, 0x1EB2), + (0x1EB5, 0x1EB4), + (0x1EB7, 0x1EB6), + (0x1EB9, 0x1EB8), + (0x1EBB, 0x1EBA), + (0x1EBD, 0x1EBC), + (0x1EBF, 0x1EBE), + (0x1EC1, 0x1EC0), + (0x1EC3, 0x1EC2), + (0x1EC5, 0x1EC4), + (0x1EC7, 0x1EC6), + (0x1EC9, 0x1EC8), + (0x1ECB, 0x1ECA), + (0x1ECD, 0x1ECC), + (0x1ECF, 0x1ECE), + (0x1ED1, 0x1ED0), + (0x1ED3, 0x1ED2), + (0x1ED5, 0x1ED4), + (0x1ED7, 0x1ED6), + (0x1ED9, 0x1ED8), + (0x1EDB, 0x1EDA), + (0x1EDD, 0x1EDC), + (0x1EDF, 0x1EDE), + (0x1EE1, 0x1EE0), + (0x1EE3, 0x1EE2), + (0x1EE5, 0x1EE4), + (0x1EE7, 0x1EE6), + (0x1EE9, 0x1EE8), + (0x1EEB, 0x1EEA), + (0x1EED, 0x1EEC), + (0x1EEF, 0x1EEE), + (0x1EF1, 0x1EF0), + (0x1EF3, 0x1EF2), + (0x1EF5, 0x1EF4), + (0x1EF7, 0x1EF6), + (0x1EF9, 0x1EF8), + (0x1EFB, 0x1EFA), + (0x1EFD, 0x1EFC), + (0x1EFF, 0x1EFE), + (0x1F00, 0x1F08), + (0x1F01, 0x1F09), + (0x1F02, 0x1F0A), + (0x1F03, 0x1F0B), + (0x1F04, 0x1F0C), + (0x1F05, 0x1F0D), + (0x1F06, 0x1F0E), + (0x1F07, 0x1F0F), + (0x1F10, 0x1F18), + (0x1F11, 0x1F19), + (0x1F12, 0x1F1A), + (0x1F13, 0x1F1B), + (0x1F14, 0x1F1C), + (0x1F15, 0x1F1D), + (0x1F20, 0x1F28), + (0x1F21, 0x1F29), + (0x1F22, 0x1F2A), + (0x1F23, 0x1F2B), + (0x1F24, 0x1F2C), + (0x1F25, 0x1F2D), + (0x1F26, 0x1F2E), + (0x1F27, 0x1F2F), + (0x1F30, 0x1F38), + (0x1F31, 0x1F39), + (0x1F32, 0x1F3A), + (0x1F33, 0x1F3B), + (0x1F34, 0x1F3C), + (0x1F35, 0x1F3D), + (0x1F36, 0x1F3E), + (0x1F37, 0x1F3F), + (0x1F40, 0x1F48), + (0x1F41, 0x1F49), + (0x1F42, 0x1F4A), + (0x1F43, 0x1F4B), + (0x1F44, 0x1F4C), + (0x1F45, 0x1F4D), + (0x1F51, 0x1F59), + (0x1F53, 0x1F5B), + (0x1F55, 0x1F5D), + (0x1F57, 0x1F5F), + (0x1F60, 0x1F68), + (0x1F61, 0x1F69), + (0x1F62, 0x1F6A), + (0x1F63, 0x1F6B), + (0x1F64, 0x1F6C), + (0x1F65, 0x1F6D), + (0x1F66, 0x1F6E), + (0x1F67, 0x1F6F), + (0x1F70, 0x1FBA), + (0x1F71, 0x1FBB), + (0x1F72, 0x1FC8), + (0x1F73, 0x1FC9), + (0x1F74, 0x1FCA), + (0x1F75, 0x1FCB), + (0x1F76, 0x1FDA), + (0x1F77, 0x1FDB), + (0x1F78, 0x1FF8), + (0x1F79, 0x1FF9), + (0x1F7A, 0x1FEA), + (0x1F7B, 0x1FEB), + (0x1F7C, 0x1FFA), + (0x1F7D, 0x1FFB), + (0x1FB0, 0x1FB8), + (0x1FB1, 0x1FB9), + (0x1FBE, 0x399), + (0x1FD0, 0x1FD8), + (0x1FD1, 0x1FD9), + (0x1FE0, 0x1FE8), + (0x1FE1, 0x1FE9), + (0x1FE5, 0x1FEC), + (0x214E, 0x2132), + (0x2170, 0x2160), + (0x2171, 0x2161), + (0x2172, 0x2162), + (0x2173, 0x2163), + (0x2174, 0x2164), + (0x2175, 0x2165), + (0x2176, 0x2166), + (0x2177, 0x2167), + (0x2178, 0x2168), + (0x2179, 0x2169), + (0x217A, 0x216A), + (0x217B, 0x216B), + (0x217C, 0x216C), + (0x217D, 0x216D), + (0x217E, 0x216E), + (0x217F, 0x216F), + (0x2184, 0x2183), + (0x24D0, 0x24B6), + (0x24D1, 0x24B7), + (0x24D2, 0x24B8), + (0x24D3, 0x24B9), + (0x24D4, 0x24BA), + (0x24D5, 0x24BB), + (0x24D6, 0x24BC), + (0x24D7, 0x24BD), + (0x24D8, 0x24BE), + (0x24D9, 0x24BF), + (0x24DA, 0x24C0), + (0x24DB, 0x24C1), + (0x24DC, 0x24C2), + (0x24DD, 0x24C3), + (0x24DE, 0x24C4), + (0x24DF, 0x24C5), + (0x24E0, 0x24C6), + (0x24E1, 0x24C7), + (0x24E2, 0x24C8), + (0x24E3, 0x24C9), + (0x24E4, 0x24CA), + (0x24E5, 0x24CB), + (0x24E6, 0x24CC), + (0x24E7, 0x24CD), + (0x24E8, 0x24CE), + (0x24E9, 0x24CF), + (0x2C30, 0x2C00), + (0x2C31, 0x2C01), + (0x2C32, 0x2C02), + (0x2C33, 0x2C03), + (0x2C34, 0x2C04), + (0x2C35, 0x2C05), + (0x2C36, 0x2C06), + (0x2C37, 0x2C07), + (0x2C38, 0x2C08), + (0x2C39, 0x2C09), + (0x2C3A, 0x2C0A), + (0x2C3B, 0x2C0B), + (0x2C3C, 0x2C0C), + (0x2C3D, 0x2C0D), + (0x2C3E, 0x2C0E), + (0x2C3F, 0x2C0F), + (0x2C40, 0x2C10), + (0x2C41, 0x2C11), + (0x2C42, 0x2C12), + (0x2C43, 0x2C13), + (0x2C44, 0x2C14), + (0x2C45, 0x2C15), + (0x2C46, 0x2C16), + (0x2C47, 0x2C17), + (0x2C48, 0x2C18), + (0x2C49, 0x2C19), + (0x2C4A, 0x2C1A), + (0x2C4B, 0x2C1B), + (0x2C4C, 0x2C1C), + (0x2C4D, 0x2C1D), + (0x2C4E, 0x2C1E), + (0x2C4F, 0x2C1F), + (0x2C50, 0x2C20), + (0x2C51, 0x2C21), + (0x2C52, 0x2C22), + (0x2C53, 0x2C23), + (0x2C54, 0x2C24), + (0x2C55, 0x2C25), + (0x2C56, 0x2C26), + (0x2C57, 0x2C27), + (0x2C58, 0x2C28), + (0x2C59, 0x2C29), + (0x2C5A, 0x2C2A), + (0x2C5B, 0x2C2B), + (0x2C5C, 0x2C2C), + (0x2C5D, 0x2C2D), + (0x2C5E, 0x2C2E), + (0x2C5F, 0x2C2F), + (0x2C61, 0x2C60), + (0x2C65, 0x23A), + (0x2C66, 0x23E), + (0x2C68, 0x2C67), + (0x2C6A, 0x2C69), + (0x2C6C, 0x2C6B), + (0x2C73, 0x2C72), + (0x2C76, 0x2C75), + (0x2C81, 0x2C80), + (0x2C83, 0x2C82), + (0x2C85, 0x2C84), + (0x2C87, 0x2C86), + (0x2C89, 0x2C88), + (0x2C8B, 0x2C8A), + (0x2C8D, 0x2C8C), + (0x2C8F, 0x2C8E), + (0x2C91, 0x2C90), + (0x2C93, 0x2C92), + (0x2C95, 0x2C94), + (0x2C97, 0x2C96), + (0x2C99, 0x2C98), + (0x2C9B, 0x2C9A), + (0x2C9D, 0x2C9C), + (0x2C9F, 0x2C9E), + (0x2CA1, 0x2CA0), + (0x2CA3, 0x2CA2), + (0x2CA5, 0x2CA4), + (0x2CA7, 0x2CA6), + (0x2CA9, 0x2CA8), + (0x2CAB, 0x2CAA), + (0x2CAD, 0x2CAC), + (0x2CAF, 0x2CAE), + (0x2CB1, 0x2CB0), + (0x2CB3, 0x2CB2), + (0x2CB5, 0x2CB4), + (0x2CB7, 0x2CB6), + (0x2CB9, 0x2CB8), + (0x2CBB, 0x2CBA), + (0x2CBD, 0x2CBC), + (0x2CBF, 0x2CBE), + (0x2CC1, 0x2CC0), + (0x2CC3, 0x2CC2), + (0x2CC5, 0x2CC4), + (0x2CC7, 0x2CC6), + (0x2CC9, 0x2CC8), + (0x2CCB, 0x2CCA), + (0x2CCD, 0x2CCC), + (0x2CCF, 0x2CCE), + (0x2CD1, 0x2CD0), + (0x2CD3, 0x2CD2), + (0x2CD5, 0x2CD4), + (0x2CD7, 0x2CD6), + (0x2CD9, 0x2CD8), + (0x2CDB, 0x2CDA), + (0x2CDD, 0x2CDC), + (0x2CDF, 0x2CDE), + (0x2CE1, 0x2CE0), + (0x2CE3, 0x2CE2), + (0x2CEC, 0x2CEB), + (0x2CEE, 0x2CED), + (0x2CF3, 0x2CF2), + (0x2D00, 0x10A0), + (0x2D01, 0x10A1), + (0x2D02, 0x10A2), + (0x2D03, 0x10A3), + (0x2D04, 0x10A4), + (0x2D05, 0x10A5), + (0x2D06, 0x10A6), + (0x2D07, 0x10A7), + (0x2D08, 0x10A8), + (0x2D09, 0x10A9), + (0x2D0A, 0x10AA), + (0x2D0B, 0x10AB), + (0x2D0C, 0x10AC), + (0x2D0D, 0x10AD), + (0x2D0E, 0x10AE), + (0x2D0F, 0x10AF), + (0x2D10, 0x10B0), + (0x2D11, 0x10B1), + (0x2D12, 0x10B2), + (0x2D13, 0x10B3), + (0x2D14, 0x10B4), + (0x2D15, 0x10B5), + (0x2D16, 0x10B6), + (0x2D17, 0x10B7), + (0x2D18, 0x10B8), + (0x2D19, 0x10B9), + (0x2D1A, 0x10BA), + (0x2D1B, 0x10BB), + (0x2D1C, 0x10BC), + (0x2D1D, 0x10BD), + (0x2D1E, 0x10BE), + (0x2D1F, 0x10BF), + (0x2D20, 0x10C0), + (0x2D21, 0x10C1), + (0x2D22, 0x10C2), + (0x2D23, 0x10C3), + (0x2D24, 0x10C4), + (0x2D25, 0x10C5), + (0x2D27, 0x10C7), + (0x2D2D, 0x10CD), + (0xA641, 0xA640), + (0xA643, 0xA642), + (0xA645, 0xA644), + (0xA647, 0xA646), + (0xA649, 0xA648), + (0xA64B, 0xA64A), + (0xA64D, 0xA64C), + (0xA64F, 0xA64E), + (0xA651, 0xA650), + (0xA653, 0xA652), + (0xA655, 0xA654), + (0xA657, 0xA656), + (0xA659, 0xA658), + (0xA65B, 0xA65A), + (0xA65D, 0xA65C), + (0xA65F, 0xA65E), + (0xA661, 0xA660), + (0xA663, 0xA662), + (0xA665, 0xA664), + (0xA667, 0xA666), + (0xA669, 0xA668), + (0xA66B, 0xA66A), + (0xA66D, 0xA66C), + (0xA681, 0xA680), + (0xA683, 0xA682), + (0xA685, 0xA684), + (0xA687, 0xA686), + (0xA689, 0xA688), + (0xA68B, 0xA68A), + (0xA68D, 0xA68C), + (0xA68F, 0xA68E), + (0xA691, 0xA690), + (0xA693, 0xA692), + (0xA695, 0xA694), + (0xA697, 0xA696), + (0xA699, 0xA698), + (0xA69B, 0xA69A), + (0xA723, 0xA722), + (0xA725, 0xA724), + (0xA727, 0xA726), + (0xA729, 0xA728), + (0xA72B, 0xA72A), + (0xA72D, 0xA72C), + (0xA72F, 0xA72E), + (0xA733, 0xA732), + (0xA735, 0xA734), + (0xA737, 0xA736), + (0xA739, 0xA738), + (0xA73B, 0xA73A), + (0xA73D, 0xA73C), + (0xA73F, 0xA73E), + (0xA741, 0xA740), + (0xA743, 0xA742), + (0xA745, 0xA744), + (0xA747, 0xA746), + (0xA749, 0xA748), + (0xA74B, 0xA74A), + (0xA74D, 0xA74C), + (0xA74F, 0xA74E), + (0xA751, 0xA750), + (0xA753, 0xA752), + (0xA755, 0xA754), + (0xA757, 0xA756), + (0xA759, 0xA758), + (0xA75B, 0xA75A), + (0xA75D, 0xA75C), + (0xA75F, 0xA75E), + (0xA761, 0xA760), + (0xA763, 0xA762), + (0xA765, 0xA764), + (0xA767, 0xA766), + (0xA769, 0xA768), + (0xA76B, 0xA76A), + (0xA76D, 0xA76C), + (0xA76F, 0xA76E), + (0xA77A, 0xA779), + (0xA77C, 0xA77B), + (0xA77F, 0xA77E), + (0xA781, 0xA780), + (0xA783, 0xA782), + (0xA785, 0xA784), + (0xA787, 0xA786), + (0xA78C, 0xA78B), + (0xA791, 0xA790), + (0xA793, 0xA792), + (0xA794, 0xA7C4), + (0xA797, 0xA796), + (0xA799, 0xA798), + (0xA79B, 0xA79A), + (0xA79D, 0xA79C), + (0xA79F, 0xA79E), + (0xA7A1, 0xA7A0), + (0xA7A3, 0xA7A2), + (0xA7A5, 0xA7A4), + (0xA7A7, 0xA7A6), + (0xA7A9, 0xA7A8), + (0xA7B5, 0xA7B4), + (0xA7B7, 0xA7B6), + (0xA7B9, 0xA7B8), + (0xA7BB, 0xA7BA), + (0xA7BD, 0xA7BC), + (0xA7BF, 0xA7BE), + (0xA7C1, 0xA7C0), + (0xA7C3, 0xA7C2), + (0xA7C8, 0xA7C7), + (0xA7CA, 0xA7C9), + (0xA7CD, 0xA7CC), + (0xA7CF, 0xA7CE), + (0xA7D1, 0xA7D0), + (0xA7D3, 0xA7D2), + (0xA7D5, 0xA7D4), + (0xA7D7, 0xA7D6), + (0xA7D9, 0xA7D8), + (0xA7DB, 0xA7DA), + (0xA7F6, 0xA7F5), + (0xAB4B, 0xAB6C), + (0xAB4C, 0xAB6D), + (0xAB53, 0xA7B3), + (0xAB70, 0x13A0), + (0xAB71, 0x13A1), + (0xAB72, 0x13A2), + (0xAB73, 0x13A3), + (0xAB74, 0x13A4), + (0xAB75, 0x13A5), + (0xAB76, 0x13A6), + (0xAB77, 0x13A7), + (0xAB78, 0x13A8), + (0xAB79, 0x13A9), + (0xAB7A, 0x13AA), + (0xAB7B, 0x13AB), + (0xAB7C, 0x13AC), + (0xAB7D, 0x13AD), + (0xAB7E, 0x13AE), + (0xAB7F, 0x13AF), + (0xAB80, 0x13B0), + (0xAB81, 0x13B1), + (0xAB82, 0x13B2), + (0xAB83, 0x13B3), + (0xAB84, 0x13B4), + (0xAB85, 0x13B5), + (0xAB86, 0x13B6), + (0xAB87, 0x13B7), + (0xAB88, 0x13B8), + (0xAB89, 0x13B9), + (0xAB8A, 0x13BA), + (0xAB8B, 0x13BB), + (0xAB8C, 0x13BC), + (0xAB8D, 0x13BD), + (0xAB8E, 0x13BE), + (0xAB8F, 0x13BF), + (0xAB90, 0x13C0), + (0xAB91, 0x13C1), + (0xAB92, 0x13C2), + (0xAB93, 0x13C3), + (0xAB94, 0x13C4), + (0xAB95, 0x13C5), + (0xAB96, 0x13C6), + (0xAB97, 0x13C7), + (0xAB98, 0x13C8), + (0xAB99, 0x13C9), + (0xAB9A, 0x13CA), + (0xAB9B, 0x13CB), + (0xAB9C, 0x13CC), + (0xAB9D, 0x13CD), + (0xAB9E, 0x13CE), + (0xAB9F, 0x13CF), + (0xABA0, 0x13D0), + (0xABA1, 0x13D1), + (0xABA2, 0x13D2), + (0xABA3, 0x13D3), + (0xABA4, 0x13D4), + (0xABA5, 0x13D5), + (0xABA6, 0x13D6), + (0xABA7, 0x13D7), + (0xABA8, 0x13D8), + (0xABA9, 0x13D9), + (0xABAA, 0x13DA), + (0xABAB, 0x13DB), + (0xABAC, 0x13DC), + (0xABAD, 0x13DD), + (0xABAE, 0x13DE), + (0xABAF, 0x13DF), + (0xABB0, 0x13E0), + (0xABB1, 0x13E1), + (0xABB2, 0x13E2), + (0xABB3, 0x13E3), + (0xABB4, 0x13E4), + (0xABB5, 0x13E5), + (0xABB6, 0x13E6), + (0xABB7, 0x13E7), + (0xABB8, 0x13E8), + (0xABB9, 0x13E9), + (0xABBA, 0x13EA), + (0xABBB, 0x13EB), + (0xABBC, 0x13EC), + (0xABBD, 0x13ED), + (0xABBE, 0x13EE), + (0xABBF, 0x13EF), + (0xFF41, 0xFF21), + (0xFF42, 0xFF22), + (0xFF43, 0xFF23), + (0xFF44, 0xFF24), + (0xFF45, 0xFF25), + (0xFF46, 0xFF26), + (0xFF47, 0xFF27), + (0xFF48, 0xFF28), + (0xFF49, 0xFF29), + (0xFF4A, 0xFF2A), + (0xFF4B, 0xFF2B), + (0xFF4C, 0xFF2C), + (0xFF4D, 0xFF2D), + (0xFF4E, 0xFF2E), + (0xFF4F, 0xFF2F), + (0xFF50, 0xFF30), + (0xFF51, 0xFF31), + (0xFF52, 0xFF32), + (0xFF53, 0xFF33), + (0xFF54, 0xFF34), + (0xFF55, 0xFF35), + (0xFF56, 0xFF36), + (0xFF57, 0xFF37), + (0xFF58, 0xFF38), + (0xFF59, 0xFF39), + (0xFF5A, 0xFF3A), +]; + +/// `UPPER` as (upper case, code point), sorted. +pub static UPPER_INVERSE: &[(u32, u32)] = &[ + (0x41, 0x61), + (0x42, 0x62), + (0x43, 0x63), + (0x44, 0x64), + (0x45, 0x65), + (0x46, 0x66), + (0x47, 0x67), + (0x48, 0x68), + (0x49, 0x69), + (0x4A, 0x6A), + (0x4B, 0x6B), + (0x4C, 0x6C), + (0x4D, 0x6D), + (0x4E, 0x6E), + (0x4F, 0x6F), + (0x50, 0x70), + (0x51, 0x71), + (0x52, 0x72), + (0x53, 0x73), + (0x54, 0x74), + (0x55, 0x75), + (0x56, 0x76), + (0x57, 0x77), + (0x58, 0x78), + (0x59, 0x79), + (0x5A, 0x7A), + (0xC0, 0xE0), + (0xC1, 0xE1), + (0xC2, 0xE2), + (0xC3, 0xE3), + (0xC4, 0xE4), + (0xC5, 0xE5), + (0xC6, 0xE6), + (0xC7, 0xE7), + (0xC8, 0xE8), + (0xC9, 0xE9), + (0xCA, 0xEA), + (0xCB, 0xEB), + (0xCC, 0xEC), + (0xCD, 0xED), + (0xCE, 0xEE), + (0xCF, 0xEF), + (0xD0, 0xF0), + (0xD1, 0xF1), + (0xD2, 0xF2), + (0xD3, 0xF3), + (0xD4, 0xF4), + (0xD5, 0xF5), + (0xD6, 0xF6), + (0xD8, 0xF8), + (0xD9, 0xF9), + (0xDA, 0xFA), + (0xDB, 0xFB), + (0xDC, 0xFC), + (0xDD, 0xFD), + (0xDE, 0xFE), + (0x100, 0x101), + (0x102, 0x103), + (0x104, 0x105), + (0x106, 0x107), + (0x108, 0x109), + (0x10A, 0x10B), + (0x10C, 0x10D), + (0x10E, 0x10F), + (0x110, 0x111), + (0x112, 0x113), + (0x114, 0x115), + (0x116, 0x117), + (0x118, 0x119), + (0x11A, 0x11B), + (0x11C, 0x11D), + (0x11E, 0x11F), + (0x120, 0x121), + (0x122, 0x123), + (0x124, 0x125), + (0x126, 0x127), + (0x128, 0x129), + (0x12A, 0x12B), + (0x12C, 0x12D), + (0x12E, 0x12F), + (0x132, 0x133), + (0x134, 0x135), + (0x136, 0x137), + (0x139, 0x13A), + (0x13B, 0x13C), + (0x13D, 0x13E), + (0x13F, 0x140), + (0x141, 0x142), + (0x143, 0x144), + (0x145, 0x146), + (0x147, 0x148), + (0x14A, 0x14B), + (0x14C, 0x14D), + (0x14E, 0x14F), + (0x150, 0x151), + (0x152, 0x153), + (0x154, 0x155), + (0x156, 0x157), + (0x158, 0x159), + (0x15A, 0x15B), + (0x15C, 0x15D), + (0x15E, 0x15F), + (0x160, 0x161), + (0x162, 0x163), + (0x164, 0x165), + (0x166, 0x167), + (0x168, 0x169), + (0x16A, 0x16B), + (0x16C, 0x16D), + (0x16E, 0x16F), + (0x170, 0x171), + (0x172, 0x173), + (0x174, 0x175), + (0x176, 0x177), + (0x178, 0xFF), + (0x179, 0x17A), + (0x17B, 0x17C), + (0x17D, 0x17E), + (0x181, 0x253), + (0x182, 0x183), + (0x184, 0x185), + (0x186, 0x254), + (0x187, 0x188), + (0x189, 0x256), + (0x18A, 0x257), + (0x18B, 0x18C), + (0x18E, 0x1DD), + (0x18F, 0x259), + (0x190, 0x25B), + (0x191, 0x192), + (0x193, 0x260), + (0x194, 0x263), + (0x196, 0x269), + (0x197, 0x268), + (0x198, 0x199), + (0x19C, 0x26F), + (0x19D, 0x272), + (0x19F, 0x275), + (0x1A0, 0x1A1), + (0x1A2, 0x1A3), + (0x1A4, 0x1A5), + (0x1A6, 0x280), + (0x1A7, 0x1A8), + (0x1A9, 0x283), + (0x1AC, 0x1AD), + (0x1AE, 0x288), + (0x1AF, 0x1B0), + (0x1B1, 0x28A), + (0x1B2, 0x28B), + (0x1B3, 0x1B4), + (0x1B5, 0x1B6), + (0x1B7, 0x292), + (0x1B8, 0x1B9), + (0x1BC, 0x1BD), + (0x1C4, 0x1C5), + (0x1C4, 0x1C6), + (0x1C7, 0x1C8), + (0x1C7, 0x1C9), + (0x1CA, 0x1CB), + (0x1CA, 0x1CC), + (0x1CD, 0x1CE), + (0x1CF, 0x1D0), + (0x1D1, 0x1D2), + (0x1D3, 0x1D4), + (0x1D5, 0x1D6), + (0x1D7, 0x1D8), + (0x1D9, 0x1DA), + (0x1DB, 0x1DC), + (0x1DE, 0x1DF), + (0x1E0, 0x1E1), + (0x1E2, 0x1E3), + (0x1E4, 0x1E5), + (0x1E6, 0x1E7), + (0x1E8, 0x1E9), + (0x1EA, 0x1EB), + (0x1EC, 0x1ED), + (0x1EE, 0x1EF), + (0x1F1, 0x1F2), + (0x1F1, 0x1F3), + (0x1F4, 0x1F5), + (0x1F6, 0x195), + (0x1F7, 0x1BF), + (0x1F8, 0x1F9), + (0x1FA, 0x1FB), + (0x1FC, 0x1FD), + (0x1FE, 0x1FF), + (0x200, 0x201), + (0x202, 0x203), + (0x204, 0x205), + (0x206, 0x207), + (0x208, 0x209), + (0x20A, 0x20B), + (0x20C, 0x20D), + (0x20E, 0x20F), + (0x210, 0x211), + (0x212, 0x213), + (0x214, 0x215), + (0x216, 0x217), + (0x218, 0x219), + (0x21A, 0x21B), + (0x21C, 0x21D), + (0x21E, 0x21F), + (0x220, 0x19E), + (0x222, 0x223), + (0x224, 0x225), + (0x226, 0x227), + (0x228, 0x229), + (0x22A, 0x22B), + (0x22C, 0x22D), + (0x22E, 0x22F), + (0x230, 0x231), + (0x232, 0x233), + (0x23A, 0x2C65), + (0x23B, 0x23C), + (0x23D, 0x19A), + (0x23E, 0x2C66), + (0x241, 0x242), + (0x243, 0x180), + (0x244, 0x289), + (0x245, 0x28C), + (0x246, 0x247), + (0x248, 0x249), + (0x24A, 0x24B), + (0x24C, 0x24D), + (0x24E, 0x24F), + (0x370, 0x371), + (0x372, 0x373), + (0x376, 0x377), + (0x37F, 0x3F3), + (0x386, 0x3AC), + (0x388, 0x3AD), + (0x389, 0x3AE), + (0x38A, 0x3AF), + (0x38C, 0x3CC), + (0x38E, 0x3CD), + (0x38F, 0x3CE), + (0x391, 0x3B1), + (0x392, 0x3B2), + (0x392, 0x3D0), + (0x393, 0x3B3), + (0x394, 0x3B4), + (0x395, 0x3B5), + (0x395, 0x3F5), + (0x396, 0x3B6), + (0x397, 0x3B7), + (0x398, 0x3B8), + (0x398, 0x3D1), + (0x399, 0x345), + (0x399, 0x3B9), + (0x399, 0x1FBE), + (0x39A, 0x3BA), + (0x39A, 0x3F0), + (0x39B, 0x3BB), + (0x39C, 0xB5), + (0x39C, 0x3BC), + (0x39D, 0x3BD), + (0x39E, 0x3BE), + (0x39F, 0x3BF), + (0x3A0, 0x3C0), + (0x3A0, 0x3D6), + (0x3A1, 0x3C1), + (0x3A1, 0x3F1), + (0x3A3, 0x3C2), + (0x3A3, 0x3C3), + (0x3A4, 0x3C4), + (0x3A5, 0x3C5), + (0x3A6, 0x3C6), + (0x3A6, 0x3D5), + (0x3A7, 0x3C7), + (0x3A8, 0x3C8), + (0x3A9, 0x3C9), + (0x3AA, 0x3CA), + (0x3AB, 0x3CB), + (0x3CF, 0x3D7), + (0x3D8, 0x3D9), + (0x3DA, 0x3DB), + (0x3DC, 0x3DD), + (0x3DE, 0x3DF), + (0x3E0, 0x3E1), + (0x3E2, 0x3E3), + (0x3E4, 0x3E5), + (0x3E6, 0x3E7), + (0x3E8, 0x3E9), + (0x3EA, 0x3EB), + (0x3EC, 0x3ED), + (0x3EE, 0x3EF), + (0x3F7, 0x3F8), + (0x3F9, 0x3F2), + (0x3FA, 0x3FB), + (0x3FD, 0x37B), + (0x3FE, 0x37C), + (0x3FF, 0x37D), + (0x400, 0x450), + (0x401, 0x451), + (0x402, 0x452), + (0x403, 0x453), + (0x404, 0x454), + (0x405, 0x455), + (0x406, 0x456), + (0x407, 0x457), + (0x408, 0x458), + (0x409, 0x459), + (0x40A, 0x45A), + (0x40B, 0x45B), + (0x40C, 0x45C), + (0x40D, 0x45D), + (0x40E, 0x45E), + (0x40F, 0x45F), + (0x410, 0x430), + (0x411, 0x431), + (0x412, 0x432), + (0x412, 0x1C80), + (0x413, 0x433), + (0x414, 0x434), + (0x414, 0x1C81), + (0x415, 0x435), + (0x416, 0x436), + (0x417, 0x437), + (0x418, 0x438), + (0x419, 0x439), + (0x41A, 0x43A), + (0x41B, 0x43B), + (0x41C, 0x43C), + (0x41D, 0x43D), + (0x41E, 0x43E), + (0x41E, 0x1C82), + (0x41F, 0x43F), + (0x420, 0x440), + (0x421, 0x441), + (0x421, 0x1C83), + (0x422, 0x442), + (0x422, 0x1C84), + (0x422, 0x1C85), + (0x423, 0x443), + (0x424, 0x444), + (0x425, 0x445), + (0x426, 0x446), + (0x427, 0x447), + (0x428, 0x448), + (0x429, 0x449), + (0x42A, 0x44A), + (0x42A, 0x1C86), + (0x42B, 0x44B), + (0x42C, 0x44C), + (0x42D, 0x44D), + (0x42E, 0x44E), + (0x42F, 0x44F), + (0x460, 0x461), + (0x462, 0x463), + (0x462, 0x1C87), + (0x464, 0x465), + (0x466, 0x467), + (0x468, 0x469), + (0x46A, 0x46B), + (0x46C, 0x46D), + (0x46E, 0x46F), + (0x470, 0x471), + (0x472, 0x473), + (0x474, 0x475), + (0x476, 0x477), + (0x478, 0x479), + (0x47A, 0x47B), + (0x47C, 0x47D), + (0x47E, 0x47F), + (0x480, 0x481), + (0x48A, 0x48B), + (0x48C, 0x48D), + (0x48E, 0x48F), + (0x490, 0x491), + (0x492, 0x493), + (0x494, 0x495), + (0x496, 0x497), + (0x498, 0x499), + (0x49A, 0x49B), + (0x49C, 0x49D), + (0x49E, 0x49F), + (0x4A0, 0x4A1), + (0x4A2, 0x4A3), + (0x4A4, 0x4A5), + (0x4A6, 0x4A7), + (0x4A8, 0x4A9), + (0x4AA, 0x4AB), + (0x4AC, 0x4AD), + (0x4AE, 0x4AF), + (0x4B0, 0x4B1), + (0x4B2, 0x4B3), + (0x4B4, 0x4B5), + (0x4B6, 0x4B7), + (0x4B8, 0x4B9), + (0x4BA, 0x4BB), + (0x4BC, 0x4BD), + (0x4BE, 0x4BF), + (0x4C0, 0x4CF), + (0x4C1, 0x4C2), + (0x4C3, 0x4C4), + (0x4C5, 0x4C6), + (0x4C7, 0x4C8), + (0x4C9, 0x4CA), + (0x4CB, 0x4CC), + (0x4CD, 0x4CE), + (0x4D0, 0x4D1), + (0x4D2, 0x4D3), + (0x4D4, 0x4D5), + (0x4D6, 0x4D7), + (0x4D8, 0x4D9), + (0x4DA, 0x4DB), + (0x4DC, 0x4DD), + (0x4DE, 0x4DF), + (0x4E0, 0x4E1), + (0x4E2, 0x4E3), + (0x4E4, 0x4E5), + (0x4E6, 0x4E7), + (0x4E8, 0x4E9), + (0x4EA, 0x4EB), + (0x4EC, 0x4ED), + (0x4EE, 0x4EF), + (0x4F0, 0x4F1), + (0x4F2, 0x4F3), + (0x4F4, 0x4F5), + (0x4F6, 0x4F7), + (0x4F8, 0x4F9), + (0x4FA, 0x4FB), + (0x4FC, 0x4FD), + (0x4FE, 0x4FF), + (0x500, 0x501), + (0x502, 0x503), + (0x504, 0x505), + (0x506, 0x507), + (0x508, 0x509), + (0x50A, 0x50B), + (0x50C, 0x50D), + (0x50E, 0x50F), + (0x510, 0x511), + (0x512, 0x513), + (0x514, 0x515), + (0x516, 0x517), + (0x518, 0x519), + (0x51A, 0x51B), + (0x51C, 0x51D), + (0x51E, 0x51F), + (0x520, 0x521), + (0x522, 0x523), + (0x524, 0x525), + (0x526, 0x527), + (0x528, 0x529), + (0x52A, 0x52B), + (0x52C, 0x52D), + (0x52E, 0x52F), + (0x531, 0x561), + (0x532, 0x562), + (0x533, 0x563), + (0x534, 0x564), + (0x535, 0x565), + (0x536, 0x566), + (0x537, 0x567), + (0x538, 0x568), + (0x539, 0x569), + (0x53A, 0x56A), + (0x53B, 0x56B), + (0x53C, 0x56C), + (0x53D, 0x56D), + (0x53E, 0x56E), + (0x53F, 0x56F), + (0x540, 0x570), + (0x541, 0x571), + (0x542, 0x572), + (0x543, 0x573), + (0x544, 0x574), + (0x545, 0x575), + (0x546, 0x576), + (0x547, 0x577), + (0x548, 0x578), + (0x549, 0x579), + (0x54A, 0x57A), + (0x54B, 0x57B), + (0x54C, 0x57C), + (0x54D, 0x57D), + (0x54E, 0x57E), + (0x54F, 0x57F), + (0x550, 0x580), + (0x551, 0x581), + (0x552, 0x582), + (0x553, 0x583), + (0x554, 0x584), + (0x555, 0x585), + (0x556, 0x586), + (0x10A0, 0x2D00), + (0x10A1, 0x2D01), + (0x10A2, 0x2D02), + (0x10A3, 0x2D03), + (0x10A4, 0x2D04), + (0x10A5, 0x2D05), + (0x10A6, 0x2D06), + (0x10A7, 0x2D07), + (0x10A8, 0x2D08), + (0x10A9, 0x2D09), + (0x10AA, 0x2D0A), + (0x10AB, 0x2D0B), + (0x10AC, 0x2D0C), + (0x10AD, 0x2D0D), + (0x10AE, 0x2D0E), + (0x10AF, 0x2D0F), + (0x10B0, 0x2D10), + (0x10B1, 0x2D11), + (0x10B2, 0x2D12), + (0x10B3, 0x2D13), + (0x10B4, 0x2D14), + (0x10B5, 0x2D15), + (0x10B6, 0x2D16), + (0x10B7, 0x2D17), + (0x10B8, 0x2D18), + (0x10B9, 0x2D19), + (0x10BA, 0x2D1A), + (0x10BB, 0x2D1B), + (0x10BC, 0x2D1C), + (0x10BD, 0x2D1D), + (0x10BE, 0x2D1E), + (0x10BF, 0x2D1F), + (0x10C0, 0x2D20), + (0x10C1, 0x2D21), + (0x10C2, 0x2D22), + (0x10C3, 0x2D23), + (0x10C4, 0x2D24), + (0x10C5, 0x2D25), + (0x10C7, 0x2D27), + (0x10CD, 0x2D2D), + (0x13A0, 0xAB70), + (0x13A1, 0xAB71), + (0x13A2, 0xAB72), + (0x13A3, 0xAB73), + (0x13A4, 0xAB74), + (0x13A5, 0xAB75), + (0x13A6, 0xAB76), + (0x13A7, 0xAB77), + (0x13A8, 0xAB78), + (0x13A9, 0xAB79), + (0x13AA, 0xAB7A), + (0x13AB, 0xAB7B), + (0x13AC, 0xAB7C), + (0x13AD, 0xAB7D), + (0x13AE, 0xAB7E), + (0x13AF, 0xAB7F), + (0x13B0, 0xAB80), + (0x13B1, 0xAB81), + (0x13B2, 0xAB82), + (0x13B3, 0xAB83), + (0x13B4, 0xAB84), + (0x13B5, 0xAB85), + (0x13B6, 0xAB86), + (0x13B7, 0xAB87), + (0x13B8, 0xAB88), + (0x13B9, 0xAB89), + (0x13BA, 0xAB8A), + (0x13BB, 0xAB8B), + (0x13BC, 0xAB8C), + (0x13BD, 0xAB8D), + (0x13BE, 0xAB8E), + (0x13BF, 0xAB8F), + (0x13C0, 0xAB90), + (0x13C1, 0xAB91), + (0x13C2, 0xAB92), + (0x13C3, 0xAB93), + (0x13C4, 0xAB94), + (0x13C5, 0xAB95), + (0x13C6, 0xAB96), + (0x13C7, 0xAB97), + (0x13C8, 0xAB98), + (0x13C9, 0xAB99), + (0x13CA, 0xAB9A), + (0x13CB, 0xAB9B), + (0x13CC, 0xAB9C), + (0x13CD, 0xAB9D), + (0x13CE, 0xAB9E), + (0x13CF, 0xAB9F), + (0x13D0, 0xABA0), + (0x13D1, 0xABA1), + (0x13D2, 0xABA2), + (0x13D3, 0xABA3), + (0x13D4, 0xABA4), + (0x13D5, 0xABA5), + (0x13D6, 0xABA6), + (0x13D7, 0xABA7), + (0x13D8, 0xABA8), + (0x13D9, 0xABA9), + (0x13DA, 0xABAA), + (0x13DB, 0xABAB), + (0x13DC, 0xABAC), + (0x13DD, 0xABAD), + (0x13DE, 0xABAE), + (0x13DF, 0xABAF), + (0x13E0, 0xABB0), + (0x13E1, 0xABB1), + (0x13E2, 0xABB2), + (0x13E3, 0xABB3), + (0x13E4, 0xABB4), + (0x13E5, 0xABB5), + (0x13E6, 0xABB6), + (0x13E7, 0xABB7), + (0x13E8, 0xABB8), + (0x13E9, 0xABB9), + (0x13EA, 0xABBA), + (0x13EB, 0xABBB), + (0x13EC, 0xABBC), + (0x13ED, 0xABBD), + (0x13EE, 0xABBE), + (0x13EF, 0xABBF), + (0x13F0, 0x13F8), + (0x13F1, 0x13F9), + (0x13F2, 0x13FA), + (0x13F3, 0x13FB), + (0x13F4, 0x13FC), + (0x13F5, 0x13FD), + (0x1C89, 0x1C8A), + (0x1C90, 0x10D0), + (0x1C91, 0x10D1), + (0x1C92, 0x10D2), + (0x1C93, 0x10D3), + (0x1C94, 0x10D4), + (0x1C95, 0x10D5), + (0x1C96, 0x10D6), + (0x1C97, 0x10D7), + (0x1C98, 0x10D8), + (0x1C99, 0x10D9), + (0x1C9A, 0x10DA), + (0x1C9B, 0x10DB), + (0x1C9C, 0x10DC), + (0x1C9D, 0x10DD), + (0x1C9E, 0x10DE), + (0x1C9F, 0x10DF), + (0x1CA0, 0x10E0), + (0x1CA1, 0x10E1), + (0x1CA2, 0x10E2), + (0x1CA3, 0x10E3), + (0x1CA4, 0x10E4), + (0x1CA5, 0x10E5), + (0x1CA6, 0x10E6), + (0x1CA7, 0x10E7), + (0x1CA8, 0x10E8), + (0x1CA9, 0x10E9), + (0x1CAA, 0x10EA), + (0x1CAB, 0x10EB), + (0x1CAC, 0x10EC), + (0x1CAD, 0x10ED), + (0x1CAE, 0x10EE), + (0x1CAF, 0x10EF), + (0x1CB0, 0x10F0), + (0x1CB1, 0x10F1), + (0x1CB2, 0x10F2), + (0x1CB3, 0x10F3), + (0x1CB4, 0x10F4), + (0x1CB5, 0x10F5), + (0x1CB6, 0x10F6), + (0x1CB7, 0x10F7), + (0x1CB8, 0x10F8), + (0x1CB9, 0x10F9), + (0x1CBA, 0x10FA), + (0x1CBD, 0x10FD), + (0x1CBE, 0x10FE), + (0x1CBF, 0x10FF), + (0x1E00, 0x1E01), + (0x1E02, 0x1E03), + (0x1E04, 0x1E05), + (0x1E06, 0x1E07), + (0x1E08, 0x1E09), + (0x1E0A, 0x1E0B), + (0x1E0C, 0x1E0D), + (0x1E0E, 0x1E0F), + (0x1E10, 0x1E11), + (0x1E12, 0x1E13), + (0x1E14, 0x1E15), + (0x1E16, 0x1E17), + (0x1E18, 0x1E19), + (0x1E1A, 0x1E1B), + (0x1E1C, 0x1E1D), + (0x1E1E, 0x1E1F), + (0x1E20, 0x1E21), + (0x1E22, 0x1E23), + (0x1E24, 0x1E25), + (0x1E26, 0x1E27), + (0x1E28, 0x1E29), + (0x1E2A, 0x1E2B), + (0x1E2C, 0x1E2D), + (0x1E2E, 0x1E2F), + (0x1E30, 0x1E31), + (0x1E32, 0x1E33), + (0x1E34, 0x1E35), + (0x1E36, 0x1E37), + (0x1E38, 0x1E39), + (0x1E3A, 0x1E3B), + (0x1E3C, 0x1E3D), + (0x1E3E, 0x1E3F), + (0x1E40, 0x1E41), + (0x1E42, 0x1E43), + (0x1E44, 0x1E45), + (0x1E46, 0x1E47), + (0x1E48, 0x1E49), + (0x1E4A, 0x1E4B), + (0x1E4C, 0x1E4D), + (0x1E4E, 0x1E4F), + (0x1E50, 0x1E51), + (0x1E52, 0x1E53), + (0x1E54, 0x1E55), + (0x1E56, 0x1E57), + (0x1E58, 0x1E59), + (0x1E5A, 0x1E5B), + (0x1E5C, 0x1E5D), + (0x1E5E, 0x1E5F), + (0x1E60, 0x1E61), + (0x1E60, 0x1E9B), + (0x1E62, 0x1E63), + (0x1E64, 0x1E65), + (0x1E66, 0x1E67), + (0x1E68, 0x1E69), + (0x1E6A, 0x1E6B), + (0x1E6C, 0x1E6D), + (0x1E6E, 0x1E6F), + (0x1E70, 0x1E71), + (0x1E72, 0x1E73), + (0x1E74, 0x1E75), + (0x1E76, 0x1E77), + (0x1E78, 0x1E79), + (0x1E7A, 0x1E7B), + (0x1E7C, 0x1E7D), + (0x1E7E, 0x1E7F), + (0x1E80, 0x1E81), + (0x1E82, 0x1E83), + (0x1E84, 0x1E85), + (0x1E86, 0x1E87), + (0x1E88, 0x1E89), + (0x1E8A, 0x1E8B), + (0x1E8C, 0x1E8D), + (0x1E8E, 0x1E8F), + (0x1E90, 0x1E91), + (0x1E92, 0x1E93), + (0x1E94, 0x1E95), + (0x1EA0, 0x1EA1), + (0x1EA2, 0x1EA3), + (0x1EA4, 0x1EA5), + (0x1EA6, 0x1EA7), + (0x1EA8, 0x1EA9), + (0x1EAA, 0x1EAB), + (0x1EAC, 0x1EAD), + (0x1EAE, 0x1EAF), + (0x1EB0, 0x1EB1), + (0x1EB2, 0x1EB3), + (0x1EB4, 0x1EB5), + (0x1EB6, 0x1EB7), + (0x1EB8, 0x1EB9), + (0x1EBA, 0x1EBB), + (0x1EBC, 0x1EBD), + (0x1EBE, 0x1EBF), + (0x1EC0, 0x1EC1), + (0x1EC2, 0x1EC3), + (0x1EC4, 0x1EC5), + (0x1EC6, 0x1EC7), + (0x1EC8, 0x1EC9), + (0x1ECA, 0x1ECB), + (0x1ECC, 0x1ECD), + (0x1ECE, 0x1ECF), + (0x1ED0, 0x1ED1), + (0x1ED2, 0x1ED3), + (0x1ED4, 0x1ED5), + (0x1ED6, 0x1ED7), + (0x1ED8, 0x1ED9), + (0x1EDA, 0x1EDB), + (0x1EDC, 0x1EDD), + (0x1EDE, 0x1EDF), + (0x1EE0, 0x1EE1), + (0x1EE2, 0x1EE3), + (0x1EE4, 0x1EE5), + (0x1EE6, 0x1EE7), + (0x1EE8, 0x1EE9), + (0x1EEA, 0x1EEB), + (0x1EEC, 0x1EED), + (0x1EEE, 0x1EEF), + (0x1EF0, 0x1EF1), + (0x1EF2, 0x1EF3), + (0x1EF4, 0x1EF5), + (0x1EF6, 0x1EF7), + (0x1EF8, 0x1EF9), + (0x1EFA, 0x1EFB), + (0x1EFC, 0x1EFD), + (0x1EFE, 0x1EFF), + (0x1F08, 0x1F00), + (0x1F09, 0x1F01), + (0x1F0A, 0x1F02), + (0x1F0B, 0x1F03), + (0x1F0C, 0x1F04), + (0x1F0D, 0x1F05), + (0x1F0E, 0x1F06), + (0x1F0F, 0x1F07), + (0x1F18, 0x1F10), + (0x1F19, 0x1F11), + (0x1F1A, 0x1F12), + (0x1F1B, 0x1F13), + (0x1F1C, 0x1F14), + (0x1F1D, 0x1F15), + (0x1F28, 0x1F20), + (0x1F29, 0x1F21), + (0x1F2A, 0x1F22), + (0x1F2B, 0x1F23), + (0x1F2C, 0x1F24), + (0x1F2D, 0x1F25), + (0x1F2E, 0x1F26), + (0x1F2F, 0x1F27), + (0x1F38, 0x1F30), + (0x1F39, 0x1F31), + (0x1F3A, 0x1F32), + (0x1F3B, 0x1F33), + (0x1F3C, 0x1F34), + (0x1F3D, 0x1F35), + (0x1F3E, 0x1F36), + (0x1F3F, 0x1F37), + (0x1F48, 0x1F40), + (0x1F49, 0x1F41), + (0x1F4A, 0x1F42), + (0x1F4B, 0x1F43), + (0x1F4C, 0x1F44), + (0x1F4D, 0x1F45), + (0x1F59, 0x1F51), + (0x1F5B, 0x1F53), + (0x1F5D, 0x1F55), + (0x1F5F, 0x1F57), + (0x1F68, 0x1F60), + (0x1F69, 0x1F61), + (0x1F6A, 0x1F62), + (0x1F6B, 0x1F63), + (0x1F6C, 0x1F64), + (0x1F6D, 0x1F65), + (0x1F6E, 0x1F66), + (0x1F6F, 0x1F67), + (0x1FB8, 0x1FB0), + (0x1FB9, 0x1FB1), + (0x1FBA, 0x1F70), + (0x1FBB, 0x1F71), + (0x1FC8, 0x1F72), + (0x1FC9, 0x1F73), + (0x1FCA, 0x1F74), + (0x1FCB, 0x1F75), + (0x1FD8, 0x1FD0), + (0x1FD9, 0x1FD1), + (0x1FDA, 0x1F76), + (0x1FDB, 0x1F77), + (0x1FE8, 0x1FE0), + (0x1FE9, 0x1FE1), + (0x1FEA, 0x1F7A), + (0x1FEB, 0x1F7B), + (0x1FEC, 0x1FE5), + (0x1FF8, 0x1F78), + (0x1FF9, 0x1F79), + (0x1FFA, 0x1F7C), + (0x1FFB, 0x1F7D), + (0x2132, 0x214E), + (0x2160, 0x2170), + (0x2161, 0x2171), + (0x2162, 0x2172), + (0x2163, 0x2173), + (0x2164, 0x2174), + (0x2165, 0x2175), + (0x2166, 0x2176), + (0x2167, 0x2177), + (0x2168, 0x2178), + (0x2169, 0x2179), + (0x216A, 0x217A), + (0x216B, 0x217B), + (0x216C, 0x217C), + (0x216D, 0x217D), + (0x216E, 0x217E), + (0x216F, 0x217F), + (0x2183, 0x2184), + (0x24B6, 0x24D0), + (0x24B7, 0x24D1), + (0x24B8, 0x24D2), + (0x24B9, 0x24D3), + (0x24BA, 0x24D4), + (0x24BB, 0x24D5), + (0x24BC, 0x24D6), + (0x24BD, 0x24D7), + (0x24BE, 0x24D8), + (0x24BF, 0x24D9), + (0x24C0, 0x24DA), + (0x24C1, 0x24DB), + (0x24C2, 0x24DC), + (0x24C3, 0x24DD), + (0x24C4, 0x24DE), + (0x24C5, 0x24DF), + (0x24C6, 0x24E0), + (0x24C7, 0x24E1), + (0x24C8, 0x24E2), + (0x24C9, 0x24E3), + (0x24CA, 0x24E4), + (0x24CB, 0x24E5), + (0x24CC, 0x24E6), + (0x24CD, 0x24E7), + (0x24CE, 0x24E8), + (0x24CF, 0x24E9), + (0x2C00, 0x2C30), + (0x2C01, 0x2C31), + (0x2C02, 0x2C32), + (0x2C03, 0x2C33), + (0x2C04, 0x2C34), + (0x2C05, 0x2C35), + (0x2C06, 0x2C36), + (0x2C07, 0x2C37), + (0x2C08, 0x2C38), + (0x2C09, 0x2C39), + (0x2C0A, 0x2C3A), + (0x2C0B, 0x2C3B), + (0x2C0C, 0x2C3C), + (0x2C0D, 0x2C3D), + (0x2C0E, 0x2C3E), + (0x2C0F, 0x2C3F), + (0x2C10, 0x2C40), + (0x2C11, 0x2C41), + (0x2C12, 0x2C42), + (0x2C13, 0x2C43), + (0x2C14, 0x2C44), + (0x2C15, 0x2C45), + (0x2C16, 0x2C46), + (0x2C17, 0x2C47), + (0x2C18, 0x2C48), + (0x2C19, 0x2C49), + (0x2C1A, 0x2C4A), + (0x2C1B, 0x2C4B), + (0x2C1C, 0x2C4C), + (0x2C1D, 0x2C4D), + (0x2C1E, 0x2C4E), + (0x2C1F, 0x2C4F), + (0x2C20, 0x2C50), + (0x2C21, 0x2C51), + (0x2C22, 0x2C52), + (0x2C23, 0x2C53), + (0x2C24, 0x2C54), + (0x2C25, 0x2C55), + (0x2C26, 0x2C56), + (0x2C27, 0x2C57), + (0x2C28, 0x2C58), + (0x2C29, 0x2C59), + (0x2C2A, 0x2C5A), + (0x2C2B, 0x2C5B), + (0x2C2C, 0x2C5C), + (0x2C2D, 0x2C5D), + (0x2C2E, 0x2C5E), + (0x2C2F, 0x2C5F), + (0x2C60, 0x2C61), + (0x2C62, 0x26B), + (0x2C63, 0x1D7D), + (0x2C64, 0x27D), + (0x2C67, 0x2C68), + (0x2C69, 0x2C6A), + (0x2C6B, 0x2C6C), + (0x2C6D, 0x251), + (0x2C6E, 0x271), + (0x2C6F, 0x250), + (0x2C70, 0x252), + (0x2C72, 0x2C73), + (0x2C75, 0x2C76), + (0x2C7E, 0x23F), + (0x2C7F, 0x240), + (0x2C80, 0x2C81), + (0x2C82, 0x2C83), + (0x2C84, 0x2C85), + (0x2C86, 0x2C87), + (0x2C88, 0x2C89), + (0x2C8A, 0x2C8B), + (0x2C8C, 0x2C8D), + (0x2C8E, 0x2C8F), + (0x2C90, 0x2C91), + (0x2C92, 0x2C93), + (0x2C94, 0x2C95), + (0x2C96, 0x2C97), + (0x2C98, 0x2C99), + (0x2C9A, 0x2C9B), + (0x2C9C, 0x2C9D), + (0x2C9E, 0x2C9F), + (0x2CA0, 0x2CA1), + (0x2CA2, 0x2CA3), + (0x2CA4, 0x2CA5), + (0x2CA6, 0x2CA7), + (0x2CA8, 0x2CA9), + (0x2CAA, 0x2CAB), + (0x2CAC, 0x2CAD), + (0x2CAE, 0x2CAF), + (0x2CB0, 0x2CB1), + (0x2CB2, 0x2CB3), + (0x2CB4, 0x2CB5), + (0x2CB6, 0x2CB7), + (0x2CB8, 0x2CB9), + (0x2CBA, 0x2CBB), + (0x2CBC, 0x2CBD), + (0x2CBE, 0x2CBF), + (0x2CC0, 0x2CC1), + (0x2CC2, 0x2CC3), + (0x2CC4, 0x2CC5), + (0x2CC6, 0x2CC7), + (0x2CC8, 0x2CC9), + (0x2CCA, 0x2CCB), + (0x2CCC, 0x2CCD), + (0x2CCE, 0x2CCF), + (0x2CD0, 0x2CD1), + (0x2CD2, 0x2CD3), + (0x2CD4, 0x2CD5), + (0x2CD6, 0x2CD7), + (0x2CD8, 0x2CD9), + (0x2CDA, 0x2CDB), + (0x2CDC, 0x2CDD), + (0x2CDE, 0x2CDF), + (0x2CE0, 0x2CE1), + (0x2CE2, 0x2CE3), + (0x2CEB, 0x2CEC), + (0x2CED, 0x2CEE), + (0x2CF2, 0x2CF3), + (0xA640, 0xA641), + (0xA642, 0xA643), + (0xA644, 0xA645), + (0xA646, 0xA647), + (0xA648, 0xA649), + (0xA64A, 0x1C88), + (0xA64A, 0xA64B), + (0xA64C, 0xA64D), + (0xA64E, 0xA64F), + (0xA650, 0xA651), + (0xA652, 0xA653), + (0xA654, 0xA655), + (0xA656, 0xA657), + (0xA658, 0xA659), + (0xA65A, 0xA65B), + (0xA65C, 0xA65D), + (0xA65E, 0xA65F), + (0xA660, 0xA661), + (0xA662, 0xA663), + (0xA664, 0xA665), + (0xA666, 0xA667), + (0xA668, 0xA669), + (0xA66A, 0xA66B), + (0xA66C, 0xA66D), + (0xA680, 0xA681), + (0xA682, 0xA683), + (0xA684, 0xA685), + (0xA686, 0xA687), + (0xA688, 0xA689), + (0xA68A, 0xA68B), + (0xA68C, 0xA68D), + (0xA68E, 0xA68F), + (0xA690, 0xA691), + (0xA692, 0xA693), + (0xA694, 0xA695), + (0xA696, 0xA697), + (0xA698, 0xA699), + (0xA69A, 0xA69B), + (0xA722, 0xA723), + (0xA724, 0xA725), + (0xA726, 0xA727), + (0xA728, 0xA729), + (0xA72A, 0xA72B), + (0xA72C, 0xA72D), + (0xA72E, 0xA72F), + (0xA732, 0xA733), + (0xA734, 0xA735), + (0xA736, 0xA737), + (0xA738, 0xA739), + (0xA73A, 0xA73B), + (0xA73C, 0xA73D), + (0xA73E, 0xA73F), + (0xA740, 0xA741), + (0xA742, 0xA743), + (0xA744, 0xA745), + (0xA746, 0xA747), + (0xA748, 0xA749), + (0xA74A, 0xA74B), + (0xA74C, 0xA74D), + (0xA74E, 0xA74F), + (0xA750, 0xA751), + (0xA752, 0xA753), + (0xA754, 0xA755), + (0xA756, 0xA757), + (0xA758, 0xA759), + (0xA75A, 0xA75B), + (0xA75C, 0xA75D), + (0xA75E, 0xA75F), + (0xA760, 0xA761), + (0xA762, 0xA763), + (0xA764, 0xA765), + (0xA766, 0xA767), + (0xA768, 0xA769), + (0xA76A, 0xA76B), + (0xA76C, 0xA76D), + (0xA76E, 0xA76F), + (0xA779, 0xA77A), + (0xA77B, 0xA77C), + (0xA77D, 0x1D79), + (0xA77E, 0xA77F), + (0xA780, 0xA781), + (0xA782, 0xA783), + (0xA784, 0xA785), + (0xA786, 0xA787), + (0xA78B, 0xA78C), + (0xA78D, 0x265), + (0xA790, 0xA791), + (0xA792, 0xA793), + (0xA796, 0xA797), + (0xA798, 0xA799), + (0xA79A, 0xA79B), + (0xA79C, 0xA79D), + (0xA79E, 0xA79F), + (0xA7A0, 0xA7A1), + (0xA7A2, 0xA7A3), + (0xA7A4, 0xA7A5), + (0xA7A6, 0xA7A7), + (0xA7A8, 0xA7A9), + (0xA7AA, 0x266), + (0xA7AB, 0x25C), + (0xA7AC, 0x261), + (0xA7AD, 0x26C), + (0xA7AE, 0x26A), + (0xA7B0, 0x29E), + (0xA7B1, 0x287), + (0xA7B2, 0x29D), + (0xA7B3, 0xAB53), + (0xA7B4, 0xA7B5), + (0xA7B6, 0xA7B7), + (0xA7B8, 0xA7B9), + (0xA7BA, 0xA7BB), + (0xA7BC, 0xA7BD), + (0xA7BE, 0xA7BF), + (0xA7C0, 0xA7C1), + (0xA7C2, 0xA7C3), + (0xA7C4, 0xA794), + (0xA7C5, 0x282), + (0xA7C6, 0x1D8E), + (0xA7C7, 0xA7C8), + (0xA7C9, 0xA7CA), + (0xA7CB, 0x264), + (0xA7CC, 0xA7CD), + (0xA7CE, 0xA7CF), + (0xA7D0, 0xA7D1), + (0xA7D2, 0xA7D3), + (0xA7D4, 0xA7D5), + (0xA7D6, 0xA7D7), + (0xA7D8, 0xA7D9), + (0xA7DA, 0xA7DB), + (0xA7DC, 0x19B), + (0xA7DD, 0x277), + (0xA7E2, 0x27C), + (0xA7F5, 0xA7F6), + (0xAB6C, 0xAB4B), + (0xAB6D, 0xAB4C), + (0xFF21, 0xFF41), + (0xFF22, 0xFF42), + (0xFF23, 0xFF43), + (0xFF24, 0xFF44), + (0xFF25, 0xFF45), + (0xFF26, 0xFF46), + (0xFF27, 0xFF47), + (0xFF28, 0xFF48), + (0xFF29, 0xFF49), + (0xFF2A, 0xFF4A), + (0xFF2B, 0xFF4B), + (0xFF2C, 0xFF4C), + (0xFF2D, 0xFF4D), + (0xFF2E, 0xFF4E), + (0xFF2F, 0xFF4F), + (0xFF30, 0xFF50), + (0xFF31, 0xFF51), + (0xFF32, 0xFF52), + (0xFF33, 0xFF53), + (0xFF34, 0xFF54), + (0xFF35, 0xFF55), + (0xFF36, 0xFF56), + (0xFF37, 0xFF57), + (0xFF38, 0xFF58), + (0xFF39, 0xFF59), + (0xFF3A, 0xFF5A), +]; + +/// The general categories, in the order of the index in `GENERAL_CATEGORY`. +pub static CATEGORY_NAMES: [&str; 30] = [ + "Lu", "Ll", "Lt", "Lm", "Lo", "Mn", "Mc", "Me", "Nd", "Nl", "No", "Pc", "Pd", "Ps", "Pe", "Pi", + "Pf", "Po", "Sm", "Sc", "Sk", "So", "Zs", "Zl", "Zp", "Cc", "Cf", "Cs", "Co", "Cn", +]; + +/// General_Category (DerivedGeneralCategory.txt): first, last, index into `CATEGORY_NAMES`. Sorted, disjoint, covers U+0000 to U+10FFFF. +pub static GENERAL_CATEGORY: &[(u32, u32, u8)] = &[ + (0x0, 0x1F, 25), + (0x20, 0x20, 22), + (0x21, 0x23, 17), + (0x24, 0x24, 19), + (0x25, 0x27, 17), + (0x28, 0x28, 13), + (0x29, 0x29, 14), + (0x2A, 0x2A, 17), + (0x2B, 0x2B, 18), + (0x2C, 0x2C, 17), + (0x2D, 0x2D, 12), + (0x2E, 0x2F, 17), + (0x30, 0x39, 8), + (0x3A, 0x3B, 17), + (0x3C, 0x3E, 18), + (0x3F, 0x40, 17), + (0x41, 0x5A, 0), + (0x5B, 0x5B, 13), + (0x5C, 0x5C, 17), + (0x5D, 0x5D, 14), + (0x5E, 0x5E, 20), + (0x5F, 0x5F, 11), + (0x60, 0x60, 20), + (0x61, 0x7A, 1), + (0x7B, 0x7B, 13), + (0x7C, 0x7C, 18), + (0x7D, 0x7D, 14), + (0x7E, 0x7E, 18), + (0x7F, 0x9F, 25), + (0xA0, 0xA0, 22), + (0xA1, 0xA1, 17), + (0xA2, 0xA5, 19), + (0xA6, 0xA6, 21), + (0xA7, 0xA7, 17), + (0xA8, 0xA8, 20), + (0xA9, 0xA9, 21), + (0xAA, 0xAA, 4), + (0xAB, 0xAB, 15), + (0xAC, 0xAC, 18), + (0xAD, 0xAD, 26), + (0xAE, 0xAE, 21), + (0xAF, 0xAF, 20), + (0xB0, 0xB0, 21), + (0xB1, 0xB1, 18), + (0xB2, 0xB3, 10), + (0xB4, 0xB4, 20), + (0xB5, 0xB5, 1), + (0xB6, 0xB7, 17), + (0xB8, 0xB8, 20), + (0xB9, 0xB9, 10), + (0xBA, 0xBA, 4), + (0xBB, 0xBB, 16), + (0xBC, 0xBE, 10), + (0xBF, 0xBF, 17), + (0xC0, 0xD6, 0), + (0xD7, 0xD7, 18), + (0xD8, 0xDE, 0), + (0xDF, 0xF6, 1), + (0xF7, 0xF7, 18), + (0xF8, 0xFF, 1), + (0x100, 0x100, 0), + (0x101, 0x101, 1), + (0x102, 0x102, 0), + (0x103, 0x103, 1), + (0x104, 0x104, 0), + (0x105, 0x105, 1), + (0x106, 0x106, 0), + (0x107, 0x107, 1), + (0x108, 0x108, 0), + (0x109, 0x109, 1), + (0x10A, 0x10A, 0), + (0x10B, 0x10B, 1), + (0x10C, 0x10C, 0), + (0x10D, 0x10D, 1), + (0x10E, 0x10E, 0), + (0x10F, 0x10F, 1), + (0x110, 0x110, 0), + (0x111, 0x111, 1), + (0x112, 0x112, 0), + (0x113, 0x113, 1), + (0x114, 0x114, 0), + (0x115, 0x115, 1), + (0x116, 0x116, 0), + (0x117, 0x117, 1), + (0x118, 0x118, 0), + (0x119, 0x119, 1), + (0x11A, 0x11A, 0), + (0x11B, 0x11B, 1), + (0x11C, 0x11C, 0), + (0x11D, 0x11D, 1), + (0x11E, 0x11E, 0), + (0x11F, 0x11F, 1), + (0x120, 0x120, 0), + (0x121, 0x121, 1), + (0x122, 0x122, 0), + (0x123, 0x123, 1), + (0x124, 0x124, 0), + (0x125, 0x125, 1), + (0x126, 0x126, 0), + (0x127, 0x127, 1), + (0x128, 0x128, 0), + (0x129, 0x129, 1), + (0x12A, 0x12A, 0), + (0x12B, 0x12B, 1), + (0x12C, 0x12C, 0), + (0x12D, 0x12D, 1), + (0x12E, 0x12E, 0), + (0x12F, 0x12F, 1), + (0x130, 0x130, 0), + (0x131, 0x131, 1), + (0x132, 0x132, 0), + (0x133, 0x133, 1), + (0x134, 0x134, 0), + (0x135, 0x135, 1), + (0x136, 0x136, 0), + (0x137, 0x138, 1), + (0x139, 0x139, 0), + (0x13A, 0x13A, 1), + (0x13B, 0x13B, 0), + (0x13C, 0x13C, 1), + (0x13D, 0x13D, 0), + (0x13E, 0x13E, 1), + (0x13F, 0x13F, 0), + (0x140, 0x140, 1), + (0x141, 0x141, 0), + (0x142, 0x142, 1), + (0x143, 0x143, 0), + (0x144, 0x144, 1), + (0x145, 0x145, 0), + (0x146, 0x146, 1), + (0x147, 0x147, 0), + (0x148, 0x149, 1), + (0x14A, 0x14A, 0), + (0x14B, 0x14B, 1), + (0x14C, 0x14C, 0), + (0x14D, 0x14D, 1), + (0x14E, 0x14E, 0), + (0x14F, 0x14F, 1), + (0x150, 0x150, 0), + (0x151, 0x151, 1), + (0x152, 0x152, 0), + (0x153, 0x153, 1), + (0x154, 0x154, 0), + (0x155, 0x155, 1), + (0x156, 0x156, 0), + (0x157, 0x157, 1), + (0x158, 0x158, 0), + (0x159, 0x159, 1), + (0x15A, 0x15A, 0), + (0x15B, 0x15B, 1), + (0x15C, 0x15C, 0), + (0x15D, 0x15D, 1), + (0x15E, 0x15E, 0), + (0x15F, 0x15F, 1), + (0x160, 0x160, 0), + (0x161, 0x161, 1), + (0x162, 0x162, 0), + (0x163, 0x163, 1), + (0x164, 0x164, 0), + (0x165, 0x165, 1), + (0x166, 0x166, 0), + (0x167, 0x167, 1), + (0x168, 0x168, 0), + (0x169, 0x169, 1), + (0x16A, 0x16A, 0), + (0x16B, 0x16B, 1), + (0x16C, 0x16C, 0), + (0x16D, 0x16D, 1), + (0x16E, 0x16E, 0), + (0x16F, 0x16F, 1), + (0x170, 0x170, 0), + (0x171, 0x171, 1), + (0x172, 0x172, 0), + (0x173, 0x173, 1), + (0x174, 0x174, 0), + (0x175, 0x175, 1), + (0x176, 0x176, 0), + (0x177, 0x177, 1), + (0x178, 0x179, 0), + (0x17A, 0x17A, 1), + (0x17B, 0x17B, 0), + (0x17C, 0x17C, 1), + (0x17D, 0x17D, 0), + (0x17E, 0x180, 1), + (0x181, 0x182, 0), + (0x183, 0x183, 1), + (0x184, 0x184, 0), + (0x185, 0x185, 1), + (0x186, 0x187, 0), + (0x188, 0x188, 1), + (0x189, 0x18B, 0), + (0x18C, 0x18D, 1), + (0x18E, 0x191, 0), + (0x192, 0x192, 1), + (0x193, 0x194, 0), + (0x195, 0x195, 1), + (0x196, 0x198, 0), + (0x199, 0x19B, 1), + (0x19C, 0x19D, 0), + (0x19E, 0x19E, 1), + (0x19F, 0x1A0, 0), + (0x1A1, 0x1A1, 1), + (0x1A2, 0x1A2, 0), + (0x1A3, 0x1A3, 1), + (0x1A4, 0x1A4, 0), + (0x1A5, 0x1A5, 1), + (0x1A6, 0x1A7, 0), + (0x1A8, 0x1A8, 1), + (0x1A9, 0x1A9, 0), + (0x1AA, 0x1AB, 1), + (0x1AC, 0x1AC, 0), + (0x1AD, 0x1AD, 1), + (0x1AE, 0x1AF, 0), + (0x1B0, 0x1B0, 1), + (0x1B1, 0x1B3, 0), + (0x1B4, 0x1B4, 1), + (0x1B5, 0x1B5, 0), + (0x1B6, 0x1B6, 1), + (0x1B7, 0x1B8, 0), + (0x1B9, 0x1BA, 1), + (0x1BB, 0x1BB, 4), + (0x1BC, 0x1BC, 0), + (0x1BD, 0x1BF, 1), + (0x1C0, 0x1C3, 4), + (0x1C4, 0x1C4, 0), + (0x1C5, 0x1C5, 2), + (0x1C6, 0x1C6, 1), + (0x1C7, 0x1C7, 0), + (0x1C8, 0x1C8, 2), + (0x1C9, 0x1C9, 1), + (0x1CA, 0x1CA, 0), + (0x1CB, 0x1CB, 2), + (0x1CC, 0x1CC, 1), + (0x1CD, 0x1CD, 0), + (0x1CE, 0x1CE, 1), + (0x1CF, 0x1CF, 0), + (0x1D0, 0x1D0, 1), + (0x1D1, 0x1D1, 0), + (0x1D2, 0x1D2, 1), + (0x1D3, 0x1D3, 0), + (0x1D4, 0x1D4, 1), + (0x1D5, 0x1D5, 0), + (0x1D6, 0x1D6, 1), + (0x1D7, 0x1D7, 0), + (0x1D8, 0x1D8, 1), + (0x1D9, 0x1D9, 0), + (0x1DA, 0x1DA, 1), + (0x1DB, 0x1DB, 0), + (0x1DC, 0x1DD, 1), + (0x1DE, 0x1DE, 0), + (0x1DF, 0x1DF, 1), + (0x1E0, 0x1E0, 0), + (0x1E1, 0x1E1, 1), + (0x1E2, 0x1E2, 0), + (0x1E3, 0x1E3, 1), + (0x1E4, 0x1E4, 0), + (0x1E5, 0x1E5, 1), + (0x1E6, 0x1E6, 0), + (0x1E7, 0x1E7, 1), + (0x1E8, 0x1E8, 0), + (0x1E9, 0x1E9, 1), + (0x1EA, 0x1EA, 0), + (0x1EB, 0x1EB, 1), + (0x1EC, 0x1EC, 0), + (0x1ED, 0x1ED, 1), + (0x1EE, 0x1EE, 0), + (0x1EF, 0x1F0, 1), + (0x1F1, 0x1F1, 0), + (0x1F2, 0x1F2, 2), + (0x1F3, 0x1F3, 1), + (0x1F4, 0x1F4, 0), + (0x1F5, 0x1F5, 1), + (0x1F6, 0x1F8, 0), + (0x1F9, 0x1F9, 1), + (0x1FA, 0x1FA, 0), + (0x1FB, 0x1FB, 1), + (0x1FC, 0x1FC, 0), + (0x1FD, 0x1FD, 1), + (0x1FE, 0x1FE, 0), + (0x1FF, 0x1FF, 1), + (0x200, 0x200, 0), + (0x201, 0x201, 1), + (0x202, 0x202, 0), + (0x203, 0x203, 1), + (0x204, 0x204, 0), + (0x205, 0x205, 1), + (0x206, 0x206, 0), + (0x207, 0x207, 1), + (0x208, 0x208, 0), + (0x209, 0x209, 1), + (0x20A, 0x20A, 0), + (0x20B, 0x20B, 1), + (0x20C, 0x20C, 0), + (0x20D, 0x20D, 1), + (0x20E, 0x20E, 0), + (0x20F, 0x20F, 1), + (0x210, 0x210, 0), + (0x211, 0x211, 1), + (0x212, 0x212, 0), + (0x213, 0x213, 1), + (0x214, 0x214, 0), + (0x215, 0x215, 1), + (0x216, 0x216, 0), + (0x217, 0x217, 1), + (0x218, 0x218, 0), + (0x219, 0x219, 1), + (0x21A, 0x21A, 0), + (0x21B, 0x21B, 1), + (0x21C, 0x21C, 0), + (0x21D, 0x21D, 1), + (0x21E, 0x21E, 0), + (0x21F, 0x21F, 1), + (0x220, 0x220, 0), + (0x221, 0x221, 1), + (0x222, 0x222, 0), + (0x223, 0x223, 1), + (0x224, 0x224, 0), + (0x225, 0x225, 1), + (0x226, 0x226, 0), + (0x227, 0x227, 1), + (0x228, 0x228, 0), + (0x229, 0x229, 1), + (0x22A, 0x22A, 0), + (0x22B, 0x22B, 1), + (0x22C, 0x22C, 0), + (0x22D, 0x22D, 1), + (0x22E, 0x22E, 0), + (0x22F, 0x22F, 1), + (0x230, 0x230, 0), + (0x231, 0x231, 1), + (0x232, 0x232, 0), + (0x233, 0x239, 1), + (0x23A, 0x23B, 0), + (0x23C, 0x23C, 1), + (0x23D, 0x23E, 0), + (0x23F, 0x240, 1), + (0x241, 0x241, 0), + (0x242, 0x242, 1), + (0x243, 0x246, 0), + (0x247, 0x247, 1), + (0x248, 0x248, 0), + (0x249, 0x249, 1), + (0x24A, 0x24A, 0), + (0x24B, 0x24B, 1), + (0x24C, 0x24C, 0), + (0x24D, 0x24D, 1), + (0x24E, 0x24E, 0), + (0x24F, 0x293, 1), + (0x294, 0x295, 4), + (0x296, 0x2AF, 1), + (0x2B0, 0x2C1, 3), + (0x2C2, 0x2C5, 20), + (0x2C6, 0x2D1, 3), + (0x2D2, 0x2DF, 20), + (0x2E0, 0x2E4, 3), + (0x2E5, 0x2EB, 20), + (0x2EC, 0x2EC, 3), + (0x2ED, 0x2ED, 20), + (0x2EE, 0x2EE, 3), + (0x2EF, 0x2FF, 20), + (0x300, 0x36F, 5), + (0x370, 0x370, 0), + (0x371, 0x371, 1), + (0x372, 0x372, 0), + (0x373, 0x373, 1), + (0x374, 0x374, 3), + (0x375, 0x375, 20), + (0x376, 0x376, 0), + (0x377, 0x377, 1), + (0x378, 0x379, 29), + (0x37A, 0x37A, 3), + (0x37B, 0x37D, 1), + (0x37E, 0x37E, 17), + (0x37F, 0x37F, 0), + (0x380, 0x383, 29), + (0x384, 0x385, 20), + (0x386, 0x386, 0), + (0x387, 0x387, 17), + (0x388, 0x38A, 0), + (0x38B, 0x38B, 29), + (0x38C, 0x38C, 0), + (0x38D, 0x38D, 29), + (0x38E, 0x38F, 0), + (0x390, 0x390, 1), + (0x391, 0x3A1, 0), + (0x3A2, 0x3A2, 29), + (0x3A3, 0x3AB, 0), + (0x3AC, 0x3CE, 1), + (0x3CF, 0x3CF, 0), + (0x3D0, 0x3D1, 1), + (0x3D2, 0x3D4, 0), + (0x3D5, 0x3D7, 1), + (0x3D8, 0x3D8, 0), + (0x3D9, 0x3D9, 1), + (0x3DA, 0x3DA, 0), + (0x3DB, 0x3DB, 1), + (0x3DC, 0x3DC, 0), + (0x3DD, 0x3DD, 1), + (0x3DE, 0x3DE, 0), + (0x3DF, 0x3DF, 1), + (0x3E0, 0x3E0, 0), + (0x3E1, 0x3E1, 1), + (0x3E2, 0x3E2, 0), + (0x3E3, 0x3E3, 1), + (0x3E4, 0x3E4, 0), + (0x3E5, 0x3E5, 1), + (0x3E6, 0x3E6, 0), + (0x3E7, 0x3E7, 1), + (0x3E8, 0x3E8, 0), + (0x3E9, 0x3E9, 1), + (0x3EA, 0x3EA, 0), + (0x3EB, 0x3EB, 1), + (0x3EC, 0x3EC, 0), + (0x3ED, 0x3ED, 1), + (0x3EE, 0x3EE, 0), + (0x3EF, 0x3F3, 1), + (0x3F4, 0x3F4, 0), + (0x3F5, 0x3F5, 1), + (0x3F6, 0x3F6, 18), + (0x3F7, 0x3F7, 0), + (0x3F8, 0x3F8, 1), + (0x3F9, 0x3FA, 0), + (0x3FB, 0x3FC, 1), + (0x3FD, 0x42F, 0), + (0x430, 0x45F, 1), + (0x460, 0x460, 0), + (0x461, 0x461, 1), + (0x462, 0x462, 0), + (0x463, 0x463, 1), + (0x464, 0x464, 0), + (0x465, 0x465, 1), + (0x466, 0x466, 0), + (0x467, 0x467, 1), + (0x468, 0x468, 0), + (0x469, 0x469, 1), + (0x46A, 0x46A, 0), + (0x46B, 0x46B, 1), + (0x46C, 0x46C, 0), + (0x46D, 0x46D, 1), + (0x46E, 0x46E, 0), + (0x46F, 0x46F, 1), + (0x470, 0x470, 0), + (0x471, 0x471, 1), + (0x472, 0x472, 0), + (0x473, 0x473, 1), + (0x474, 0x474, 0), + (0x475, 0x475, 1), + (0x476, 0x476, 0), + (0x477, 0x477, 1), + (0x478, 0x478, 0), + (0x479, 0x479, 1), + (0x47A, 0x47A, 0), + (0x47B, 0x47B, 1), + (0x47C, 0x47C, 0), + (0x47D, 0x47D, 1), + (0x47E, 0x47E, 0), + (0x47F, 0x47F, 1), + (0x480, 0x480, 0), + (0x481, 0x481, 1), + (0x482, 0x482, 21), + (0x483, 0x487, 5), + (0x488, 0x489, 7), + (0x48A, 0x48A, 0), + (0x48B, 0x48B, 1), + (0x48C, 0x48C, 0), + (0x48D, 0x48D, 1), + (0x48E, 0x48E, 0), + (0x48F, 0x48F, 1), + (0x490, 0x490, 0), + (0x491, 0x491, 1), + (0x492, 0x492, 0), + (0x493, 0x493, 1), + (0x494, 0x494, 0), + (0x495, 0x495, 1), + (0x496, 0x496, 0), + (0x497, 0x497, 1), + (0x498, 0x498, 0), + (0x499, 0x499, 1), + (0x49A, 0x49A, 0), + (0x49B, 0x49B, 1), + (0x49C, 0x49C, 0), + (0x49D, 0x49D, 1), + (0x49E, 0x49E, 0), + (0x49F, 0x49F, 1), + (0x4A0, 0x4A0, 0), + (0x4A1, 0x4A1, 1), + (0x4A2, 0x4A2, 0), + (0x4A3, 0x4A3, 1), + (0x4A4, 0x4A4, 0), + (0x4A5, 0x4A5, 1), + (0x4A6, 0x4A6, 0), + (0x4A7, 0x4A7, 1), + (0x4A8, 0x4A8, 0), + (0x4A9, 0x4A9, 1), + (0x4AA, 0x4AA, 0), + (0x4AB, 0x4AB, 1), + (0x4AC, 0x4AC, 0), + (0x4AD, 0x4AD, 1), + (0x4AE, 0x4AE, 0), + (0x4AF, 0x4AF, 1), + (0x4B0, 0x4B0, 0), + (0x4B1, 0x4B1, 1), + (0x4B2, 0x4B2, 0), + (0x4B3, 0x4B3, 1), + (0x4B4, 0x4B4, 0), + (0x4B5, 0x4B5, 1), + (0x4B6, 0x4B6, 0), + (0x4B7, 0x4B7, 1), + (0x4B8, 0x4B8, 0), + (0x4B9, 0x4B9, 1), + (0x4BA, 0x4BA, 0), + (0x4BB, 0x4BB, 1), + (0x4BC, 0x4BC, 0), + (0x4BD, 0x4BD, 1), + (0x4BE, 0x4BE, 0), + (0x4BF, 0x4BF, 1), + (0x4C0, 0x4C1, 0), + (0x4C2, 0x4C2, 1), + (0x4C3, 0x4C3, 0), + (0x4C4, 0x4C4, 1), + (0x4C5, 0x4C5, 0), + (0x4C6, 0x4C6, 1), + (0x4C7, 0x4C7, 0), + (0x4C8, 0x4C8, 1), + (0x4C9, 0x4C9, 0), + (0x4CA, 0x4CA, 1), + (0x4CB, 0x4CB, 0), + (0x4CC, 0x4CC, 1), + (0x4CD, 0x4CD, 0), + (0x4CE, 0x4CF, 1), + (0x4D0, 0x4D0, 0), + (0x4D1, 0x4D1, 1), + (0x4D2, 0x4D2, 0), + (0x4D3, 0x4D3, 1), + (0x4D4, 0x4D4, 0), + (0x4D5, 0x4D5, 1), + (0x4D6, 0x4D6, 0), + (0x4D7, 0x4D7, 1), + (0x4D8, 0x4D8, 0), + (0x4D9, 0x4D9, 1), + (0x4DA, 0x4DA, 0), + (0x4DB, 0x4DB, 1), + (0x4DC, 0x4DC, 0), + (0x4DD, 0x4DD, 1), + (0x4DE, 0x4DE, 0), + (0x4DF, 0x4DF, 1), + (0x4E0, 0x4E0, 0), + (0x4E1, 0x4E1, 1), + (0x4E2, 0x4E2, 0), + (0x4E3, 0x4E3, 1), + (0x4E4, 0x4E4, 0), + (0x4E5, 0x4E5, 1), + (0x4E6, 0x4E6, 0), + (0x4E7, 0x4E7, 1), + (0x4E8, 0x4E8, 0), + (0x4E9, 0x4E9, 1), + (0x4EA, 0x4EA, 0), + (0x4EB, 0x4EB, 1), + (0x4EC, 0x4EC, 0), + (0x4ED, 0x4ED, 1), + (0x4EE, 0x4EE, 0), + (0x4EF, 0x4EF, 1), + (0x4F0, 0x4F0, 0), + (0x4F1, 0x4F1, 1), + (0x4F2, 0x4F2, 0), + (0x4F3, 0x4F3, 1), + (0x4F4, 0x4F4, 0), + (0x4F5, 0x4F5, 1), + (0x4F6, 0x4F6, 0), + (0x4F7, 0x4F7, 1), + (0x4F8, 0x4F8, 0), + (0x4F9, 0x4F9, 1), + (0x4FA, 0x4FA, 0), + (0x4FB, 0x4FB, 1), + (0x4FC, 0x4FC, 0), + (0x4FD, 0x4FD, 1), + (0x4FE, 0x4FE, 0), + (0x4FF, 0x4FF, 1), + (0x500, 0x500, 0), + (0x501, 0x501, 1), + (0x502, 0x502, 0), + (0x503, 0x503, 1), + (0x504, 0x504, 0), + (0x505, 0x505, 1), + (0x506, 0x506, 0), + (0x507, 0x507, 1), + (0x508, 0x508, 0), + (0x509, 0x509, 1), + (0x50A, 0x50A, 0), + (0x50B, 0x50B, 1), + (0x50C, 0x50C, 0), + (0x50D, 0x50D, 1), + (0x50E, 0x50E, 0), + (0x50F, 0x50F, 1), + (0x510, 0x510, 0), + (0x511, 0x511, 1), + (0x512, 0x512, 0), + (0x513, 0x513, 1), + (0x514, 0x514, 0), + (0x515, 0x515, 1), + (0x516, 0x516, 0), + (0x517, 0x517, 1), + (0x518, 0x518, 0), + (0x519, 0x519, 1), + (0x51A, 0x51A, 0), + (0x51B, 0x51B, 1), + (0x51C, 0x51C, 0), + (0x51D, 0x51D, 1), + (0x51E, 0x51E, 0), + (0x51F, 0x51F, 1), + (0x520, 0x520, 0), + (0x521, 0x521, 1), + (0x522, 0x522, 0), + (0x523, 0x523, 1), + (0x524, 0x524, 0), + (0x525, 0x525, 1), + (0x526, 0x526, 0), + (0x527, 0x527, 1), + (0x528, 0x528, 0), + (0x529, 0x529, 1), + (0x52A, 0x52A, 0), + (0x52B, 0x52B, 1), + (0x52C, 0x52C, 0), + (0x52D, 0x52D, 1), + (0x52E, 0x52E, 0), + (0x52F, 0x52F, 1), + (0x530, 0x530, 29), + (0x531, 0x556, 0), + (0x557, 0x557, 29), + (0x558, 0x559, 3), + (0x55A, 0x55F, 17), + (0x560, 0x588, 1), + (0x589, 0x589, 17), + (0x58A, 0x58A, 12), + (0x58B, 0x58C, 3), + (0x58D, 0x58E, 21), + (0x58F, 0x58F, 19), + (0x590, 0x590, 29), + (0x591, 0x5BD, 5), + (0x5BE, 0x5BE, 12), + (0x5BF, 0x5BF, 5), + (0x5C0, 0x5C0, 17), + (0x5C1, 0x5C2, 5), + (0x5C3, 0x5C3, 17), + (0x5C4, 0x5C5, 5), + (0x5C6, 0x5C6, 17), + (0x5C7, 0x5C9, 5), + (0x5CA, 0x5CF, 29), + (0x5D0, 0x5EA, 4), + (0x5EB, 0x5EE, 29), + (0x5EF, 0x5F2, 4), + (0x5F3, 0x5F4, 17), + (0x5F5, 0x5FF, 29), + (0x600, 0x605, 26), + (0x606, 0x608, 18), + (0x609, 0x60A, 17), + (0x60B, 0x60B, 19), + (0x60C, 0x60D, 17), + (0x60E, 0x60F, 21), + (0x610, 0x61A, 5), + (0x61B, 0x61B, 17), + (0x61C, 0x61C, 26), + (0x61D, 0x61F, 17), + (0x620, 0x63F, 4), + (0x640, 0x640, 3), + (0x641, 0x64A, 4), + (0x64B, 0x65F, 5), + (0x660, 0x669, 8), + (0x66A, 0x66D, 17), + (0x66E, 0x66F, 4), + (0x670, 0x670, 5), + (0x671, 0x6D3, 4), + (0x6D4, 0x6D4, 17), + (0x6D5, 0x6D5, 4), + (0x6D6, 0x6DC, 5), + (0x6DD, 0x6DD, 26), + (0x6DE, 0x6DE, 21), + (0x6DF, 0x6E4, 5), + (0x6E5, 0x6E6, 3), + (0x6E7, 0x6E8, 5), + (0x6E9, 0x6E9, 21), + (0x6EA, 0x6ED, 5), + (0x6EE, 0x6EF, 4), + (0x6F0, 0x6F9, 8), + (0x6FA, 0x6FC, 4), + (0x6FD, 0x6FE, 21), + (0x6FF, 0x6FF, 4), + (0x700, 0x70D, 17), + (0x70E, 0x70E, 29), + (0x70F, 0x70F, 26), + (0x710, 0x710, 4), + (0x711, 0x711, 5), + (0x712, 0x72F, 4), + (0x730, 0x74A, 5), + (0x74B, 0x74C, 29), + (0x74D, 0x7A5, 4), + (0x7A6, 0x7B0, 5), + (0x7B1, 0x7B1, 4), + (0x7B2, 0x7BF, 29), + (0x7C0, 0x7C9, 8), + (0x7CA, 0x7EA, 4), + (0x7EB, 0x7F3, 5), + (0x7F4, 0x7F5, 3), + (0x7F6, 0x7F6, 21), + (0x7F7, 0x7F9, 17), + (0x7FA, 0x7FA, 3), + (0x7FB, 0x7FC, 29), + (0x7FD, 0x7FD, 5), + (0x7FE, 0x7FF, 19), + (0x800, 0x815, 4), + (0x816, 0x819, 5), + (0x81A, 0x81A, 3), + (0x81B, 0x823, 5), + (0x824, 0x824, 3), + (0x825, 0x827, 5), + (0x828, 0x828, 3), + (0x829, 0x82D, 5), + (0x82E, 0x82F, 29), + (0x830, 0x83E, 17), + (0x83F, 0x83F, 29), + (0x840, 0x858, 4), + (0x859, 0x85B, 5), + (0x85C, 0x85D, 29), + (0x85E, 0x85E, 17), + (0x85F, 0x85F, 29), + (0x860, 0x86A, 4), + (0x86B, 0x86F, 29), + (0x870, 0x887, 4), + (0x888, 0x888, 20), + (0x889, 0x88F, 4), + (0x890, 0x891, 26), + (0x892, 0x896, 29), + (0x897, 0x89F, 5), + (0x8A0, 0x8C8, 4), + (0x8C9, 0x8C9, 3), + (0x8CA, 0x8E1, 5), + (0x8E2, 0x8E2, 26), + (0x8E3, 0x902, 5), + (0x903, 0x903, 6), + (0x904, 0x939, 4), + (0x93A, 0x93A, 5), + (0x93B, 0x93B, 6), + (0x93C, 0x93C, 5), + (0x93D, 0x93D, 4), + (0x93E, 0x940, 6), + (0x941, 0x948, 5), + (0x949, 0x94C, 6), + (0x94D, 0x94D, 5), + (0x94E, 0x94F, 6), + (0x950, 0x950, 4), + (0x951, 0x957, 5), + (0x958, 0x961, 4), + (0x962, 0x963, 5), + (0x964, 0x965, 17), + (0x966, 0x96F, 8), + (0x970, 0x970, 17), + (0x971, 0x971, 3), + (0x972, 0x980, 4), + (0x981, 0x981, 5), + (0x982, 0x983, 6), + (0x984, 0x984, 29), + (0x985, 0x98C, 4), + (0x98D, 0x98E, 29), + (0x98F, 0x990, 4), + (0x991, 0x992, 29), + (0x993, 0x9A8, 4), + (0x9A9, 0x9A9, 29), + (0x9AA, 0x9B0, 4), + (0x9B1, 0x9B1, 29), + (0x9B2, 0x9B2, 4), + (0x9B3, 0x9B5, 29), + (0x9B6, 0x9B9, 4), + (0x9BA, 0x9BB, 29), + (0x9BC, 0x9BC, 5), + (0x9BD, 0x9BD, 4), + (0x9BE, 0x9C0, 6), + (0x9C1, 0x9C4, 5), + (0x9C5, 0x9C6, 29), + (0x9C7, 0x9C8, 6), + (0x9C9, 0x9CA, 29), + (0x9CB, 0x9CC, 6), + (0x9CD, 0x9CD, 5), + (0x9CE, 0x9CE, 4), + (0x9CF, 0x9D6, 29), + (0x9D7, 0x9D7, 6), + (0x9D8, 0x9DB, 29), + (0x9DC, 0x9DD, 4), + (0x9DE, 0x9DE, 29), + (0x9DF, 0x9E1, 4), + (0x9E2, 0x9E3, 5), + (0x9E4, 0x9E5, 29), + (0x9E6, 0x9EF, 8), + (0x9F0, 0x9F1, 4), + (0x9F2, 0x9F3, 19), + (0x9F4, 0x9F9, 10), + (0x9FA, 0x9FA, 21), + (0x9FB, 0x9FB, 19), + (0x9FC, 0x9FC, 4), + (0x9FD, 0x9FD, 17), + (0x9FE, 0x9FE, 5), + (0x9FF, 0xA00, 29), + (0xA01, 0xA02, 5), + (0xA03, 0xA03, 6), + (0xA04, 0xA04, 29), + (0xA05, 0xA0A, 4), + (0xA0B, 0xA0E, 29), + (0xA0F, 0xA10, 4), + (0xA11, 0xA12, 29), + (0xA13, 0xA28, 4), + (0xA29, 0xA29, 29), + (0xA2A, 0xA30, 4), + (0xA31, 0xA31, 29), + (0xA32, 0xA33, 4), + (0xA34, 0xA34, 29), + (0xA35, 0xA36, 4), + (0xA37, 0xA37, 29), + (0xA38, 0xA39, 4), + (0xA3A, 0xA3B, 29), + (0xA3C, 0xA3C, 5), + (0xA3D, 0xA3D, 29), + (0xA3E, 0xA40, 6), + (0xA41, 0xA42, 5), + (0xA43, 0xA46, 29), + (0xA47, 0xA48, 5), + (0xA49, 0xA4A, 29), + (0xA4B, 0xA4D, 5), + (0xA4E, 0xA50, 29), + (0xA51, 0xA51, 5), + (0xA52, 0xA58, 29), + (0xA59, 0xA5C, 4), + (0xA5D, 0xA5D, 29), + (0xA5E, 0xA5E, 4), + (0xA5F, 0xA65, 29), + (0xA66, 0xA6F, 8), + (0xA70, 0xA71, 5), + (0xA72, 0xA74, 4), + (0xA75, 0xA75, 5), + (0xA76, 0xA76, 17), + (0xA77, 0xA80, 29), + (0xA81, 0xA82, 5), + (0xA83, 0xA83, 6), + (0xA84, 0xA84, 29), + (0xA85, 0xA8D, 4), + (0xA8E, 0xA8E, 29), + (0xA8F, 0xA91, 4), + (0xA92, 0xA92, 29), + (0xA93, 0xAA8, 4), + (0xAA9, 0xAA9, 29), + (0xAAA, 0xAB0, 4), + (0xAB1, 0xAB1, 29), + (0xAB2, 0xAB3, 4), + (0xAB4, 0xAB4, 29), + (0xAB5, 0xAB9, 4), + (0xABA, 0xABB, 29), + (0xABC, 0xABC, 5), + (0xABD, 0xABD, 4), + (0xABE, 0xAC0, 6), + (0xAC1, 0xAC5, 5), + (0xAC6, 0xAC6, 29), + (0xAC7, 0xAC8, 5), + (0xAC9, 0xAC9, 6), + (0xACA, 0xACA, 29), + (0xACB, 0xACC, 6), + (0xACD, 0xACD, 5), + (0xACE, 0xACF, 29), + (0xAD0, 0xAD0, 4), + (0xAD1, 0xADF, 29), + (0xAE0, 0xAE1, 4), + (0xAE2, 0xAE3, 5), + (0xAE4, 0xAE5, 29), + (0xAE6, 0xAEF, 8), + (0xAF0, 0xAF0, 17), + (0xAF1, 0xAF1, 19), + (0xAF2, 0xAF8, 29), + (0xAF9, 0xAF9, 4), + (0xAFA, 0xAFF, 5), + (0xB00, 0xB00, 29), + (0xB01, 0xB01, 5), + (0xB02, 0xB03, 6), + (0xB04, 0xB04, 29), + (0xB05, 0xB0C, 4), + (0xB0D, 0xB0E, 29), + (0xB0F, 0xB10, 4), + (0xB11, 0xB12, 29), + (0xB13, 0xB28, 4), + (0xB29, 0xB29, 29), + (0xB2A, 0xB30, 4), + (0xB31, 0xB31, 29), + (0xB32, 0xB33, 4), + (0xB34, 0xB34, 29), + (0xB35, 0xB39, 4), + (0xB3A, 0xB3B, 29), + (0xB3C, 0xB3C, 5), + (0xB3D, 0xB3D, 4), + (0xB3E, 0xB3E, 6), + (0xB3F, 0xB3F, 5), + (0xB40, 0xB40, 6), + (0xB41, 0xB44, 5), + (0xB45, 0xB46, 29), + (0xB47, 0xB48, 6), + (0xB49, 0xB4A, 29), + (0xB4B, 0xB4C, 6), + (0xB4D, 0xB4D, 5), + (0xB4E, 0xB52, 29), + (0xB53, 0xB56, 5), + (0xB57, 0xB57, 6), + (0xB58, 0xB5B, 29), + (0xB5C, 0xB5D, 4), + (0xB5E, 0xB5E, 29), + (0xB5F, 0xB61, 4), + (0xB62, 0xB63, 5), + (0xB64, 0xB65, 29), + (0xB66, 0xB6F, 8), + (0xB70, 0xB70, 21), + (0xB71, 0xB71, 4), + (0xB72, 0xB77, 10), + (0xB78, 0xB81, 29), + (0xB82, 0xB82, 5), + (0xB83, 0xB83, 4), + (0xB84, 0xB84, 29), + (0xB85, 0xB8A, 4), + (0xB8B, 0xB8D, 29), + (0xB8E, 0xB90, 4), + (0xB91, 0xB91, 29), + (0xB92, 0xB95, 4), + (0xB96, 0xB98, 29), + (0xB99, 0xB9A, 4), + (0xB9B, 0xB9B, 29), + (0xB9C, 0xB9C, 4), + (0xB9D, 0xB9D, 29), + (0xB9E, 0xB9F, 4), + (0xBA0, 0xBA2, 29), + (0xBA3, 0xBA4, 4), + (0xBA5, 0xBA7, 29), + (0xBA8, 0xBAA, 4), + (0xBAB, 0xBAD, 29), + (0xBAE, 0xBB9, 4), + (0xBBA, 0xBBD, 29), + (0xBBE, 0xBBF, 6), + (0xBC0, 0xBC0, 5), + (0xBC1, 0xBC2, 6), + (0xBC3, 0xBC5, 29), + (0xBC6, 0xBC8, 6), + (0xBC9, 0xBC9, 29), + (0xBCA, 0xBCC, 6), + (0xBCD, 0xBCD, 5), + (0xBCE, 0xBCF, 29), + (0xBD0, 0xBD0, 4), + (0xBD1, 0xBD6, 29), + (0xBD7, 0xBD7, 6), + (0xBD8, 0xBE5, 29), + (0xBE6, 0xBEF, 8), + (0xBF0, 0xBF2, 10), + (0xBF3, 0xBF8, 21), + (0xBF9, 0xBF9, 19), + (0xBFA, 0xBFA, 21), + (0xBFB, 0xBFF, 29), + (0xC00, 0xC00, 5), + (0xC01, 0xC03, 6), + (0xC04, 0xC04, 5), + (0xC05, 0xC0C, 4), + (0xC0D, 0xC0D, 29), + (0xC0E, 0xC10, 4), + (0xC11, 0xC11, 29), + (0xC12, 0xC28, 4), + (0xC29, 0xC29, 29), + (0xC2A, 0xC39, 4), + (0xC3A, 0xC3B, 29), + (0xC3C, 0xC3C, 5), + (0xC3D, 0xC3D, 4), + (0xC3E, 0xC40, 5), + (0xC41, 0xC44, 6), + (0xC45, 0xC45, 29), + (0xC46, 0xC48, 5), + (0xC49, 0xC49, 29), + (0xC4A, 0xC4D, 5), + (0xC4E, 0xC54, 29), + (0xC55, 0xC56, 5), + (0xC57, 0xC57, 29), + (0xC58, 0xC5A, 4), + (0xC5B, 0xC5B, 29), + (0xC5C, 0xC5D, 4), + (0xC5E, 0xC5F, 29), + (0xC60, 0xC61, 4), + (0xC62, 0xC63, 5), + (0xC64, 0xC65, 29), + (0xC66, 0xC6F, 8), + (0xC70, 0xC76, 29), + (0xC77, 0xC77, 17), + (0xC78, 0xC7E, 10), + (0xC7F, 0xC7F, 21), + (0xC80, 0xC80, 4), + (0xC81, 0xC81, 5), + (0xC82, 0xC83, 6), + (0xC84, 0xC84, 17), + (0xC85, 0xC8C, 4), + (0xC8D, 0xC8D, 29), + (0xC8E, 0xC90, 4), + (0xC91, 0xC91, 29), + (0xC92, 0xCA8, 4), + (0xCA9, 0xCA9, 29), + (0xCAA, 0xCB3, 4), + (0xCB4, 0xCB4, 29), + (0xCB5, 0xCB9, 4), + (0xCBA, 0xCBB, 29), + (0xCBC, 0xCBC, 5), + (0xCBD, 0xCBD, 4), + (0xCBE, 0xCBE, 6), + (0xCBF, 0xCBF, 5), + (0xCC0, 0xCC4, 6), + (0xCC5, 0xCC5, 29), + (0xCC6, 0xCC6, 5), + (0xCC7, 0xCC8, 6), + (0xCC9, 0xCC9, 29), + (0xCCA, 0xCCB, 6), + (0xCCC, 0xCCD, 5), + (0xCCE, 0xCD4, 29), + (0xCD5, 0xCD6, 6), + (0xCD7, 0xCDB, 29), + (0xCDC, 0xCDE, 4), + (0xCDF, 0xCDF, 29), + (0xCE0, 0xCE1, 4), + (0xCE2, 0xCE3, 5), + (0xCE4, 0xCE5, 29), + (0xCE6, 0xCEF, 8), + (0xCF0, 0xCF0, 29), + (0xCF1, 0xCF2, 4), + (0xCF3, 0xCF3, 6), + (0xCF4, 0xCFF, 29), + (0xD00, 0xD01, 5), + (0xD02, 0xD03, 6), + (0xD04, 0xD0C, 4), + (0xD0D, 0xD0D, 29), + (0xD0E, 0xD10, 4), + (0xD11, 0xD11, 29), + (0xD12, 0xD3A, 4), + (0xD3B, 0xD3C, 5), + (0xD3D, 0xD3D, 4), + (0xD3E, 0xD40, 6), + (0xD41, 0xD44, 5), + (0xD45, 0xD45, 29), + (0xD46, 0xD48, 6), + (0xD49, 0xD49, 29), + (0xD4A, 0xD4C, 6), + (0xD4D, 0xD4D, 5), + (0xD4E, 0xD4E, 4), + (0xD4F, 0xD4F, 21), + (0xD50, 0xD53, 29), + (0xD54, 0xD56, 4), + (0xD57, 0xD57, 6), + (0xD58, 0xD5E, 10), + (0xD5F, 0xD61, 4), + (0xD62, 0xD63, 5), + (0xD64, 0xD65, 29), + (0xD66, 0xD6F, 8), + (0xD70, 0xD78, 10), + (0xD79, 0xD79, 21), + (0xD7A, 0xD7F, 4), + (0xD80, 0xD80, 29), + (0xD81, 0xD81, 5), + (0xD82, 0xD83, 6), + (0xD84, 0xD84, 29), + (0xD85, 0xD96, 4), + (0xD97, 0xD99, 29), + (0xD9A, 0xDB1, 4), + (0xDB2, 0xDB2, 29), + (0xDB3, 0xDBB, 4), + (0xDBC, 0xDBC, 29), + (0xDBD, 0xDBD, 4), + (0xDBE, 0xDBF, 29), + (0xDC0, 0xDC6, 4), + (0xDC7, 0xDC9, 29), + (0xDCA, 0xDCA, 5), + (0xDCB, 0xDCE, 29), + (0xDCF, 0xDD1, 6), + (0xDD2, 0xDD4, 5), + (0xDD5, 0xDD5, 29), + (0xDD6, 0xDD6, 5), + (0xDD7, 0xDD7, 29), + (0xDD8, 0xDDF, 6), + (0xDE0, 0xDE5, 29), + (0xDE6, 0xDEF, 8), + (0xDF0, 0xDF1, 29), + (0xDF2, 0xDF3, 6), + (0xDF4, 0xDF4, 17), + (0xDF5, 0xE00, 29), + (0xE01, 0xE30, 4), + (0xE31, 0xE31, 5), + (0xE32, 0xE33, 4), + (0xE34, 0xE3A, 5), + (0xE3B, 0xE3E, 29), + (0xE3F, 0xE3F, 19), + (0xE40, 0xE45, 4), + (0xE46, 0xE46, 3), + (0xE47, 0xE4E, 5), + (0xE4F, 0xE4F, 17), + (0xE50, 0xE59, 8), + (0xE5A, 0xE5B, 17), + (0xE5C, 0xE80, 29), + (0xE81, 0xE82, 4), + (0xE83, 0xE83, 29), + (0xE84, 0xE84, 4), + (0xE85, 0xE85, 29), + (0xE86, 0xE8A, 4), + (0xE8B, 0xE8B, 29), + (0xE8C, 0xEA3, 4), + (0xEA4, 0xEA4, 29), + (0xEA5, 0xEA5, 4), + (0xEA6, 0xEA6, 29), + (0xEA7, 0xEB0, 4), + (0xEB1, 0xEB1, 5), + (0xEB2, 0xEB3, 4), + (0xEB4, 0xEBC, 5), + (0xEBD, 0xEBD, 4), + (0xEBE, 0xEBF, 29), + (0xEC0, 0xEC4, 4), + (0xEC5, 0xEC5, 29), + (0xEC6, 0xEC6, 3), + (0xEC7, 0xEC7, 29), + (0xEC8, 0xECE, 5), + (0xECF, 0xECF, 29), + (0xED0, 0xED9, 8), + (0xEDA, 0xEDB, 29), + (0xEDC, 0xEDF, 4), + (0xEE0, 0xEFF, 29), + (0xF00, 0xF00, 4), + (0xF01, 0xF03, 21), + (0xF04, 0xF12, 17), + (0xF13, 0xF13, 21), + (0xF14, 0xF14, 17), + (0xF15, 0xF17, 21), + (0xF18, 0xF19, 5), + (0xF1A, 0xF1F, 21), + (0xF20, 0xF29, 8), + (0xF2A, 0xF33, 10), + (0xF34, 0xF34, 21), + (0xF35, 0xF35, 5), + (0xF36, 0xF36, 21), + (0xF37, 0xF37, 5), + (0xF38, 0xF38, 21), + (0xF39, 0xF39, 5), + (0xF3A, 0xF3A, 13), + (0xF3B, 0xF3B, 14), + (0xF3C, 0xF3C, 13), + (0xF3D, 0xF3D, 14), + (0xF3E, 0xF3F, 6), + (0xF40, 0xF47, 4), + (0xF48, 0xF48, 29), + (0xF49, 0xF6C, 4), + (0xF6D, 0xF70, 29), + (0xF71, 0xF7E, 5), + (0xF7F, 0xF7F, 6), + (0xF80, 0xF84, 5), + (0xF85, 0xF85, 17), + (0xF86, 0xF87, 5), + (0xF88, 0xF8C, 4), + (0xF8D, 0xF97, 5), + (0xF98, 0xF98, 29), + (0xF99, 0xFBC, 5), + (0xFBD, 0xFBD, 29), + (0xFBE, 0xFC5, 21), + (0xFC6, 0xFC6, 5), + (0xFC7, 0xFCC, 21), + (0xFCD, 0xFCD, 29), + (0xFCE, 0xFCF, 21), + (0xFD0, 0xFD4, 17), + (0xFD5, 0xFD8, 21), + (0xFD9, 0xFDA, 17), + (0xFDB, 0xFFF, 29), + (0x1000, 0x102A, 4), + (0x102B, 0x102C, 6), + (0x102D, 0x1030, 5), + (0x1031, 0x1031, 6), + (0x1032, 0x1037, 5), + (0x1038, 0x1038, 6), + (0x1039, 0x103A, 5), + (0x103B, 0x103C, 6), + (0x103D, 0x103E, 5), + (0x103F, 0x103F, 4), + (0x1040, 0x1049, 8), + (0x104A, 0x104F, 17), + (0x1050, 0x1055, 4), + (0x1056, 0x1057, 6), + (0x1058, 0x1059, 5), + (0x105A, 0x105D, 4), + (0x105E, 0x1060, 5), + (0x1061, 0x1061, 4), + (0x1062, 0x1064, 6), + (0x1065, 0x1066, 4), + (0x1067, 0x106D, 6), + (0x106E, 0x1070, 4), + (0x1071, 0x1074, 5), + (0x1075, 0x1081, 4), + (0x1082, 0x1082, 5), + (0x1083, 0x1084, 6), + (0x1085, 0x1086, 5), + (0x1087, 0x108C, 6), + (0x108D, 0x108D, 5), + (0x108E, 0x108E, 4), + (0x108F, 0x108F, 6), + (0x1090, 0x1099, 8), + (0x109A, 0x109C, 6), + (0x109D, 0x109D, 5), + (0x109E, 0x109F, 21), + (0x10A0, 0x10C5, 0), + (0x10C6, 0x10C6, 29), + (0x10C7, 0x10C7, 0), + (0x10C8, 0x10CC, 29), + (0x10CD, 0x10CD, 0), + (0x10CE, 0x10CF, 29), + (0x10D0, 0x10FA, 1), + (0x10FB, 0x10FB, 17), + (0x10FC, 0x10FC, 3), + (0x10FD, 0x10FF, 1), + (0x1100, 0x1248, 4), + (0x1249, 0x1249, 29), + (0x124A, 0x124D, 4), + (0x124E, 0x124F, 29), + (0x1250, 0x1256, 4), + (0x1257, 0x1257, 29), + (0x1258, 0x1258, 4), + (0x1259, 0x1259, 29), + (0x125A, 0x125D, 4), + (0x125E, 0x125F, 29), + (0x1260, 0x1288, 4), + (0x1289, 0x1289, 29), + (0x128A, 0x128D, 4), + (0x128E, 0x128F, 29), + (0x1290, 0x12B0, 4), + (0x12B1, 0x12B1, 29), + (0x12B2, 0x12B5, 4), + (0x12B6, 0x12B7, 29), + (0x12B8, 0x12BE, 4), + (0x12BF, 0x12BF, 29), + (0x12C0, 0x12C0, 4), + (0x12C1, 0x12C1, 29), + (0x12C2, 0x12C5, 4), + (0x12C6, 0x12C7, 29), + (0x12C8, 0x12D6, 4), + (0x12D7, 0x12D7, 29), + (0x12D8, 0x1310, 4), + (0x1311, 0x1311, 29), + (0x1312, 0x1315, 4), + (0x1316, 0x1317, 29), + (0x1318, 0x135A, 4), + (0x135B, 0x135C, 29), + (0x135D, 0x135F, 5), + (0x1360, 0x1368, 17), + (0x1369, 0x137C, 10), + (0x137D, 0x137F, 29), + (0x1380, 0x138F, 4), + (0x1390, 0x1399, 21), + (0x139A, 0x139F, 29), + (0x13A0, 0x13F5, 0), + (0x13F6, 0x13F7, 29), + (0x13F8, 0x13FD, 1), + (0x13FE, 0x13FF, 29), + (0x1400, 0x1400, 12), + (0x1401, 0x166C, 4), + (0x166D, 0x166D, 21), + (0x166E, 0x166E, 17), + (0x166F, 0x167F, 4), + (0x1680, 0x1680, 22), + (0x1681, 0x169A, 4), + (0x169B, 0x169B, 13), + (0x169C, 0x169C, 14), + (0x169D, 0x169F, 29), + (0x16A0, 0x16EA, 4), + (0x16EB, 0x16ED, 17), + (0x16EE, 0x16F0, 9), + (0x16F1, 0x16F8, 4), + (0x16F9, 0x16FF, 29), + (0x1700, 0x1711, 4), + (0x1712, 0x1714, 5), + (0x1715, 0x1715, 6), + (0x1716, 0x171E, 29), + (0x171F, 0x1731, 4), + (0x1732, 0x1733, 5), + (0x1734, 0x1734, 6), + (0x1735, 0x1736, 17), + (0x1737, 0x173F, 29), + (0x1740, 0x1751, 4), + (0x1752, 0x1753, 5), + (0x1754, 0x175F, 29), + (0x1760, 0x176C, 4), + (0x176D, 0x176D, 29), + (0x176E, 0x1770, 4), + (0x1771, 0x1771, 29), + (0x1772, 0x1773, 5), + (0x1774, 0x177F, 29), + (0x1780, 0x17B3, 4), + (0x17B4, 0x17B5, 5), + (0x17B6, 0x17B6, 6), + (0x17B7, 0x17BD, 5), + (0x17BE, 0x17C5, 6), + (0x17C6, 0x17C6, 5), + (0x17C7, 0x17C8, 6), + (0x17C9, 0x17D3, 5), + (0x17D4, 0x17D6, 17), + (0x17D7, 0x17D7, 3), + (0x17D8, 0x17DA, 17), + (0x17DB, 0x17DB, 19), + (0x17DC, 0x17DC, 4), + (0x17DD, 0x17DD, 5), + (0x17DE, 0x17DF, 29), + (0x17E0, 0x17E9, 8), + (0x17EA, 0x17EF, 29), + (0x17F0, 0x17F9, 10), + (0x17FA, 0x17FF, 29), + (0x1800, 0x1805, 17), + (0x1806, 0x1806, 12), + (0x1807, 0x180A, 17), + (0x180B, 0x180D, 5), + (0x180E, 0x180E, 26), + (0x180F, 0x180F, 5), + (0x1810, 0x1819, 8), + (0x181A, 0x181F, 29), + (0x1820, 0x1842, 4), + (0x1843, 0x1843, 3), + (0x1844, 0x1878, 4), + (0x1879, 0x187F, 29), + (0x1880, 0x1884, 4), + (0x1885, 0x1886, 5), + (0x1887, 0x18A8, 4), + (0x18A9, 0x18A9, 5), + (0x18AA, 0x18AA, 4), + (0x18AB, 0x18AF, 29), + (0x18B0, 0x18F5, 4), + (0x18F6, 0x18FF, 29), + (0x1900, 0x191E, 4), + (0x191F, 0x191F, 29), + (0x1920, 0x1922, 5), + (0x1923, 0x1926, 6), + (0x1927, 0x1928, 5), + (0x1929, 0x192B, 6), + (0x192C, 0x192F, 29), + (0x1930, 0x1931, 6), + (0x1932, 0x1932, 5), + (0x1933, 0x1938, 6), + (0x1939, 0x193B, 5), + (0x193C, 0x193F, 29), + (0x1940, 0x1940, 21), + (0x1941, 0x1943, 29), + (0x1944, 0x1945, 17), + (0x1946, 0x194F, 8), + (0x1950, 0x196D, 4), + (0x196E, 0x196F, 29), + (0x1970, 0x1974, 4), + (0x1975, 0x197F, 29), + (0x1980, 0x19AB, 4), + (0x19AC, 0x19AF, 29), + (0x19B0, 0x19C9, 4), + (0x19CA, 0x19CF, 29), + (0x19D0, 0x19D9, 8), + (0x19DA, 0x19DA, 10), + (0x19DB, 0x19DD, 29), + (0x19DE, 0x19FF, 21), + (0x1A00, 0x1A16, 4), + (0x1A17, 0x1A18, 5), + (0x1A19, 0x1A1A, 6), + (0x1A1B, 0x1A1B, 5), + (0x1A1C, 0x1A1D, 29), + (0x1A1E, 0x1A1F, 17), + (0x1A20, 0x1A54, 4), + (0x1A55, 0x1A55, 6), + (0x1A56, 0x1A56, 5), + (0x1A57, 0x1A57, 6), + (0x1A58, 0x1A5E, 5), + (0x1A5F, 0x1A5F, 29), + (0x1A60, 0x1A60, 5), + (0x1A61, 0x1A61, 6), + (0x1A62, 0x1A62, 5), + (0x1A63, 0x1A64, 6), + (0x1A65, 0x1A6C, 5), + (0x1A6D, 0x1A72, 6), + (0x1A73, 0x1A7C, 5), + (0x1A7D, 0x1A7E, 29), + (0x1A7F, 0x1A7F, 5), + (0x1A80, 0x1A89, 8), + (0x1A8A, 0x1A8F, 29), + (0x1A90, 0x1A99, 8), + (0x1A9A, 0x1A9F, 29), + (0x1AA0, 0x1AA6, 17), + (0x1AA7, 0x1AA7, 3), + (0x1AA8, 0x1AAD, 17), + (0x1AAE, 0x1AAF, 29), + (0x1AB0, 0x1ABD, 5), + (0x1ABE, 0x1ABE, 7), + (0x1ABF, 0x1AF0, 5), + (0x1AF1, 0x1AFF, 29), + (0x1B00, 0x1B03, 5), + (0x1B04, 0x1B04, 6), + (0x1B05, 0x1B33, 4), + (0x1B34, 0x1B34, 5), + (0x1B35, 0x1B35, 6), + (0x1B36, 0x1B3A, 5), + (0x1B3B, 0x1B3B, 6), + (0x1B3C, 0x1B3C, 5), + (0x1B3D, 0x1B41, 6), + (0x1B42, 0x1B42, 5), + (0x1B43, 0x1B44, 6), + (0x1B45, 0x1B4C, 4), + (0x1B4D, 0x1B4D, 29), + (0x1B4E, 0x1B4F, 17), + (0x1B50, 0x1B59, 8), + (0x1B5A, 0x1B60, 17), + (0x1B61, 0x1B6A, 21), + (0x1B6B, 0x1B73, 5), + (0x1B74, 0x1B7C, 21), + (0x1B7D, 0x1B7F, 17), + (0x1B80, 0x1B81, 5), + (0x1B82, 0x1B82, 6), + (0x1B83, 0x1BA0, 4), + (0x1BA1, 0x1BA1, 6), + (0x1BA2, 0x1BA5, 5), + (0x1BA6, 0x1BA7, 6), + (0x1BA8, 0x1BA9, 5), + (0x1BAA, 0x1BAA, 6), + (0x1BAB, 0x1BAD, 5), + (0x1BAE, 0x1BAF, 4), + (0x1BB0, 0x1BB9, 8), + (0x1BBA, 0x1BE5, 4), + (0x1BE6, 0x1BE6, 5), + (0x1BE7, 0x1BE7, 6), + (0x1BE8, 0x1BE9, 5), + (0x1BEA, 0x1BEC, 6), + (0x1BED, 0x1BED, 5), + (0x1BEE, 0x1BEE, 6), + (0x1BEF, 0x1BF1, 5), + (0x1BF2, 0x1BF3, 6), + (0x1BF4, 0x1BFB, 29), + (0x1BFC, 0x1BFF, 17), + (0x1C00, 0x1C23, 4), + (0x1C24, 0x1C2B, 6), + (0x1C2C, 0x1C33, 5), + (0x1C34, 0x1C35, 6), + (0x1C36, 0x1C37, 5), + (0x1C38, 0x1C3A, 29), + (0x1C3B, 0x1C3F, 17), + (0x1C40, 0x1C49, 8), + (0x1C4A, 0x1C4C, 29), + (0x1C4D, 0x1C4F, 4), + (0x1C50, 0x1C59, 8), + (0x1C5A, 0x1C77, 4), + (0x1C78, 0x1C7D, 3), + (0x1C7E, 0x1C7F, 17), + (0x1C80, 0x1C88, 1), + (0x1C89, 0x1C89, 0), + (0x1C8A, 0x1C8A, 1), + (0x1C8B, 0x1C8F, 29), + (0x1C90, 0x1CBA, 0), + (0x1CBB, 0x1CBC, 29), + (0x1CBD, 0x1CBF, 0), + (0x1CC0, 0x1CC7, 17), + (0x1CC8, 0x1CCF, 29), + (0x1CD0, 0x1CD2, 5), + (0x1CD3, 0x1CD3, 17), + (0x1CD4, 0x1CE0, 5), + (0x1CE1, 0x1CE1, 6), + (0x1CE2, 0x1CE8, 5), + (0x1CE9, 0x1CEC, 4), + (0x1CED, 0x1CED, 5), + (0x1CEE, 0x1CF3, 4), + (0x1CF4, 0x1CF4, 5), + (0x1CF5, 0x1CF6, 4), + (0x1CF7, 0x1CF7, 6), + (0x1CF8, 0x1CF9, 5), + (0x1CFA, 0x1CFA, 4), + (0x1CFB, 0x1CFF, 29), + (0x1D00, 0x1D2B, 1), + (0x1D2C, 0x1D6A, 3), + (0x1D6B, 0x1D77, 1), + (0x1D78, 0x1D78, 3), + (0x1D79, 0x1D9A, 1), + (0x1D9B, 0x1DBF, 3), + (0x1DC0, 0x1DFF, 5), + (0x1E00, 0x1E00, 0), + (0x1E01, 0x1E01, 1), + (0x1E02, 0x1E02, 0), + (0x1E03, 0x1E03, 1), + (0x1E04, 0x1E04, 0), + (0x1E05, 0x1E05, 1), + (0x1E06, 0x1E06, 0), + (0x1E07, 0x1E07, 1), + (0x1E08, 0x1E08, 0), + (0x1E09, 0x1E09, 1), + (0x1E0A, 0x1E0A, 0), + (0x1E0B, 0x1E0B, 1), + (0x1E0C, 0x1E0C, 0), + (0x1E0D, 0x1E0D, 1), + (0x1E0E, 0x1E0E, 0), + (0x1E0F, 0x1E0F, 1), + (0x1E10, 0x1E10, 0), + (0x1E11, 0x1E11, 1), + (0x1E12, 0x1E12, 0), + (0x1E13, 0x1E13, 1), + (0x1E14, 0x1E14, 0), + (0x1E15, 0x1E15, 1), + (0x1E16, 0x1E16, 0), + (0x1E17, 0x1E17, 1), + (0x1E18, 0x1E18, 0), + (0x1E19, 0x1E19, 1), + (0x1E1A, 0x1E1A, 0), + (0x1E1B, 0x1E1B, 1), + (0x1E1C, 0x1E1C, 0), + (0x1E1D, 0x1E1D, 1), + (0x1E1E, 0x1E1E, 0), + (0x1E1F, 0x1E1F, 1), + (0x1E20, 0x1E20, 0), + (0x1E21, 0x1E21, 1), + (0x1E22, 0x1E22, 0), + (0x1E23, 0x1E23, 1), + (0x1E24, 0x1E24, 0), + (0x1E25, 0x1E25, 1), + (0x1E26, 0x1E26, 0), + (0x1E27, 0x1E27, 1), + (0x1E28, 0x1E28, 0), + (0x1E29, 0x1E29, 1), + (0x1E2A, 0x1E2A, 0), + (0x1E2B, 0x1E2B, 1), + (0x1E2C, 0x1E2C, 0), + (0x1E2D, 0x1E2D, 1), + (0x1E2E, 0x1E2E, 0), + (0x1E2F, 0x1E2F, 1), + (0x1E30, 0x1E30, 0), + (0x1E31, 0x1E31, 1), + (0x1E32, 0x1E32, 0), + (0x1E33, 0x1E33, 1), + (0x1E34, 0x1E34, 0), + (0x1E35, 0x1E35, 1), + (0x1E36, 0x1E36, 0), + (0x1E37, 0x1E37, 1), + (0x1E38, 0x1E38, 0), + (0x1E39, 0x1E39, 1), + (0x1E3A, 0x1E3A, 0), + (0x1E3B, 0x1E3B, 1), + (0x1E3C, 0x1E3C, 0), + (0x1E3D, 0x1E3D, 1), + (0x1E3E, 0x1E3E, 0), + (0x1E3F, 0x1E3F, 1), + (0x1E40, 0x1E40, 0), + (0x1E41, 0x1E41, 1), + (0x1E42, 0x1E42, 0), + (0x1E43, 0x1E43, 1), + (0x1E44, 0x1E44, 0), + (0x1E45, 0x1E45, 1), + (0x1E46, 0x1E46, 0), + (0x1E47, 0x1E47, 1), + (0x1E48, 0x1E48, 0), + (0x1E49, 0x1E49, 1), + (0x1E4A, 0x1E4A, 0), + (0x1E4B, 0x1E4B, 1), + (0x1E4C, 0x1E4C, 0), + (0x1E4D, 0x1E4D, 1), + (0x1E4E, 0x1E4E, 0), + (0x1E4F, 0x1E4F, 1), + (0x1E50, 0x1E50, 0), + (0x1E51, 0x1E51, 1), + (0x1E52, 0x1E52, 0), + (0x1E53, 0x1E53, 1), + (0x1E54, 0x1E54, 0), + (0x1E55, 0x1E55, 1), + (0x1E56, 0x1E56, 0), + (0x1E57, 0x1E57, 1), + (0x1E58, 0x1E58, 0), + (0x1E59, 0x1E59, 1), + (0x1E5A, 0x1E5A, 0), + (0x1E5B, 0x1E5B, 1), + (0x1E5C, 0x1E5C, 0), + (0x1E5D, 0x1E5D, 1), + (0x1E5E, 0x1E5E, 0), + (0x1E5F, 0x1E5F, 1), + (0x1E60, 0x1E60, 0), + (0x1E61, 0x1E61, 1), + (0x1E62, 0x1E62, 0), + (0x1E63, 0x1E63, 1), + (0x1E64, 0x1E64, 0), + (0x1E65, 0x1E65, 1), + (0x1E66, 0x1E66, 0), + (0x1E67, 0x1E67, 1), + (0x1E68, 0x1E68, 0), + (0x1E69, 0x1E69, 1), + (0x1E6A, 0x1E6A, 0), + (0x1E6B, 0x1E6B, 1), + (0x1E6C, 0x1E6C, 0), + (0x1E6D, 0x1E6D, 1), + (0x1E6E, 0x1E6E, 0), + (0x1E6F, 0x1E6F, 1), + (0x1E70, 0x1E70, 0), + (0x1E71, 0x1E71, 1), + (0x1E72, 0x1E72, 0), + (0x1E73, 0x1E73, 1), + (0x1E74, 0x1E74, 0), + (0x1E75, 0x1E75, 1), + (0x1E76, 0x1E76, 0), + (0x1E77, 0x1E77, 1), + (0x1E78, 0x1E78, 0), + (0x1E79, 0x1E79, 1), + (0x1E7A, 0x1E7A, 0), + (0x1E7B, 0x1E7B, 1), + (0x1E7C, 0x1E7C, 0), + (0x1E7D, 0x1E7D, 1), + (0x1E7E, 0x1E7E, 0), + (0x1E7F, 0x1E7F, 1), + (0x1E80, 0x1E80, 0), + (0x1E81, 0x1E81, 1), + (0x1E82, 0x1E82, 0), + (0x1E83, 0x1E83, 1), + (0x1E84, 0x1E84, 0), + (0x1E85, 0x1E85, 1), + (0x1E86, 0x1E86, 0), + (0x1E87, 0x1E87, 1), + (0x1E88, 0x1E88, 0), + (0x1E89, 0x1E89, 1), + (0x1E8A, 0x1E8A, 0), + (0x1E8B, 0x1E8B, 1), + (0x1E8C, 0x1E8C, 0), + (0x1E8D, 0x1E8D, 1), + (0x1E8E, 0x1E8E, 0), + (0x1E8F, 0x1E8F, 1), + (0x1E90, 0x1E90, 0), + (0x1E91, 0x1E91, 1), + (0x1E92, 0x1E92, 0), + (0x1E93, 0x1E93, 1), + (0x1E94, 0x1E94, 0), + (0x1E95, 0x1E9D, 1), + (0x1E9E, 0x1E9E, 0), + (0x1E9F, 0x1E9F, 1), + (0x1EA0, 0x1EA0, 0), + (0x1EA1, 0x1EA1, 1), + (0x1EA2, 0x1EA2, 0), + (0x1EA3, 0x1EA3, 1), + (0x1EA4, 0x1EA4, 0), + (0x1EA5, 0x1EA5, 1), + (0x1EA6, 0x1EA6, 0), + (0x1EA7, 0x1EA7, 1), + (0x1EA8, 0x1EA8, 0), + (0x1EA9, 0x1EA9, 1), + (0x1EAA, 0x1EAA, 0), + (0x1EAB, 0x1EAB, 1), + (0x1EAC, 0x1EAC, 0), + (0x1EAD, 0x1EAD, 1), + (0x1EAE, 0x1EAE, 0), + (0x1EAF, 0x1EAF, 1), + (0x1EB0, 0x1EB0, 0), + (0x1EB1, 0x1EB1, 1), + (0x1EB2, 0x1EB2, 0), + (0x1EB3, 0x1EB3, 1), + (0x1EB4, 0x1EB4, 0), + (0x1EB5, 0x1EB5, 1), + (0x1EB6, 0x1EB6, 0), + (0x1EB7, 0x1EB7, 1), + (0x1EB8, 0x1EB8, 0), + (0x1EB9, 0x1EB9, 1), + (0x1EBA, 0x1EBA, 0), + (0x1EBB, 0x1EBB, 1), + (0x1EBC, 0x1EBC, 0), + (0x1EBD, 0x1EBD, 1), + (0x1EBE, 0x1EBE, 0), + (0x1EBF, 0x1EBF, 1), + (0x1EC0, 0x1EC0, 0), + (0x1EC1, 0x1EC1, 1), + (0x1EC2, 0x1EC2, 0), + (0x1EC3, 0x1EC3, 1), + (0x1EC4, 0x1EC4, 0), + (0x1EC5, 0x1EC5, 1), + (0x1EC6, 0x1EC6, 0), + (0x1EC7, 0x1EC7, 1), + (0x1EC8, 0x1EC8, 0), + (0x1EC9, 0x1EC9, 1), + (0x1ECA, 0x1ECA, 0), + (0x1ECB, 0x1ECB, 1), + (0x1ECC, 0x1ECC, 0), + (0x1ECD, 0x1ECD, 1), + (0x1ECE, 0x1ECE, 0), + (0x1ECF, 0x1ECF, 1), + (0x1ED0, 0x1ED0, 0), + (0x1ED1, 0x1ED1, 1), + (0x1ED2, 0x1ED2, 0), + (0x1ED3, 0x1ED3, 1), + (0x1ED4, 0x1ED4, 0), + (0x1ED5, 0x1ED5, 1), + (0x1ED6, 0x1ED6, 0), + (0x1ED7, 0x1ED7, 1), + (0x1ED8, 0x1ED8, 0), + (0x1ED9, 0x1ED9, 1), + (0x1EDA, 0x1EDA, 0), + (0x1EDB, 0x1EDB, 1), + (0x1EDC, 0x1EDC, 0), + (0x1EDD, 0x1EDD, 1), + (0x1EDE, 0x1EDE, 0), + (0x1EDF, 0x1EDF, 1), + (0x1EE0, 0x1EE0, 0), + (0x1EE1, 0x1EE1, 1), + (0x1EE2, 0x1EE2, 0), + (0x1EE3, 0x1EE3, 1), + (0x1EE4, 0x1EE4, 0), + (0x1EE5, 0x1EE5, 1), + (0x1EE6, 0x1EE6, 0), + (0x1EE7, 0x1EE7, 1), + (0x1EE8, 0x1EE8, 0), + (0x1EE9, 0x1EE9, 1), + (0x1EEA, 0x1EEA, 0), + (0x1EEB, 0x1EEB, 1), + (0x1EEC, 0x1EEC, 0), + (0x1EED, 0x1EED, 1), + (0x1EEE, 0x1EEE, 0), + (0x1EEF, 0x1EEF, 1), + (0x1EF0, 0x1EF0, 0), + (0x1EF1, 0x1EF1, 1), + (0x1EF2, 0x1EF2, 0), + (0x1EF3, 0x1EF3, 1), + (0x1EF4, 0x1EF4, 0), + (0x1EF5, 0x1EF5, 1), + (0x1EF6, 0x1EF6, 0), + (0x1EF7, 0x1EF7, 1), + (0x1EF8, 0x1EF8, 0), + (0x1EF9, 0x1EF9, 1), + (0x1EFA, 0x1EFA, 0), + (0x1EFB, 0x1EFB, 1), + (0x1EFC, 0x1EFC, 0), + (0x1EFD, 0x1EFD, 1), + (0x1EFE, 0x1EFE, 0), + (0x1EFF, 0x1F07, 1), + (0x1F08, 0x1F0F, 0), + (0x1F10, 0x1F15, 1), + (0x1F16, 0x1F17, 29), + (0x1F18, 0x1F1D, 0), + (0x1F1E, 0x1F1F, 29), + (0x1F20, 0x1F27, 1), + (0x1F28, 0x1F2F, 0), + (0x1F30, 0x1F37, 1), + (0x1F38, 0x1F3F, 0), + (0x1F40, 0x1F45, 1), + (0x1F46, 0x1F47, 29), + (0x1F48, 0x1F4D, 0), + (0x1F4E, 0x1F4F, 29), + (0x1F50, 0x1F57, 1), + (0x1F58, 0x1F58, 29), + (0x1F59, 0x1F59, 0), + (0x1F5A, 0x1F5A, 29), + (0x1F5B, 0x1F5B, 0), + (0x1F5C, 0x1F5C, 29), + (0x1F5D, 0x1F5D, 0), + (0x1F5E, 0x1F5E, 29), + (0x1F5F, 0x1F5F, 0), + (0x1F60, 0x1F67, 1), + (0x1F68, 0x1F6F, 0), + (0x1F70, 0x1F7D, 1), + (0x1F7E, 0x1F7F, 29), + (0x1F80, 0x1F87, 1), + (0x1F88, 0x1F8F, 2), + (0x1F90, 0x1F97, 1), + (0x1F98, 0x1F9F, 2), + (0x1FA0, 0x1FA7, 1), + (0x1FA8, 0x1FAF, 2), + (0x1FB0, 0x1FB4, 1), + (0x1FB5, 0x1FB5, 29), + (0x1FB6, 0x1FB7, 1), + (0x1FB8, 0x1FBB, 0), + (0x1FBC, 0x1FBC, 2), + (0x1FBD, 0x1FBD, 20), + (0x1FBE, 0x1FBE, 1), + (0x1FBF, 0x1FC1, 20), + (0x1FC2, 0x1FC4, 1), + (0x1FC5, 0x1FC5, 29), + (0x1FC6, 0x1FC7, 1), + (0x1FC8, 0x1FCB, 0), + (0x1FCC, 0x1FCC, 2), + (0x1FCD, 0x1FCF, 20), + (0x1FD0, 0x1FD3, 1), + (0x1FD4, 0x1FD5, 29), + (0x1FD6, 0x1FD7, 1), + (0x1FD8, 0x1FDB, 0), + (0x1FDC, 0x1FDC, 29), + (0x1FDD, 0x1FDF, 20), + (0x1FE0, 0x1FE7, 1), + (0x1FE8, 0x1FEC, 0), + (0x1FED, 0x1FEF, 20), + (0x1FF0, 0x1FF1, 29), + (0x1FF2, 0x1FF4, 1), + (0x1FF5, 0x1FF5, 29), + (0x1FF6, 0x1FF7, 1), + (0x1FF8, 0x1FFB, 0), + (0x1FFC, 0x1FFC, 2), + (0x1FFD, 0x1FFE, 20), + (0x1FFF, 0x1FFF, 29), + (0x2000, 0x200A, 22), + (0x200B, 0x200F, 26), + (0x2010, 0x2015, 12), + (0x2016, 0x2017, 17), + (0x2018, 0x2018, 15), + (0x2019, 0x2019, 16), + (0x201A, 0x201A, 13), + (0x201B, 0x201C, 15), + (0x201D, 0x201D, 16), + (0x201E, 0x201E, 13), + (0x201F, 0x201F, 15), + (0x2020, 0x2027, 17), + (0x2028, 0x2028, 23), + (0x2029, 0x2029, 24), + (0x202A, 0x202E, 26), + (0x202F, 0x202F, 22), + (0x2030, 0x2038, 17), + (0x2039, 0x2039, 15), + (0x203A, 0x203A, 16), + (0x203B, 0x203E, 17), + (0x203F, 0x2040, 11), + (0x2041, 0x2043, 17), + (0x2044, 0x2044, 18), + (0x2045, 0x2045, 13), + (0x2046, 0x2046, 14), + (0x2047, 0x2051, 17), + (0x2052, 0x2052, 18), + (0x2053, 0x2053, 17), + (0x2054, 0x2054, 11), + (0x2055, 0x205E, 17), + (0x205F, 0x205F, 22), + (0x2060, 0x2064, 26), + (0x2065, 0x2065, 29), + (0x2066, 0x206F, 26), + (0x2070, 0x2070, 10), + (0x2071, 0x2071, 3), + (0x2072, 0x2073, 29), + (0x2074, 0x2079, 10), + (0x207A, 0x207C, 18), + (0x207D, 0x207D, 13), + (0x207E, 0x207E, 14), + (0x207F, 0x207F, 3), + (0x2080, 0x2089, 10), + (0x208A, 0x208C, 18), + (0x208D, 0x208D, 13), + (0x208E, 0x208E, 14), + (0x208F, 0x209F, 3), + (0x20A0, 0x20C4, 19), + (0x20C5, 0x20CF, 29), + (0x20D0, 0x20DC, 5), + (0x20DD, 0x20E0, 7), + (0x20E1, 0x20E1, 5), + (0x20E2, 0x20E4, 7), + (0x20E5, 0x20F0, 5), + (0x20F1, 0x20FF, 29), + (0x2100, 0x2101, 21), + (0x2102, 0x2102, 0), + (0x2103, 0x2106, 21), + (0x2107, 0x2107, 0), + (0x2108, 0x2109, 21), + (0x210A, 0x210A, 1), + (0x210B, 0x210D, 0), + (0x210E, 0x210F, 1), + (0x2110, 0x2112, 0), + (0x2113, 0x2113, 1), + (0x2114, 0x2114, 21), + (0x2115, 0x2115, 0), + (0x2116, 0x2117, 21), + (0x2118, 0x2118, 18), + (0x2119, 0x211D, 0), + (0x211E, 0x2123, 21), + (0x2124, 0x2124, 0), + (0x2125, 0x2125, 21), + (0x2126, 0x2126, 0), + (0x2127, 0x2127, 21), + (0x2128, 0x2128, 0), + (0x2129, 0x2129, 21), + (0x212A, 0x212D, 0), + (0x212E, 0x212E, 21), + (0x212F, 0x212F, 1), + (0x2130, 0x2133, 0), + (0x2134, 0x2134, 1), + (0x2135, 0x2138, 4), + (0x2139, 0x2139, 1), + (0x213A, 0x213B, 21), + (0x213C, 0x213D, 1), + (0x213E, 0x213F, 0), + (0x2140, 0x2144, 18), + (0x2145, 0x2145, 0), + (0x2146, 0x2149, 1), + (0x214A, 0x214A, 21), + (0x214B, 0x214B, 18), + (0x214C, 0x214D, 21), + (0x214E, 0x214E, 1), + (0x214F, 0x214F, 21), + (0x2150, 0x215F, 10), + (0x2160, 0x2182, 9), + (0x2183, 0x2183, 0), + (0x2184, 0x2184, 1), + (0x2185, 0x2188, 9), + (0x2189, 0x2189, 10), + (0x218A, 0x218B, 21), + (0x218C, 0x218F, 29), + (0x2190, 0x2194, 18), + (0x2195, 0x2199, 21), + (0x219A, 0x219B, 18), + (0x219C, 0x219F, 21), + (0x21A0, 0x21A0, 18), + (0x21A1, 0x21A2, 21), + (0x21A3, 0x21A3, 18), + (0x21A4, 0x21A5, 21), + (0x21A6, 0x21A6, 18), + (0x21A7, 0x21AD, 21), + (0x21AE, 0x21AE, 18), + (0x21AF, 0x21CD, 21), + (0x21CE, 0x21CF, 18), + (0x21D0, 0x21D1, 21), + (0x21D2, 0x21D2, 18), + (0x21D3, 0x21D3, 21), + (0x21D4, 0x21D4, 18), + (0x21D5, 0x21F3, 21), + (0x21F4, 0x22FF, 18), + (0x2300, 0x2307, 21), + (0x2308, 0x2308, 13), + (0x2309, 0x2309, 14), + (0x230A, 0x230A, 13), + (0x230B, 0x230B, 14), + (0x230C, 0x231F, 21), + (0x2320, 0x2321, 18), + (0x2322, 0x2328, 21), + (0x2329, 0x2329, 13), + (0x232A, 0x232A, 14), + (0x232B, 0x237B, 21), + (0x237C, 0x237C, 18), + (0x237D, 0x239A, 21), + (0x239B, 0x23B3, 18), + (0x23B4, 0x23DB, 21), + (0x23DC, 0x23E1, 18), + (0x23E2, 0x2429, 21), + (0x242A, 0x243F, 29), + (0x2440, 0x244A, 21), + (0x244B, 0x245F, 29), + (0x2460, 0x249B, 10), + (0x249C, 0x24E9, 21), + (0x24EA, 0x24FF, 10), + (0x2500, 0x25B6, 21), + (0x25B7, 0x25B7, 18), + (0x25B8, 0x25C0, 21), + (0x25C1, 0x25C1, 18), + (0x25C2, 0x25F7, 21), + (0x25F8, 0x25FF, 18), + (0x2600, 0x266E, 21), + (0x266F, 0x266F, 18), + (0x2670, 0x2767, 21), + (0x2768, 0x2768, 13), + (0x2769, 0x2769, 14), + (0x276A, 0x276A, 13), + (0x276B, 0x276B, 14), + (0x276C, 0x276C, 13), + (0x276D, 0x276D, 14), + (0x276E, 0x276E, 13), + (0x276F, 0x276F, 14), + (0x2770, 0x2770, 13), + (0x2771, 0x2771, 14), + (0x2772, 0x2772, 13), + (0x2773, 0x2773, 14), + (0x2774, 0x2774, 13), + (0x2775, 0x2775, 14), + (0x2776, 0x2793, 10), + (0x2794, 0x27BF, 21), + (0x27C0, 0x27C4, 18), + (0x27C5, 0x27C5, 13), + (0x27C6, 0x27C6, 14), + (0x27C7, 0x27E5, 18), + (0x27E6, 0x27E6, 13), + (0x27E7, 0x27E7, 14), + (0x27E8, 0x27E8, 13), + (0x27E9, 0x27E9, 14), + (0x27EA, 0x27EA, 13), + (0x27EB, 0x27EB, 14), + (0x27EC, 0x27EC, 13), + (0x27ED, 0x27ED, 14), + (0x27EE, 0x27EE, 13), + (0x27EF, 0x27EF, 14), + (0x27F0, 0x27FF, 18), + (0x2800, 0x28FF, 21), + (0x2900, 0x2982, 18), + (0x2983, 0x2983, 13), + (0x2984, 0x2984, 14), + (0x2985, 0x2985, 13), + (0x2986, 0x2986, 14), + (0x2987, 0x2987, 13), + (0x2988, 0x2988, 14), + (0x2989, 0x2989, 13), + (0x298A, 0x298A, 14), + (0x298B, 0x298B, 13), + (0x298C, 0x298C, 14), + (0x298D, 0x298D, 13), + (0x298E, 0x298E, 14), + (0x298F, 0x298F, 13), + (0x2990, 0x2990, 14), + (0x2991, 0x2991, 13), + (0x2992, 0x2992, 14), + (0x2993, 0x2993, 13), + (0x2994, 0x2994, 14), + (0x2995, 0x2995, 13), + (0x2996, 0x2996, 14), + (0x2997, 0x2997, 13), + (0x2998, 0x2998, 14), + (0x2999, 0x29D7, 18), + (0x29D8, 0x29D8, 13), + (0x29D9, 0x29D9, 14), + (0x29DA, 0x29DA, 13), + (0x29DB, 0x29DB, 14), + (0x29DC, 0x29FB, 18), + (0x29FC, 0x29FC, 13), + (0x29FD, 0x29FD, 14), + (0x29FE, 0x2AFF, 18), + (0x2B00, 0x2B2F, 21), + (0x2B30, 0x2B44, 18), + (0x2B45, 0x2B46, 21), + (0x2B47, 0x2B4C, 18), + (0x2B4D, 0x2B73, 21), + (0x2B74, 0x2B75, 29), + (0x2B76, 0x2BFF, 21), + (0x2C00, 0x2C2F, 0), + (0x2C30, 0x2C5F, 1), + (0x2C60, 0x2C60, 0), + (0x2C61, 0x2C61, 1), + (0x2C62, 0x2C64, 0), + (0x2C65, 0x2C66, 1), + (0x2C67, 0x2C67, 0), + (0x2C68, 0x2C68, 1), + (0x2C69, 0x2C69, 0), + (0x2C6A, 0x2C6A, 1), + (0x2C6B, 0x2C6B, 0), + (0x2C6C, 0x2C6C, 1), + (0x2C6D, 0x2C70, 0), + (0x2C71, 0x2C71, 1), + (0x2C72, 0x2C72, 0), + (0x2C73, 0x2C74, 1), + (0x2C75, 0x2C75, 0), + (0x2C76, 0x2C7B, 1), + (0x2C7C, 0x2C7D, 3), + (0x2C7E, 0x2C80, 0), + (0x2C81, 0x2C81, 1), + (0x2C82, 0x2C82, 0), + (0x2C83, 0x2C83, 1), + (0x2C84, 0x2C84, 0), + (0x2C85, 0x2C85, 1), + (0x2C86, 0x2C86, 0), + (0x2C87, 0x2C87, 1), + (0x2C88, 0x2C88, 0), + (0x2C89, 0x2C89, 1), + (0x2C8A, 0x2C8A, 0), + (0x2C8B, 0x2C8B, 1), + (0x2C8C, 0x2C8C, 0), + (0x2C8D, 0x2C8D, 1), + (0x2C8E, 0x2C8E, 0), + (0x2C8F, 0x2C8F, 1), + (0x2C90, 0x2C90, 0), + (0x2C91, 0x2C91, 1), + (0x2C92, 0x2C92, 0), + (0x2C93, 0x2C93, 1), + (0x2C94, 0x2C94, 0), + (0x2C95, 0x2C95, 1), + (0x2C96, 0x2C96, 0), + (0x2C97, 0x2C97, 1), + (0x2C98, 0x2C98, 0), + (0x2C99, 0x2C99, 1), + (0x2C9A, 0x2C9A, 0), + (0x2C9B, 0x2C9B, 1), + (0x2C9C, 0x2C9C, 0), + (0x2C9D, 0x2C9D, 1), + (0x2C9E, 0x2C9E, 0), + (0x2C9F, 0x2C9F, 1), + (0x2CA0, 0x2CA0, 0), + (0x2CA1, 0x2CA1, 1), + (0x2CA2, 0x2CA2, 0), + (0x2CA3, 0x2CA3, 1), + (0x2CA4, 0x2CA4, 0), + (0x2CA5, 0x2CA5, 1), + (0x2CA6, 0x2CA6, 0), + (0x2CA7, 0x2CA7, 1), + (0x2CA8, 0x2CA8, 0), + (0x2CA9, 0x2CA9, 1), + (0x2CAA, 0x2CAA, 0), + (0x2CAB, 0x2CAB, 1), + (0x2CAC, 0x2CAC, 0), + (0x2CAD, 0x2CAD, 1), + (0x2CAE, 0x2CAE, 0), + (0x2CAF, 0x2CAF, 1), + (0x2CB0, 0x2CB0, 0), + (0x2CB1, 0x2CB1, 1), + (0x2CB2, 0x2CB2, 0), + (0x2CB3, 0x2CB3, 1), + (0x2CB4, 0x2CB4, 0), + (0x2CB5, 0x2CB5, 1), + (0x2CB6, 0x2CB6, 0), + (0x2CB7, 0x2CB7, 1), + (0x2CB8, 0x2CB8, 0), + (0x2CB9, 0x2CB9, 1), + (0x2CBA, 0x2CBA, 0), + (0x2CBB, 0x2CBB, 1), + (0x2CBC, 0x2CBC, 0), + (0x2CBD, 0x2CBD, 1), + (0x2CBE, 0x2CBE, 0), + (0x2CBF, 0x2CBF, 1), + (0x2CC0, 0x2CC0, 0), + (0x2CC1, 0x2CC1, 1), + (0x2CC2, 0x2CC2, 0), + (0x2CC3, 0x2CC3, 1), + (0x2CC4, 0x2CC4, 0), + (0x2CC5, 0x2CC5, 1), + (0x2CC6, 0x2CC6, 0), + (0x2CC7, 0x2CC7, 1), + (0x2CC8, 0x2CC8, 0), + (0x2CC9, 0x2CC9, 1), + (0x2CCA, 0x2CCA, 0), + (0x2CCB, 0x2CCB, 1), + (0x2CCC, 0x2CCC, 0), + (0x2CCD, 0x2CCD, 1), + (0x2CCE, 0x2CCE, 0), + (0x2CCF, 0x2CCF, 1), + (0x2CD0, 0x2CD0, 0), + (0x2CD1, 0x2CD1, 1), + (0x2CD2, 0x2CD2, 0), + (0x2CD3, 0x2CD3, 1), + (0x2CD4, 0x2CD4, 0), + (0x2CD5, 0x2CD5, 1), + (0x2CD6, 0x2CD6, 0), + (0x2CD7, 0x2CD7, 1), + (0x2CD8, 0x2CD8, 0), + (0x2CD9, 0x2CD9, 1), + (0x2CDA, 0x2CDA, 0), + (0x2CDB, 0x2CDB, 1), + (0x2CDC, 0x2CDC, 0), + (0x2CDD, 0x2CDD, 1), + (0x2CDE, 0x2CDE, 0), + (0x2CDF, 0x2CDF, 1), + (0x2CE0, 0x2CE0, 0), + (0x2CE1, 0x2CE1, 1), + (0x2CE2, 0x2CE2, 0), + (0x2CE3, 0x2CE4, 1), + (0x2CE5, 0x2CEA, 21), + (0x2CEB, 0x2CEB, 0), + (0x2CEC, 0x2CEC, 1), + (0x2CED, 0x2CED, 0), + (0x2CEE, 0x2CEE, 1), + (0x2CEF, 0x2CF1, 5), + (0x2CF2, 0x2CF2, 0), + (0x2CF3, 0x2CF3, 1), + (0x2CF4, 0x2CF8, 29), + (0x2CF9, 0x2CFC, 17), + (0x2CFD, 0x2CFD, 10), + (0x2CFE, 0x2CFF, 17), + (0x2D00, 0x2D25, 1), + (0x2D26, 0x2D26, 29), + (0x2D27, 0x2D27, 1), + (0x2D28, 0x2D2C, 29), + (0x2D2D, 0x2D2D, 1), + (0x2D2E, 0x2D2F, 29), + (0x2D30, 0x2D67, 4), + (0x2D68, 0x2D6E, 29), + (0x2D6F, 0x2D6F, 3), + (0x2D70, 0x2D70, 17), + (0x2D71, 0x2D7E, 29), + (0x2D7F, 0x2D7F, 5), + (0x2D80, 0x2D96, 4), + (0x2D97, 0x2D9F, 29), + (0x2DA0, 0x2DA6, 4), + (0x2DA7, 0x2DA7, 29), + (0x2DA8, 0x2DAE, 4), + (0x2DAF, 0x2DAF, 29), + (0x2DB0, 0x2DB6, 4), + (0x2DB7, 0x2DB7, 29), + (0x2DB8, 0x2DBE, 4), + (0x2DBF, 0x2DBF, 29), + (0x2DC0, 0x2DC6, 4), + (0x2DC7, 0x2DC7, 29), + (0x2DC8, 0x2DCE, 4), + (0x2DCF, 0x2DCF, 29), + (0x2DD0, 0x2DD6, 4), + (0x2DD7, 0x2DD7, 29), + (0x2DD8, 0x2DDE, 4), + (0x2DDF, 0x2DDF, 29), + (0x2DE0, 0x2DFF, 5), + (0x2E00, 0x2E01, 17), + (0x2E02, 0x2E02, 15), + (0x2E03, 0x2E03, 16), + (0x2E04, 0x2E04, 15), + (0x2E05, 0x2E05, 16), + (0x2E06, 0x2E08, 17), + (0x2E09, 0x2E09, 15), + (0x2E0A, 0x2E0A, 16), + (0x2E0B, 0x2E0B, 17), + (0x2E0C, 0x2E0C, 15), + (0x2E0D, 0x2E0D, 16), + (0x2E0E, 0x2E16, 17), + (0x2E17, 0x2E17, 12), + (0x2E18, 0x2E19, 17), + (0x2E1A, 0x2E1A, 12), + (0x2E1B, 0x2E1B, 17), + (0x2E1C, 0x2E1C, 15), + (0x2E1D, 0x2E1D, 16), + (0x2E1E, 0x2E1F, 17), + (0x2E20, 0x2E20, 15), + (0x2E21, 0x2E21, 16), + (0x2E22, 0x2E22, 13), + (0x2E23, 0x2E23, 14), + (0x2E24, 0x2E24, 13), + (0x2E25, 0x2E25, 14), + (0x2E26, 0x2E26, 13), + (0x2E27, 0x2E27, 14), + (0x2E28, 0x2E28, 13), + (0x2E29, 0x2E29, 14), + (0x2E2A, 0x2E2E, 17), + (0x2E2F, 0x2E2F, 3), + (0x2E30, 0x2E39, 17), + (0x2E3A, 0x2E3B, 12), + (0x2E3C, 0x2E3F, 17), + (0x2E40, 0x2E40, 12), + (0x2E41, 0x2E41, 17), + (0x2E42, 0x2E42, 13), + (0x2E43, 0x2E4F, 17), + (0x2E50, 0x2E51, 21), + (0x2E52, 0x2E54, 17), + (0x2E55, 0x2E55, 13), + (0x2E56, 0x2E56, 14), + (0x2E57, 0x2E57, 13), + (0x2E58, 0x2E58, 14), + (0x2E59, 0x2E59, 13), + (0x2E5A, 0x2E5A, 14), + (0x2E5B, 0x2E5B, 13), + (0x2E5C, 0x2E5C, 14), + (0x2E5D, 0x2E5D, 12), + (0x2E5E, 0x2E5F, 29), + (0x2E60, 0x2E61, 17), + (0x2E62, 0x2E62, 13), + (0x2E63, 0x2E63, 14), + (0x2E64, 0x2E7F, 29), + (0x2E80, 0x2E99, 21), + (0x2E9A, 0x2E9A, 29), + (0x2E9B, 0x2EF3, 21), + (0x2EF4, 0x2EFF, 29), + (0x2F00, 0x2FD5, 21), + (0x2FD6, 0x2FEF, 29), + (0x2FF0, 0x2FFF, 21), + (0x3000, 0x3000, 22), + (0x3001, 0x3003, 17), + (0x3004, 0x3004, 21), + (0x3005, 0x3005, 3), + (0x3006, 0x3006, 4), + (0x3007, 0x3007, 9), + (0x3008, 0x3008, 13), + (0x3009, 0x3009, 14), + (0x300A, 0x300A, 13), + (0x300B, 0x300B, 14), + (0x300C, 0x300C, 13), + (0x300D, 0x300D, 14), + (0x300E, 0x300E, 13), + (0x300F, 0x300F, 14), + (0x3010, 0x3010, 13), + (0x3011, 0x3011, 14), + (0x3012, 0x3013, 21), + (0x3014, 0x3014, 13), + (0x3015, 0x3015, 14), + (0x3016, 0x3016, 13), + (0x3017, 0x3017, 14), + (0x3018, 0x3018, 13), + (0x3019, 0x3019, 14), + (0x301A, 0x301A, 13), + (0x301B, 0x301B, 14), + (0x301C, 0x301C, 12), + (0x301D, 0x301D, 13), + (0x301E, 0x301F, 14), + (0x3020, 0x3020, 21), + (0x3021, 0x3029, 9), + (0x302A, 0x302D, 5), + (0x302E, 0x302F, 6), + (0x3030, 0x3030, 12), + (0x3031, 0x3035, 3), + (0x3036, 0x3037, 21), + (0x3038, 0x303A, 9), + (0x303B, 0x303B, 3), + (0x303C, 0x303C, 4), + (0x303D, 0x303D, 17), + (0x303E, 0x303F, 21), + (0x3040, 0x3040, 29), + (0x3041, 0x3096, 4), + (0x3097, 0x3098, 29), + (0x3099, 0x309A, 5), + (0x309B, 0x309C, 20), + (0x309D, 0x309E, 3), + (0x309F, 0x309F, 4), + (0x30A0, 0x30A0, 12), + (0x30A1, 0x30FA, 4), + (0x30FB, 0x30FB, 17), + (0x30FC, 0x30FE, 3), + (0x30FF, 0x30FF, 4), + (0x3100, 0x3104, 29), + (0x3105, 0x312F, 4), + (0x3130, 0x3130, 29), + (0x3131, 0x318E, 4), + (0x318F, 0x318F, 29), + (0x3190, 0x3191, 21), + (0x3192, 0x3195, 10), + (0x3196, 0x319F, 21), + (0x31A0, 0x31BF, 4), + (0x31C0, 0x31E5, 21), + (0x31E6, 0x31EE, 29), + (0x31EF, 0x31EF, 21), + (0x31F0, 0x31FF, 4), + (0x3200, 0x321E, 21), + (0x321F, 0x321F, 29), + (0x3220, 0x3229, 10), + (0x322A, 0x3247, 21), + (0x3248, 0x324F, 10), + (0x3250, 0x3250, 21), + (0x3251, 0x325F, 10), + (0x3260, 0x327F, 21), + (0x3280, 0x3289, 10), + (0x328A, 0x32B0, 21), + (0x32B1, 0x32BF, 10), + (0x32C0, 0x33FF, 21), + (0x3400, 0x4DBF, 4), + (0x4DC0, 0x4DFF, 21), + (0x4E00, 0xA014, 4), + (0xA015, 0xA015, 3), + (0xA016, 0xA48C, 4), + (0xA48D, 0xA48F, 29), + (0xA490, 0xA4C6, 21), + (0xA4C7, 0xA4CF, 29), + (0xA4D0, 0xA4F7, 4), + (0xA4F8, 0xA4FD, 3), + (0xA4FE, 0xA4FF, 17), + (0xA500, 0xA60B, 4), + (0xA60C, 0xA60C, 3), + (0xA60D, 0xA60F, 17), + (0xA610, 0xA61F, 4), + (0xA620, 0xA629, 8), + (0xA62A, 0xA62B, 4), + (0xA62C, 0xA63F, 29), + (0xA640, 0xA640, 0), + (0xA641, 0xA641, 1), + (0xA642, 0xA642, 0), + (0xA643, 0xA643, 1), + (0xA644, 0xA644, 0), + (0xA645, 0xA645, 1), + (0xA646, 0xA646, 0), + (0xA647, 0xA647, 1), + (0xA648, 0xA648, 0), + (0xA649, 0xA649, 1), + (0xA64A, 0xA64A, 0), + (0xA64B, 0xA64B, 1), + (0xA64C, 0xA64C, 0), + (0xA64D, 0xA64D, 1), + (0xA64E, 0xA64E, 0), + (0xA64F, 0xA64F, 1), + (0xA650, 0xA650, 0), + (0xA651, 0xA651, 1), + (0xA652, 0xA652, 0), + (0xA653, 0xA653, 1), + (0xA654, 0xA654, 0), + (0xA655, 0xA655, 1), + (0xA656, 0xA656, 0), + (0xA657, 0xA657, 1), + (0xA658, 0xA658, 0), + (0xA659, 0xA659, 1), + (0xA65A, 0xA65A, 0), + (0xA65B, 0xA65B, 1), + (0xA65C, 0xA65C, 0), + (0xA65D, 0xA65D, 1), + (0xA65E, 0xA65E, 0), + (0xA65F, 0xA65F, 1), + (0xA660, 0xA660, 0), + (0xA661, 0xA661, 1), + (0xA662, 0xA662, 0), + (0xA663, 0xA663, 1), + (0xA664, 0xA664, 0), + (0xA665, 0xA665, 1), + (0xA666, 0xA666, 0), + (0xA667, 0xA667, 1), + (0xA668, 0xA668, 0), + (0xA669, 0xA669, 1), + (0xA66A, 0xA66A, 0), + (0xA66B, 0xA66B, 1), + (0xA66C, 0xA66C, 0), + (0xA66D, 0xA66D, 1), + (0xA66E, 0xA66E, 4), + (0xA66F, 0xA66F, 5), + (0xA670, 0xA672, 7), + (0xA673, 0xA673, 17), + (0xA674, 0xA67D, 5), + (0xA67E, 0xA67E, 17), + (0xA67F, 0xA67F, 3), + (0xA680, 0xA680, 0), + (0xA681, 0xA681, 1), + (0xA682, 0xA682, 0), + (0xA683, 0xA683, 1), + (0xA684, 0xA684, 0), + (0xA685, 0xA685, 1), + (0xA686, 0xA686, 0), + (0xA687, 0xA687, 1), + (0xA688, 0xA688, 0), + (0xA689, 0xA689, 1), + (0xA68A, 0xA68A, 0), + (0xA68B, 0xA68B, 1), + (0xA68C, 0xA68C, 0), + (0xA68D, 0xA68D, 1), + (0xA68E, 0xA68E, 0), + (0xA68F, 0xA68F, 1), + (0xA690, 0xA690, 0), + (0xA691, 0xA691, 1), + (0xA692, 0xA692, 0), + (0xA693, 0xA693, 1), + (0xA694, 0xA694, 0), + (0xA695, 0xA695, 1), + (0xA696, 0xA696, 0), + (0xA697, 0xA697, 1), + (0xA698, 0xA698, 0), + (0xA699, 0xA699, 1), + (0xA69A, 0xA69A, 0), + (0xA69B, 0xA69B, 1), + (0xA69C, 0xA69D, 3), + (0xA69E, 0xA69F, 5), + (0xA6A0, 0xA6E5, 4), + (0xA6E6, 0xA6EF, 9), + (0xA6F0, 0xA6F1, 5), + (0xA6F2, 0xA6F7, 17), + (0xA6F8, 0xA6FF, 29), + (0xA700, 0xA716, 20), + (0xA717, 0xA71F, 3), + (0xA720, 0xA721, 20), + (0xA722, 0xA722, 0), + (0xA723, 0xA723, 1), + (0xA724, 0xA724, 0), + (0xA725, 0xA725, 1), + (0xA726, 0xA726, 0), + (0xA727, 0xA727, 1), + (0xA728, 0xA728, 0), + (0xA729, 0xA729, 1), + (0xA72A, 0xA72A, 0), + (0xA72B, 0xA72B, 1), + (0xA72C, 0xA72C, 0), + (0xA72D, 0xA72D, 1), + (0xA72E, 0xA72E, 0), + (0xA72F, 0xA731, 1), + (0xA732, 0xA732, 0), + (0xA733, 0xA733, 1), + (0xA734, 0xA734, 0), + (0xA735, 0xA735, 1), + (0xA736, 0xA736, 0), + (0xA737, 0xA737, 1), + (0xA738, 0xA738, 0), + (0xA739, 0xA739, 1), + (0xA73A, 0xA73A, 0), + (0xA73B, 0xA73B, 1), + (0xA73C, 0xA73C, 0), + (0xA73D, 0xA73D, 1), + (0xA73E, 0xA73E, 0), + (0xA73F, 0xA73F, 1), + (0xA740, 0xA740, 0), + (0xA741, 0xA741, 1), + (0xA742, 0xA742, 0), + (0xA743, 0xA743, 1), + (0xA744, 0xA744, 0), + (0xA745, 0xA745, 1), + (0xA746, 0xA746, 0), + (0xA747, 0xA747, 1), + (0xA748, 0xA748, 0), + (0xA749, 0xA749, 1), + (0xA74A, 0xA74A, 0), + (0xA74B, 0xA74B, 1), + (0xA74C, 0xA74C, 0), + (0xA74D, 0xA74D, 1), + (0xA74E, 0xA74E, 0), + (0xA74F, 0xA74F, 1), + (0xA750, 0xA750, 0), + (0xA751, 0xA751, 1), + (0xA752, 0xA752, 0), + (0xA753, 0xA753, 1), + (0xA754, 0xA754, 0), + (0xA755, 0xA755, 1), + (0xA756, 0xA756, 0), + (0xA757, 0xA757, 1), + (0xA758, 0xA758, 0), + (0xA759, 0xA759, 1), + (0xA75A, 0xA75A, 0), + (0xA75B, 0xA75B, 1), + (0xA75C, 0xA75C, 0), + (0xA75D, 0xA75D, 1), + (0xA75E, 0xA75E, 0), + (0xA75F, 0xA75F, 1), + (0xA760, 0xA760, 0), + (0xA761, 0xA761, 1), + (0xA762, 0xA762, 0), + (0xA763, 0xA763, 1), + (0xA764, 0xA764, 0), + (0xA765, 0xA765, 1), + (0xA766, 0xA766, 0), + (0xA767, 0xA767, 1), + (0xA768, 0xA768, 0), + (0xA769, 0xA769, 1), + (0xA76A, 0xA76A, 0), + (0xA76B, 0xA76B, 1), + (0xA76C, 0xA76C, 0), + (0xA76D, 0xA76D, 1), + (0xA76E, 0xA76E, 0), + (0xA76F, 0xA76F, 1), + (0xA770, 0xA770, 3), + (0xA771, 0xA778, 1), + (0xA779, 0xA779, 0), + (0xA77A, 0xA77A, 1), + (0xA77B, 0xA77B, 0), + (0xA77C, 0xA77C, 1), + (0xA77D, 0xA77E, 0), + (0xA77F, 0xA77F, 1), + (0xA780, 0xA780, 0), + (0xA781, 0xA781, 1), + (0xA782, 0xA782, 0), + (0xA783, 0xA783, 1), + (0xA784, 0xA784, 0), + (0xA785, 0xA785, 1), + (0xA786, 0xA786, 0), + (0xA787, 0xA787, 1), + (0xA788, 0xA788, 3), + (0xA789, 0xA78A, 20), + (0xA78B, 0xA78B, 0), + (0xA78C, 0xA78C, 1), + (0xA78D, 0xA78D, 0), + (0xA78E, 0xA78E, 1), + (0xA78F, 0xA78F, 4), + (0xA790, 0xA790, 0), + (0xA791, 0xA791, 1), + (0xA792, 0xA792, 0), + (0xA793, 0xA795, 1), + (0xA796, 0xA796, 0), + (0xA797, 0xA797, 1), + (0xA798, 0xA798, 0), + (0xA799, 0xA799, 1), + (0xA79A, 0xA79A, 0), + (0xA79B, 0xA79B, 1), + (0xA79C, 0xA79C, 0), + (0xA79D, 0xA79D, 1), + (0xA79E, 0xA79E, 0), + (0xA79F, 0xA79F, 1), + (0xA7A0, 0xA7A0, 0), + (0xA7A1, 0xA7A1, 1), + (0xA7A2, 0xA7A2, 0), + (0xA7A3, 0xA7A3, 1), + (0xA7A4, 0xA7A4, 0), + (0xA7A5, 0xA7A5, 1), + (0xA7A6, 0xA7A6, 0), + (0xA7A7, 0xA7A7, 1), + (0xA7A8, 0xA7A8, 0), + (0xA7A9, 0xA7A9, 1), + (0xA7AA, 0xA7AE, 0), + (0xA7AF, 0xA7AF, 1), + (0xA7B0, 0xA7B4, 0), + (0xA7B5, 0xA7B5, 1), + (0xA7B6, 0xA7B6, 0), + (0xA7B7, 0xA7B7, 1), + (0xA7B8, 0xA7B8, 0), + (0xA7B9, 0xA7B9, 1), + (0xA7BA, 0xA7BA, 0), + (0xA7BB, 0xA7BB, 1), + (0xA7BC, 0xA7BC, 0), + (0xA7BD, 0xA7BD, 1), + (0xA7BE, 0xA7BE, 0), + (0xA7BF, 0xA7BF, 1), + (0xA7C0, 0xA7C0, 0), + (0xA7C1, 0xA7C1, 1), + (0xA7C2, 0xA7C2, 0), + (0xA7C3, 0xA7C3, 1), + (0xA7C4, 0xA7C7, 0), + (0xA7C8, 0xA7C8, 1), + (0xA7C9, 0xA7C9, 0), + (0xA7CA, 0xA7CA, 1), + (0xA7CB, 0xA7CC, 0), + (0xA7CD, 0xA7CD, 1), + (0xA7CE, 0xA7CE, 0), + (0xA7CF, 0xA7CF, 1), + (0xA7D0, 0xA7D0, 0), + (0xA7D1, 0xA7D1, 1), + (0xA7D2, 0xA7D2, 0), + (0xA7D3, 0xA7D3, 1), + (0xA7D4, 0xA7D4, 0), + (0xA7D5, 0xA7D5, 1), + (0xA7D6, 0xA7D6, 0), + (0xA7D7, 0xA7D7, 1), + (0xA7D8, 0xA7D8, 0), + (0xA7D9, 0xA7D9, 1), + (0xA7DA, 0xA7DA, 0), + (0xA7DB, 0xA7DB, 1), + (0xA7DC, 0xA7DD, 0), + (0xA7DE, 0xA7E1, 29), + (0xA7E2, 0xA7E2, 0), + (0xA7E3, 0xA7F0, 29), + (0xA7F1, 0xA7F4, 3), + (0xA7F5, 0xA7F5, 0), + (0xA7F6, 0xA7F6, 1), + (0xA7F7, 0xA7F7, 4), + (0xA7F8, 0xA7F9, 3), + (0xA7FA, 0xA7FA, 1), + (0xA7FB, 0xA801, 4), + (0xA802, 0xA802, 5), + (0xA803, 0xA805, 4), + (0xA806, 0xA806, 5), + (0xA807, 0xA80A, 4), + (0xA80B, 0xA80B, 5), + (0xA80C, 0xA822, 4), + (0xA823, 0xA824, 6), + (0xA825, 0xA826, 5), + (0xA827, 0xA827, 6), + (0xA828, 0xA82B, 21), + (0xA82C, 0xA82C, 5), + (0xA82D, 0xA82F, 29), + (0xA830, 0xA835, 10), + (0xA836, 0xA837, 21), + (0xA838, 0xA838, 19), + (0xA839, 0xA839, 21), + (0xA83A, 0xA83F, 29), + (0xA840, 0xA873, 4), + (0xA874, 0xA877, 17), + (0xA878, 0xA87F, 29), + (0xA880, 0xA881, 6), + (0xA882, 0xA8B3, 4), + (0xA8B4, 0xA8C3, 6), + (0xA8C4, 0xA8C5, 5), + (0xA8C6, 0xA8CD, 29), + (0xA8CE, 0xA8CF, 17), + (0xA8D0, 0xA8D9, 8), + (0xA8DA, 0xA8DF, 29), + (0xA8E0, 0xA8F1, 5), + (0xA8F2, 0xA8F7, 4), + (0xA8F8, 0xA8FA, 17), + (0xA8FB, 0xA8FB, 4), + (0xA8FC, 0xA8FC, 17), + (0xA8FD, 0xA8FE, 4), + (0xA8FF, 0xA8FF, 5), + (0xA900, 0xA909, 8), + (0xA90A, 0xA925, 4), + (0xA926, 0xA92D, 5), + (0xA92E, 0xA92F, 17), + (0xA930, 0xA946, 4), + (0xA947, 0xA951, 5), + (0xA952, 0xA953, 6), + (0xA954, 0xA95E, 29), + (0xA95F, 0xA95F, 17), + (0xA960, 0xA97C, 4), + (0xA97D, 0xA97F, 29), + (0xA980, 0xA982, 5), + (0xA983, 0xA983, 6), + (0xA984, 0xA9B2, 4), + (0xA9B3, 0xA9B3, 5), + (0xA9B4, 0xA9B5, 6), + (0xA9B6, 0xA9B9, 5), + (0xA9BA, 0xA9BB, 6), + (0xA9BC, 0xA9BD, 5), + (0xA9BE, 0xA9C0, 6), + (0xA9C1, 0xA9CD, 17), + (0xA9CE, 0xA9CE, 29), + (0xA9CF, 0xA9CF, 3), + (0xA9D0, 0xA9D9, 8), + (0xA9DA, 0xA9DD, 29), + (0xA9DE, 0xA9DF, 17), + (0xA9E0, 0xA9E4, 4), + (0xA9E5, 0xA9E5, 5), + (0xA9E6, 0xA9E6, 3), + (0xA9E7, 0xA9EF, 4), + (0xA9F0, 0xA9F9, 8), + (0xA9FA, 0xA9FE, 4), + (0xA9FF, 0xA9FF, 29), + (0xAA00, 0xAA28, 4), + (0xAA29, 0xAA2E, 5), + (0xAA2F, 0xAA30, 6), + (0xAA31, 0xAA32, 5), + (0xAA33, 0xAA34, 6), + (0xAA35, 0xAA36, 5), + (0xAA37, 0xAA3F, 29), + (0xAA40, 0xAA42, 4), + (0xAA43, 0xAA43, 5), + (0xAA44, 0xAA4B, 4), + (0xAA4C, 0xAA4C, 5), + (0xAA4D, 0xAA4D, 6), + (0xAA4E, 0xAA4F, 29), + (0xAA50, 0xAA59, 8), + (0xAA5A, 0xAA5B, 29), + (0xAA5C, 0xAA5F, 17), + (0xAA60, 0xAA6F, 4), + (0xAA70, 0xAA70, 3), + (0xAA71, 0xAA76, 4), + (0xAA77, 0xAA79, 21), + (0xAA7A, 0xAA7A, 4), + (0xAA7B, 0xAA7B, 6), + (0xAA7C, 0xAA7C, 5), + (0xAA7D, 0xAA7D, 6), + (0xAA7E, 0xAAAF, 4), + (0xAAB0, 0xAAB0, 5), + (0xAAB1, 0xAAB1, 4), + (0xAAB2, 0xAAB4, 5), + (0xAAB5, 0xAAB6, 4), + (0xAAB7, 0xAAB8, 5), + (0xAAB9, 0xAABD, 4), + (0xAABE, 0xAABF, 5), + (0xAAC0, 0xAAC0, 4), + (0xAAC1, 0xAAC1, 5), + (0xAAC2, 0xAAC2, 4), + (0xAAC3, 0xAADA, 29), + (0xAADB, 0xAADC, 4), + (0xAADD, 0xAADD, 3), + (0xAADE, 0xAADF, 17), + (0xAAE0, 0xAAEA, 4), + (0xAAEB, 0xAAEB, 6), + (0xAAEC, 0xAAED, 5), + (0xAAEE, 0xAAEF, 6), + (0xAAF0, 0xAAF1, 17), + (0xAAF2, 0xAAF2, 4), + (0xAAF3, 0xAAF4, 3), + (0xAAF5, 0xAAF5, 6), + (0xAAF6, 0xAAF6, 5), + (0xAAF7, 0xAB00, 29), + (0xAB01, 0xAB06, 4), + (0xAB07, 0xAB08, 29), + (0xAB09, 0xAB0E, 4), + (0xAB0F, 0xAB10, 29), + (0xAB11, 0xAB16, 4), + (0xAB17, 0xAB1F, 29), + (0xAB20, 0xAB26, 4), + (0xAB27, 0xAB27, 29), + (0xAB28, 0xAB2E, 4), + (0xAB2F, 0xAB2F, 29), + (0xAB30, 0xAB5A, 1), + (0xAB5B, 0xAB5B, 20), + (0xAB5C, 0xAB5F, 3), + (0xAB60, 0xAB68, 1), + (0xAB69, 0xAB69, 3), + (0xAB6A, 0xAB6B, 20), + (0xAB6C, 0xAB6D, 0), + (0xAB6E, 0xAB6F, 29), + (0xAB70, 0xABBF, 1), + (0xABC0, 0xABE2, 4), + (0xABE3, 0xABE4, 6), + (0xABE5, 0xABE5, 5), + (0xABE6, 0xABE7, 6), + (0xABE8, 0xABE8, 5), + (0xABE9, 0xABEA, 6), + (0xABEB, 0xABEB, 17), + (0xABEC, 0xABEC, 6), + (0xABED, 0xABED, 5), + (0xABEE, 0xABEF, 29), + (0xABF0, 0xABF9, 8), + (0xABFA, 0xABFF, 29), + (0xAC00, 0xD7A3, 4), + (0xD7A4, 0xD7AF, 29), + (0xD7B0, 0xD7C6, 4), + (0xD7C7, 0xD7CA, 29), + (0xD7CB, 0xD7FB, 4), + (0xD7FC, 0xD7FF, 29), + (0xD800, 0xDFFF, 27), + (0xE000, 0xF8FF, 28), + (0xF900, 0xFA6D, 4), + (0xFA6E, 0xFA6F, 29), + (0xFA70, 0xFAD9, 4), + (0xFADA, 0xFAFF, 29), + (0xFB00, 0xFB06, 1), + (0xFB07, 0xFB12, 29), + (0xFB13, 0xFB17, 1), + (0xFB18, 0xFB1C, 29), + (0xFB1D, 0xFB1D, 4), + (0xFB1E, 0xFB1E, 5), + (0xFB1F, 0xFB28, 4), + (0xFB29, 0xFB29, 18), + (0xFB2A, 0xFB36, 4), + (0xFB37, 0xFB37, 29), + (0xFB38, 0xFB3C, 4), + (0xFB3D, 0xFB3D, 29), + (0xFB3E, 0xFB3E, 4), + (0xFB3F, 0xFB3F, 29), + (0xFB40, 0xFB41, 4), + (0xFB42, 0xFB42, 29), + (0xFB43, 0xFB44, 4), + (0xFB45, 0xFB45, 29), + (0xFB46, 0xFBB1, 4), + (0xFBB2, 0xFBC2, 20), + (0xFBC3, 0xFBD2, 21), + (0xFBD3, 0xFD3D, 4), + (0xFD3E, 0xFD3E, 14), + (0xFD3F, 0xFD3F, 13), + (0xFD40, 0xFD4F, 21), + (0xFD50, 0xFD8F, 4), + (0xFD90, 0xFD91, 21), + (0xFD92, 0xFDC7, 4), + (0xFDC8, 0xFDCF, 21), + (0xFDD0, 0xFDEF, 29), + (0xFDF0, 0xFDFB, 4), + (0xFDFC, 0xFDFC, 19), + (0xFDFD, 0xFDFF, 21), + (0xFE00, 0xFE0F, 5), + (0xFE10, 0xFE16, 17), + (0xFE17, 0xFE17, 13), + (0xFE18, 0xFE18, 14), + (0xFE19, 0xFE19, 17), + (0xFE1A, 0xFE1F, 29), + (0xFE20, 0xFE2F, 5), + (0xFE30, 0xFE30, 17), + (0xFE31, 0xFE32, 12), + (0xFE33, 0xFE34, 11), + (0xFE35, 0xFE35, 13), + (0xFE36, 0xFE36, 14), + (0xFE37, 0xFE37, 13), + (0xFE38, 0xFE38, 14), + (0xFE39, 0xFE39, 13), + (0xFE3A, 0xFE3A, 14), + (0xFE3B, 0xFE3B, 13), + (0xFE3C, 0xFE3C, 14), + (0xFE3D, 0xFE3D, 13), + (0xFE3E, 0xFE3E, 14), + (0xFE3F, 0xFE3F, 13), + (0xFE40, 0xFE40, 14), + (0xFE41, 0xFE41, 13), + (0xFE42, 0xFE42, 14), + (0xFE43, 0xFE43, 13), + (0xFE44, 0xFE44, 14), + (0xFE45, 0xFE46, 17), + (0xFE47, 0xFE47, 13), + (0xFE48, 0xFE48, 14), + (0xFE49, 0xFE4C, 17), + (0xFE4D, 0xFE4F, 11), + (0xFE50, 0xFE52, 17), + (0xFE53, 0xFE53, 29), + (0xFE54, 0xFE57, 17), + (0xFE58, 0xFE58, 12), + (0xFE59, 0xFE59, 13), + (0xFE5A, 0xFE5A, 14), + (0xFE5B, 0xFE5B, 13), + (0xFE5C, 0xFE5C, 14), + (0xFE5D, 0xFE5D, 13), + (0xFE5E, 0xFE5E, 14), + (0xFE5F, 0xFE61, 17), + (0xFE62, 0xFE62, 18), + (0xFE63, 0xFE63, 12), + (0xFE64, 0xFE66, 18), + (0xFE67, 0xFE67, 29), + (0xFE68, 0xFE68, 17), + (0xFE69, 0xFE69, 19), + (0xFE6A, 0xFE6B, 17), + (0xFE6C, 0xFE6F, 29), + (0xFE70, 0xFE74, 4), + (0xFE75, 0xFE75, 29), + (0xFE76, 0xFEFC, 4), + (0xFEFD, 0xFEFE, 29), + (0xFEFF, 0xFEFF, 26), + (0xFF00, 0xFF00, 29), + (0xFF01, 0xFF03, 17), + (0xFF04, 0xFF04, 19), + (0xFF05, 0xFF07, 17), + (0xFF08, 0xFF08, 13), + (0xFF09, 0xFF09, 14), + (0xFF0A, 0xFF0A, 17), + (0xFF0B, 0xFF0B, 18), + (0xFF0C, 0xFF0C, 17), + (0xFF0D, 0xFF0D, 12), + (0xFF0E, 0xFF0F, 17), + (0xFF10, 0xFF19, 8), + (0xFF1A, 0xFF1B, 17), + (0xFF1C, 0xFF1E, 18), + (0xFF1F, 0xFF20, 17), + (0xFF21, 0xFF3A, 0), + (0xFF3B, 0xFF3B, 13), + (0xFF3C, 0xFF3C, 17), + (0xFF3D, 0xFF3D, 14), + (0xFF3E, 0xFF3E, 20), + (0xFF3F, 0xFF3F, 11), + (0xFF40, 0xFF40, 20), + (0xFF41, 0xFF5A, 1), + (0xFF5B, 0xFF5B, 13), + (0xFF5C, 0xFF5C, 18), + (0xFF5D, 0xFF5D, 14), + (0xFF5E, 0xFF5E, 18), + (0xFF5F, 0xFF5F, 13), + (0xFF60, 0xFF60, 14), + (0xFF61, 0xFF61, 17), + (0xFF62, 0xFF62, 13), + (0xFF63, 0xFF63, 14), + (0xFF64, 0xFF65, 17), + (0xFF66, 0xFF6F, 4), + (0xFF70, 0xFF70, 3), + (0xFF71, 0xFF9D, 4), + (0xFF9E, 0xFF9F, 3), + (0xFFA0, 0xFFBE, 4), + (0xFFBF, 0xFFC1, 29), + (0xFFC2, 0xFFC7, 4), + (0xFFC8, 0xFFC9, 29), + (0xFFCA, 0xFFCF, 4), + (0xFFD0, 0xFFD1, 29), + (0xFFD2, 0xFFD7, 4), + (0xFFD8, 0xFFD9, 29), + (0xFFDA, 0xFFDC, 4), + (0xFFDD, 0xFFDF, 29), + (0xFFE0, 0xFFE1, 19), + (0xFFE2, 0xFFE2, 18), + (0xFFE3, 0xFFE3, 20), + (0xFFE4, 0xFFE4, 21), + (0xFFE5, 0xFFE6, 19), + (0xFFE7, 0xFFE7, 29), + (0xFFE8, 0xFFE8, 21), + (0xFFE9, 0xFFEC, 18), + (0xFFED, 0xFFEE, 21), + (0xFFEF, 0xFFF8, 29), + (0xFFF9, 0xFFFB, 26), + (0xFFFC, 0xFFFD, 21), + (0xFFFE, 0xFFFF, 29), + (0x10000, 0x1000B, 4), + (0x1000C, 0x1000C, 29), + (0x1000D, 0x10026, 4), + (0x10027, 0x10027, 29), + (0x10028, 0x1003A, 4), + (0x1003B, 0x1003B, 29), + (0x1003C, 0x1003D, 4), + (0x1003E, 0x1003E, 29), + (0x1003F, 0x1004D, 4), + (0x1004E, 0x1004F, 29), + (0x10050, 0x1005D, 4), + (0x1005E, 0x1007F, 29), + (0x10080, 0x100FA, 4), + (0x100FB, 0x100FF, 29), + (0x10100, 0x10102, 17), + (0x10103, 0x10106, 29), + (0x10107, 0x10133, 10), + (0x10134, 0x10136, 29), + (0x10137, 0x1013F, 21), + (0x10140, 0x10174, 9), + (0x10175, 0x10178, 10), + (0x10179, 0x10189, 21), + (0x1018A, 0x1018B, 10), + (0x1018C, 0x1018E, 21), + (0x1018F, 0x1018F, 29), + (0x10190, 0x1019C, 21), + (0x1019D, 0x1019F, 29), + (0x101A0, 0x101A0, 21), + (0x101A1, 0x101CF, 29), + (0x101D0, 0x101FC, 21), + (0x101FD, 0x101FD, 5), + (0x101FE, 0x1027F, 29), + (0x10280, 0x1029C, 4), + (0x1029D, 0x1029F, 29), + (0x102A0, 0x102D0, 4), + (0x102D1, 0x102DF, 29), + (0x102E0, 0x102E0, 5), + (0x102E1, 0x102FB, 10), + (0x102FC, 0x102FF, 29), + (0x10300, 0x1031F, 4), + (0x10320, 0x10323, 10), + (0x10324, 0x1032C, 29), + (0x1032D, 0x10340, 4), + (0x10341, 0x10341, 9), + (0x10342, 0x10349, 4), + (0x1034A, 0x1034A, 9), + (0x1034B, 0x1034F, 29), + (0x10350, 0x10375, 4), + (0x10376, 0x1037A, 5), + (0x1037B, 0x1037F, 29), + (0x10380, 0x1039D, 4), + (0x1039E, 0x1039E, 29), + (0x1039F, 0x1039F, 17), + (0x103A0, 0x103C3, 4), + (0x103C4, 0x103C7, 29), + (0x103C8, 0x103CF, 4), + (0x103D0, 0x103D0, 17), + (0x103D1, 0x103D5, 9), + (0x103D6, 0x103FF, 29), + (0x10400, 0x10427, 0), + (0x10428, 0x1044F, 1), + (0x10450, 0x1049D, 4), + (0x1049E, 0x1049F, 29), + (0x104A0, 0x104A9, 8), + (0x104AA, 0x104AF, 29), + (0x104B0, 0x104D3, 0), + (0x104D4, 0x104D7, 29), + (0x104D8, 0x104FB, 1), + (0x104FC, 0x104FF, 29), + (0x10500, 0x10527, 4), + (0x10528, 0x1052F, 29), + (0x10530, 0x10563, 4), + (0x10564, 0x1056E, 29), + (0x1056F, 0x1056F, 17), + (0x10570, 0x1057A, 0), + (0x1057B, 0x1057B, 29), + (0x1057C, 0x1058A, 0), + (0x1058B, 0x1058B, 29), + (0x1058C, 0x10592, 0), + (0x10593, 0x10593, 29), + (0x10594, 0x10595, 0), + (0x10596, 0x10596, 29), + (0x10597, 0x105A1, 1), + (0x105A2, 0x105A2, 29), + (0x105A3, 0x105B1, 1), + (0x105B2, 0x105B2, 29), + (0x105B3, 0x105B9, 1), + (0x105BA, 0x105BA, 29), + (0x105BB, 0x105BC, 1), + (0x105BD, 0x105BF, 29), + (0x105C0, 0x105F3, 4), + (0x105F4, 0x105FF, 29), + (0x10600, 0x10736, 4), + (0x10737, 0x1073F, 29), + (0x10740, 0x10755, 4), + (0x10756, 0x1075F, 29), + (0x10760, 0x10767, 4), + (0x10768, 0x1077F, 29), + (0x10780, 0x10785, 3), + (0x10786, 0x10786, 29), + (0x10787, 0x107B0, 3), + (0x107B1, 0x107B1, 29), + (0x107B2, 0x107BF, 3), + (0x107C0, 0x107FF, 29), + (0x10800, 0x10805, 4), + (0x10806, 0x10807, 29), + (0x10808, 0x10808, 4), + (0x10809, 0x10809, 29), + (0x1080A, 0x10835, 4), + (0x10836, 0x10836, 29), + (0x10837, 0x10838, 4), + (0x10839, 0x1083B, 29), + (0x1083C, 0x1083C, 4), + (0x1083D, 0x1083E, 29), + (0x1083F, 0x10855, 4), + (0x10856, 0x10856, 29), + (0x10857, 0x10857, 17), + (0x10858, 0x1085F, 10), + (0x10860, 0x10876, 4), + (0x10877, 0x10878, 21), + (0x10879, 0x1087F, 10), + (0x10880, 0x1089E, 4), + (0x1089F, 0x108A6, 29), + (0x108A7, 0x108AF, 10), + (0x108B0, 0x108DF, 29), + (0x108E0, 0x108F2, 4), + (0x108F3, 0x108F3, 29), + (0x108F4, 0x108F5, 4), + (0x108F6, 0x108FA, 29), + (0x108FB, 0x108FF, 10), + (0x10900, 0x10915, 4), + (0x10916, 0x1091B, 10), + (0x1091C, 0x1091E, 29), + (0x1091F, 0x1091F, 17), + (0x10920, 0x10939, 4), + (0x1093A, 0x1093E, 29), + (0x1093F, 0x1093F, 17), + (0x10940, 0x10959, 4), + (0x1095A, 0x1097F, 29), + (0x10980, 0x109B7, 4), + (0x109B8, 0x109BB, 29), + (0x109BC, 0x109BD, 10), + (0x109BE, 0x109BF, 4), + (0x109C0, 0x109CF, 10), + (0x109D0, 0x109D1, 29), + (0x109D2, 0x109FF, 10), + (0x10A00, 0x10A00, 4), + (0x10A01, 0x10A03, 5), + (0x10A04, 0x10A04, 29), + (0x10A05, 0x10A06, 5), + (0x10A07, 0x10A0B, 29), + (0x10A0C, 0x10A0F, 5), + (0x10A10, 0x10A13, 4), + (0x10A14, 0x10A14, 29), + (0x10A15, 0x10A17, 4), + (0x10A18, 0x10A18, 29), + (0x10A19, 0x10A35, 4), + (0x10A36, 0x10A37, 29), + (0x10A38, 0x10A3A, 5), + (0x10A3B, 0x10A3E, 29), + (0x10A3F, 0x10A3F, 5), + (0x10A40, 0x10A48, 10), + (0x10A49, 0x10A4F, 29), + (0x10A50, 0x10A58, 17), + (0x10A59, 0x10A5F, 29), + (0x10A60, 0x10A7C, 4), + (0x10A7D, 0x10A7E, 10), + (0x10A7F, 0x10A7F, 17), + (0x10A80, 0x10A9C, 4), + (0x10A9D, 0x10A9F, 10), + (0x10AA0, 0x10ABF, 29), + (0x10AC0, 0x10AC7, 4), + (0x10AC8, 0x10AC8, 21), + (0x10AC9, 0x10AE4, 4), + (0x10AE5, 0x10AE6, 5), + (0x10AE7, 0x10AEA, 29), + (0x10AEB, 0x10AEF, 10), + (0x10AF0, 0x10AF6, 17), + (0x10AF7, 0x10AFF, 29), + (0x10B00, 0x10B35, 4), + (0x10B36, 0x10B38, 29), + (0x10B39, 0x10B3F, 17), + (0x10B40, 0x10B55, 4), + (0x10B56, 0x10B57, 29), + (0x10B58, 0x10B5F, 10), + (0x10B60, 0x10B72, 4), + (0x10B73, 0x10B77, 29), + (0x10B78, 0x10B7F, 10), + (0x10B80, 0x10B91, 4), + (0x10B92, 0x10B98, 29), + (0x10B99, 0x10B9C, 17), + (0x10B9D, 0x10BA8, 29), + (0x10BA9, 0x10BAF, 10), + (0x10BB0, 0x10BFF, 29), + (0x10C00, 0x10C48, 4), + (0x10C49, 0x10C7F, 29), + (0x10C80, 0x10CB2, 0), + (0x10CB3, 0x10CBF, 29), + (0x10CC0, 0x10CF2, 1), + (0x10CF3, 0x10CF9, 29), + (0x10CFA, 0x10CFF, 10), + (0x10D00, 0x10D23, 4), + (0x10D24, 0x10D27, 5), + (0x10D28, 0x10D2F, 29), + (0x10D30, 0x10D39, 8), + (0x10D3A, 0x10D3F, 29), + (0x10D40, 0x10D49, 8), + (0x10D4A, 0x10D4D, 4), + (0x10D4E, 0x10D4E, 3), + (0x10D4F, 0x10D4F, 4), + (0x10D50, 0x10D65, 0), + (0x10D66, 0x10D68, 29), + (0x10D69, 0x10D6D, 5), + (0x10D6E, 0x10D6E, 12), + (0x10D6F, 0x10D6F, 3), + (0x10D70, 0x10D85, 1), + (0x10D86, 0x10D8D, 29), + (0x10D8E, 0x10D8F, 18), + (0x10D90, 0x10E5F, 29), + (0x10E60, 0x10E7E, 10), + (0x10E7F, 0x10E7F, 29), + (0x10E80, 0x10EA9, 4), + (0x10EAA, 0x10EAA, 29), + (0x10EAB, 0x10EAC, 5), + (0x10EAD, 0x10EAD, 12), + (0x10EAE, 0x10EAF, 29), + (0x10EB0, 0x10EB1, 4), + (0x10EB2, 0x10EC1, 29), + (0x10EC2, 0x10EC4, 4), + (0x10EC5, 0x10EC5, 3), + (0x10EC6, 0x10EC7, 4), + (0x10EC8, 0x10EC8, 29), + (0x10EC9, 0x10ECA, 20), + (0x10ECB, 0x10ECF, 5), + (0x10ED0, 0x10ED0, 17), + (0x10ED1, 0x10ED8, 21), + (0x10ED9, 0x10EEE, 4), + (0x10EEF, 0x10EEF, 29), + (0x10EF0, 0x10EFF, 5), + (0x10F00, 0x10F1C, 4), + (0x10F1D, 0x10F26, 10), + (0x10F27, 0x10F27, 4), + (0x10F28, 0x10F2F, 29), + (0x10F30, 0x10F45, 4), + (0x10F46, 0x10F50, 5), + (0x10F51, 0x10F54, 10), + (0x10F55, 0x10F59, 17), + (0x10F5A, 0x10F6F, 29), + (0x10F70, 0x10F81, 4), + (0x10F82, 0x10F85, 5), + (0x10F86, 0x10F89, 17), + (0x10F8A, 0x10FAF, 29), + (0x10FB0, 0x10FC4, 4), + (0x10FC5, 0x10FCB, 10), + (0x10FCC, 0x10FDF, 29), + (0x10FE0, 0x10FF6, 4), + (0x10FF7, 0x10FFF, 29), + (0x11000, 0x11000, 6), + (0x11001, 0x11001, 5), + (0x11002, 0x11002, 6), + (0x11003, 0x11037, 4), + (0x11038, 0x11046, 5), + (0x11047, 0x1104D, 17), + (0x1104E, 0x11051, 29), + (0x11052, 0x11065, 10), + (0x11066, 0x1106F, 8), + (0x11070, 0x11070, 5), + (0x11071, 0x11072, 4), + (0x11073, 0x11074, 5), + (0x11075, 0x11075, 4), + (0x11076, 0x1107E, 29), + (0x1107F, 0x11081, 5), + (0x11082, 0x11082, 6), + (0x11083, 0x110AF, 4), + (0x110B0, 0x110B2, 6), + (0x110B3, 0x110B6, 5), + (0x110B7, 0x110B8, 6), + (0x110B9, 0x110BA, 5), + (0x110BB, 0x110BC, 17), + (0x110BD, 0x110BD, 26), + (0x110BE, 0x110C1, 17), + (0x110C2, 0x110C2, 5), + (0x110C3, 0x110CC, 29), + (0x110CD, 0x110CD, 26), + (0x110CE, 0x110CF, 29), + (0x110D0, 0x110E8, 4), + (0x110E9, 0x110EF, 29), + (0x110F0, 0x110F9, 8), + (0x110FA, 0x110FF, 29), + (0x11100, 0x11102, 5), + (0x11103, 0x11126, 4), + (0x11127, 0x1112B, 5), + (0x1112C, 0x1112C, 6), + (0x1112D, 0x11134, 5), + (0x11135, 0x11135, 29), + (0x11136, 0x1113F, 8), + (0x11140, 0x11143, 17), + (0x11144, 0x11144, 4), + (0x11145, 0x11146, 6), + (0x11147, 0x11147, 4), + (0x11148, 0x1114F, 29), + (0x11150, 0x11172, 4), + (0x11173, 0x11173, 5), + (0x11174, 0x11175, 17), + (0x11176, 0x11176, 4), + (0x11177, 0x1117F, 29), + (0x11180, 0x11181, 5), + (0x11182, 0x11182, 6), + (0x11183, 0x111B2, 4), + (0x111B3, 0x111B5, 6), + (0x111B6, 0x111BE, 5), + (0x111BF, 0x111C0, 6), + (0x111C1, 0x111C4, 4), + (0x111C5, 0x111C8, 17), + (0x111C9, 0x111CC, 5), + (0x111CD, 0x111CD, 17), + (0x111CE, 0x111CE, 6), + (0x111CF, 0x111CF, 5), + (0x111D0, 0x111D9, 8), + (0x111DA, 0x111DA, 4), + (0x111DB, 0x111DB, 17), + (0x111DC, 0x111DC, 4), + (0x111DD, 0x111DF, 17), + (0x111E0, 0x111E0, 29), + (0x111E1, 0x111F4, 10), + (0x111F5, 0x111FF, 29), + (0x11200, 0x11211, 4), + (0x11212, 0x11212, 29), + (0x11213, 0x1122B, 4), + (0x1122C, 0x1122E, 6), + (0x1122F, 0x11231, 5), + (0x11232, 0x11233, 6), + (0x11234, 0x11234, 5), + (0x11235, 0x11235, 6), + (0x11236, 0x11237, 5), + (0x11238, 0x1123D, 17), + (0x1123E, 0x1123E, 5), + (0x1123F, 0x11240, 4), + (0x11241, 0x11241, 5), + (0x11242, 0x1127F, 29), + (0x11280, 0x11286, 4), + (0x11287, 0x11287, 29), + (0x11288, 0x11288, 4), + (0x11289, 0x11289, 29), + (0x1128A, 0x1128D, 4), + (0x1128E, 0x1128E, 29), + (0x1128F, 0x1129D, 4), + (0x1129E, 0x1129E, 29), + (0x1129F, 0x112A8, 4), + (0x112A9, 0x112A9, 17), + (0x112AA, 0x112AF, 29), + (0x112B0, 0x112DE, 4), + (0x112DF, 0x112DF, 5), + (0x112E0, 0x112E2, 6), + (0x112E3, 0x112EA, 5), + (0x112EB, 0x112EF, 29), + (0x112F0, 0x112F9, 8), + (0x112FA, 0x112FF, 29), + (0x11300, 0x11301, 5), + (0x11302, 0x11303, 6), + (0x11304, 0x11304, 29), + (0x11305, 0x1130C, 4), + (0x1130D, 0x1130E, 29), + (0x1130F, 0x11310, 4), + (0x11311, 0x11312, 29), + (0x11313, 0x11328, 4), + (0x11329, 0x11329, 29), + (0x1132A, 0x11330, 4), + (0x11331, 0x11331, 29), + (0x11332, 0x11333, 4), + (0x11334, 0x11334, 29), + (0x11335, 0x11339, 4), + (0x1133A, 0x1133A, 29), + (0x1133B, 0x1133C, 5), + (0x1133D, 0x1133D, 4), + (0x1133E, 0x1133F, 6), + (0x11340, 0x11340, 5), + (0x11341, 0x11344, 6), + (0x11345, 0x11346, 29), + (0x11347, 0x11348, 6), + (0x11349, 0x1134A, 29), + (0x1134B, 0x1134D, 6), + (0x1134E, 0x1134F, 29), + (0x11350, 0x11350, 4), + (0x11351, 0x11356, 29), + (0x11357, 0x11357, 6), + (0x11358, 0x1135C, 29), + (0x1135D, 0x11361, 4), + (0x11362, 0x11363, 6), + (0x11364, 0x11365, 29), + (0x11366, 0x1136C, 5), + (0x1136D, 0x1136F, 29), + (0x11370, 0x11374, 5), + (0x11375, 0x1137F, 29), + (0x11380, 0x11389, 4), + (0x1138A, 0x1138A, 29), + (0x1138B, 0x1138B, 4), + (0x1138C, 0x1138D, 29), + (0x1138E, 0x1138E, 4), + (0x1138F, 0x1138F, 29), + (0x11390, 0x113B5, 4), + (0x113B6, 0x113B6, 29), + (0x113B7, 0x113B7, 4), + (0x113B8, 0x113BA, 6), + (0x113BB, 0x113C0, 5), + (0x113C1, 0x113C1, 29), + (0x113C2, 0x113C2, 6), + (0x113C3, 0x113C4, 29), + (0x113C5, 0x113C5, 6), + (0x113C6, 0x113C6, 29), + (0x113C7, 0x113CA, 6), + (0x113CB, 0x113CB, 29), + (0x113CC, 0x113CD, 6), + (0x113CE, 0x113CE, 5), + (0x113CF, 0x113CF, 6), + (0x113D0, 0x113D0, 5), + (0x113D1, 0x113D1, 4), + (0x113D2, 0x113D2, 5), + (0x113D3, 0x113D3, 4), + (0x113D4, 0x113D5, 17), + (0x113D6, 0x113D6, 29), + (0x113D7, 0x113D8, 17), + (0x113D9, 0x113E0, 29), + (0x113E1, 0x113E2, 5), + (0x113E3, 0x113FF, 29), + (0x11400, 0x11434, 4), + (0x11435, 0x11437, 6), + (0x11438, 0x1143F, 5), + (0x11440, 0x11441, 6), + (0x11442, 0x11444, 5), + (0x11445, 0x11445, 6), + (0x11446, 0x11446, 5), + (0x11447, 0x1144A, 4), + (0x1144B, 0x1144F, 17), + (0x11450, 0x11459, 8), + (0x1145A, 0x1145B, 17), + (0x1145C, 0x1145C, 29), + (0x1145D, 0x1145D, 17), + (0x1145E, 0x1145E, 5), + (0x1145F, 0x11461, 4), + (0x11462, 0x1147F, 29), + (0x11480, 0x114AF, 4), + (0x114B0, 0x114B2, 6), + (0x114B3, 0x114B8, 5), + (0x114B9, 0x114B9, 6), + (0x114BA, 0x114BA, 5), + (0x114BB, 0x114BE, 6), + (0x114BF, 0x114C0, 5), + (0x114C1, 0x114C1, 6), + (0x114C2, 0x114C3, 5), + (0x114C4, 0x114C5, 4), + (0x114C6, 0x114C6, 17), + (0x114C7, 0x114C7, 4), + (0x114C8, 0x114CF, 29), + (0x114D0, 0x114D9, 8), + (0x114DA, 0x1157F, 29), + (0x11580, 0x115AE, 4), + (0x115AF, 0x115B1, 6), + (0x115B2, 0x115B5, 5), + (0x115B6, 0x115B7, 29), + (0x115B8, 0x115BB, 6), + (0x115BC, 0x115BD, 5), + (0x115BE, 0x115BE, 6), + (0x115BF, 0x115C0, 5), + (0x115C1, 0x115D7, 17), + (0x115D8, 0x115DB, 4), + (0x115DC, 0x115DD, 5), + (0x115DE, 0x115FF, 29), + (0x11600, 0x1162F, 4), + (0x11630, 0x11632, 6), + (0x11633, 0x1163A, 5), + (0x1163B, 0x1163C, 6), + (0x1163D, 0x1163D, 5), + (0x1163E, 0x1163E, 6), + (0x1163F, 0x11640, 5), + (0x11641, 0x11643, 17), + (0x11644, 0x11644, 4), + (0x11645, 0x1164F, 29), + (0x11650, 0x11659, 8), + (0x1165A, 0x1165F, 29), + (0x11660, 0x1166C, 17), + (0x1166D, 0x1167F, 29), + (0x11680, 0x116AA, 4), + (0x116AB, 0x116AB, 5), + (0x116AC, 0x116AC, 6), + (0x116AD, 0x116AD, 5), + (0x116AE, 0x116AF, 6), + (0x116B0, 0x116B5, 5), + (0x116B6, 0x116B6, 6), + (0x116B7, 0x116B7, 5), + (0x116B8, 0x116B8, 4), + (0x116B9, 0x116B9, 17), + (0x116BA, 0x116BF, 29), + (0x116C0, 0x116C9, 8), + (0x116CA, 0x116CF, 29), + (0x116D0, 0x116E3, 8), + (0x116E4, 0x116FF, 29), + (0x11700, 0x1171A, 4), + (0x1171B, 0x1171C, 29), + (0x1171D, 0x1171D, 5), + (0x1171E, 0x1171E, 6), + (0x1171F, 0x1171F, 5), + (0x11720, 0x11721, 6), + (0x11722, 0x11725, 5), + (0x11726, 0x11726, 6), + (0x11727, 0x1172B, 5), + (0x1172C, 0x1172F, 29), + (0x11730, 0x11739, 8), + (0x1173A, 0x1173B, 10), + (0x1173C, 0x1173E, 17), + (0x1173F, 0x1173F, 21), + (0x11740, 0x11746, 4), + (0x11747, 0x117FF, 29), + (0x11800, 0x1182B, 4), + (0x1182C, 0x1182E, 6), + (0x1182F, 0x11837, 5), + (0x11838, 0x11838, 6), + (0x11839, 0x1183A, 5), + (0x1183B, 0x1183B, 17), + (0x1183C, 0x1189F, 29), + (0x118A0, 0x118BF, 0), + (0x118C0, 0x118DF, 1), + (0x118E0, 0x118E9, 8), + (0x118EA, 0x118F2, 10), + (0x118F3, 0x118FE, 29), + (0x118FF, 0x11906, 4), + (0x11907, 0x11908, 29), + (0x11909, 0x11909, 4), + (0x1190A, 0x1190B, 29), + (0x1190C, 0x11913, 4), + (0x11914, 0x11914, 29), + (0x11915, 0x11916, 4), + (0x11917, 0x11917, 29), + (0x11918, 0x1192F, 4), + (0x11930, 0x11935, 6), + (0x11936, 0x11936, 29), + (0x11937, 0x11938, 6), + (0x11939, 0x1193A, 29), + (0x1193B, 0x1193C, 5), + (0x1193D, 0x1193D, 6), + (0x1193E, 0x1193E, 5), + (0x1193F, 0x1193F, 4), + (0x11940, 0x11940, 6), + (0x11941, 0x11941, 4), + (0x11942, 0x11942, 6), + (0x11943, 0x11943, 5), + (0x11944, 0x11946, 17), + (0x11947, 0x1194F, 29), + (0x11950, 0x11959, 8), + (0x1195A, 0x1199F, 29), + (0x119A0, 0x119A7, 4), + (0x119A8, 0x119A9, 29), + (0x119AA, 0x119D0, 4), + (0x119D1, 0x119D3, 6), + (0x119D4, 0x119D7, 5), + (0x119D8, 0x119D9, 29), + (0x119DA, 0x119DB, 5), + (0x119DC, 0x119DF, 6), + (0x119E0, 0x119E0, 5), + (0x119E1, 0x119E1, 4), + (0x119E2, 0x119E2, 17), + (0x119E3, 0x119E3, 4), + (0x119E4, 0x119E4, 6), + (0x119E5, 0x119FF, 29), + (0x11A00, 0x11A00, 4), + (0x11A01, 0x11A0A, 5), + (0x11A0B, 0x11A32, 4), + (0x11A33, 0x11A38, 5), + (0x11A39, 0x11A39, 6), + (0x11A3A, 0x11A3A, 4), + (0x11A3B, 0x11A3E, 5), + (0x11A3F, 0x11A46, 17), + (0x11A47, 0x11A47, 5), + (0x11A48, 0x11A4F, 29), + (0x11A50, 0x11A50, 4), + (0x11A51, 0x11A56, 5), + (0x11A57, 0x11A58, 6), + (0x11A59, 0x11A5B, 5), + (0x11A5C, 0x11A89, 4), + (0x11A8A, 0x11A96, 5), + (0x11A97, 0x11A97, 6), + (0x11A98, 0x11A99, 5), + (0x11A9A, 0x11A9C, 17), + (0x11A9D, 0x11A9D, 4), + (0x11A9E, 0x11AA2, 17), + (0x11AA3, 0x11AAF, 29), + (0x11AB0, 0x11AF8, 4), + (0x11AF9, 0x11AFF, 29), + (0x11B00, 0x11B09, 17), + (0x11B0A, 0x11B0A, 4), + (0x11B0B, 0x11B5F, 29), + (0x11B60, 0x11B60, 5), + (0x11B61, 0x11B61, 6), + (0x11B62, 0x11B64, 5), + (0x11B65, 0x11B65, 6), + (0x11B66, 0x11B66, 5), + (0x11B67, 0x11B67, 6), + (0x11B68, 0x11BBF, 29), + (0x11BC0, 0x11BE0, 4), + (0x11BE1, 0x11BE1, 17), + (0x11BE2, 0x11BEF, 29), + (0x11BF0, 0x11BF9, 8), + (0x11BFA, 0x11BFF, 29), + (0x11C00, 0x11C08, 4), + (0x11C09, 0x11C09, 29), + (0x11C0A, 0x11C2E, 4), + (0x11C2F, 0x11C2F, 6), + (0x11C30, 0x11C36, 5), + (0x11C37, 0x11C37, 29), + (0x11C38, 0x11C3D, 5), + (0x11C3E, 0x11C3E, 6), + (0x11C3F, 0x11C3F, 5), + (0x11C40, 0x11C40, 4), + (0x11C41, 0x11C45, 17), + (0x11C46, 0x11C4F, 29), + (0x11C50, 0x11C59, 8), + (0x11C5A, 0x11C6C, 10), + (0x11C6D, 0x11C6F, 29), + (0x11C70, 0x11C71, 17), + (0x11C72, 0x11C8F, 4), + (0x11C90, 0x11C91, 29), + (0x11C92, 0x11CA7, 5), + (0x11CA8, 0x11CA8, 29), + (0x11CA9, 0x11CA9, 6), + (0x11CAA, 0x11CB0, 5), + (0x11CB1, 0x11CB1, 6), + (0x11CB2, 0x11CB3, 5), + (0x11CB4, 0x11CB4, 6), + (0x11CB5, 0x11CB6, 5), + (0x11CB7, 0x11CFF, 29), + (0x11D00, 0x11D06, 4), + (0x11D07, 0x11D07, 29), + (0x11D08, 0x11D09, 4), + (0x11D0A, 0x11D0A, 29), + (0x11D0B, 0x11D30, 4), + (0x11D31, 0x11D36, 5), + (0x11D37, 0x11D39, 29), + (0x11D3A, 0x11D3A, 5), + (0x11D3B, 0x11D3B, 29), + (0x11D3C, 0x11D3D, 5), + (0x11D3E, 0x11D3E, 29), + (0x11D3F, 0x11D45, 5), + (0x11D46, 0x11D46, 4), + (0x11D47, 0x11D47, 5), + (0x11D48, 0x11D4F, 29), + (0x11D50, 0x11D59, 8), + (0x11D5A, 0x11D5F, 29), + (0x11D60, 0x11D65, 4), + (0x11D66, 0x11D66, 29), + (0x11D67, 0x11D68, 4), + (0x11D69, 0x11D69, 29), + (0x11D6A, 0x11D89, 4), + (0x11D8A, 0x11D8E, 6), + (0x11D8F, 0x11D8F, 29), + (0x11D90, 0x11D91, 5), + (0x11D92, 0x11D92, 29), + (0x11D93, 0x11D94, 6), + (0x11D95, 0x11D95, 5), + (0x11D96, 0x11D96, 6), + (0x11D97, 0x11D97, 5), + (0x11D98, 0x11D98, 4), + (0x11D99, 0x11D9F, 29), + (0x11DA0, 0x11DA9, 8), + (0x11DAA, 0x11DAF, 29), + (0x11DB0, 0x11DD8, 4), + (0x11DD9, 0x11DD9, 3), + (0x11DDA, 0x11DDB, 4), + (0x11DDC, 0x11DDF, 29), + (0x11DE0, 0x11DE9, 8), + (0x11DEA, 0x11DEF, 29), + (0x11DF0, 0x11DF0, 5), + (0x11DF1, 0x11DF1, 4), + (0x11DF2, 0x11EDF, 29), + (0x11EE0, 0x11EF2, 4), + (0x11EF3, 0x11EF4, 5), + (0x11EF5, 0x11EF6, 6), + (0x11EF7, 0x11EF8, 17), + (0x11EF9, 0x11EFF, 29), + (0x11F00, 0x11F01, 5), + (0x11F02, 0x11F02, 4), + (0x11F03, 0x11F03, 6), + (0x11F04, 0x11F10, 4), + (0x11F11, 0x11F11, 29), + (0x11F12, 0x11F33, 4), + (0x11F34, 0x11F35, 6), + (0x11F36, 0x11F3A, 5), + (0x11F3B, 0x11F3D, 29), + (0x11F3E, 0x11F3F, 6), + (0x11F40, 0x11F40, 5), + (0x11F41, 0x11F41, 6), + (0x11F42, 0x11F42, 5), + (0x11F43, 0x11F4F, 17), + (0x11F50, 0x11F59, 8), + (0x11F5A, 0x11F5A, 5), + (0x11F5B, 0x11FAF, 29), + (0x11FB0, 0x11FB0, 4), + (0x11FB1, 0x11FBF, 29), + (0x11FC0, 0x11FD4, 10), + (0x11FD5, 0x11FDC, 21), + (0x11FDD, 0x11FE0, 19), + (0x11FE1, 0x11FF1, 21), + (0x11FF2, 0x11FFE, 29), + (0x11FFF, 0x11FFF, 17), + (0x12000, 0x12399, 4), + (0x1239A, 0x123FF, 29), + (0x12400, 0x1246F, 9), + (0x12470, 0x12474, 17), + (0x12475, 0x1247F, 9), + (0x12480, 0x12543, 4), + (0x12544, 0x1254F, 29), + (0x12550, 0x12686, 9), + (0x12687, 0x12F8F, 29), + (0x12F90, 0x12FF0, 4), + (0x12FF1, 0x12FF2, 17), + (0x12FF3, 0x12FFF, 29), + (0x13000, 0x1342F, 4), + (0x13430, 0x1343F, 26), + (0x13440, 0x13440, 5), + (0x13441, 0x13446, 4), + (0x13447, 0x13455, 5), + (0x13456, 0x1345F, 29), + (0x13460, 0x143FA, 4), + (0x143FB, 0x143FF, 29), + (0x14400, 0x14646, 4), + (0x14647, 0x160FF, 29), + (0x16100, 0x1611D, 4), + (0x1611E, 0x16129, 5), + (0x1612A, 0x1612C, 6), + (0x1612D, 0x1612F, 5), + (0x16130, 0x16139, 8), + (0x1613A, 0x167FF, 29), + (0x16800, 0x16A38, 4), + (0x16A39, 0x16A3F, 29), + (0x16A40, 0x16A5E, 4), + (0x16A5F, 0x16A5F, 29), + (0x16A60, 0x16A69, 8), + (0x16A6A, 0x16A6D, 29), + (0x16A6E, 0x16A6F, 17), + (0x16A70, 0x16ABE, 4), + (0x16ABF, 0x16ABF, 29), + (0x16AC0, 0x16AC9, 8), + (0x16ACA, 0x16ACF, 29), + (0x16AD0, 0x16AED, 4), + (0x16AEE, 0x16AEF, 29), + (0x16AF0, 0x16AF4, 5), + (0x16AF5, 0x16AF5, 17), + (0x16AF6, 0x16AFF, 29), + (0x16B00, 0x16B2F, 4), + (0x16B30, 0x16B36, 5), + (0x16B37, 0x16B3B, 17), + (0x16B3C, 0x16B3F, 21), + (0x16B40, 0x16B43, 3), + (0x16B44, 0x16B44, 17), + (0x16B45, 0x16B45, 21), + (0x16B46, 0x16B4F, 29), + (0x16B50, 0x16B59, 8), + (0x16B5A, 0x16B5A, 29), + (0x16B5B, 0x16B61, 10), + (0x16B62, 0x16B62, 29), + (0x16B63, 0x16B77, 4), + (0x16B78, 0x16B7C, 29), + (0x16B7D, 0x16B8F, 4), + (0x16B90, 0x16D3F, 29), + (0x16D40, 0x16D42, 3), + (0x16D43, 0x16D6A, 4), + (0x16D6B, 0x16D6C, 3), + (0x16D6D, 0x16D6F, 17), + (0x16D70, 0x16D79, 8), + (0x16D7A, 0x16E3F, 29), + (0x16E40, 0x16E5F, 0), + (0x16E60, 0x16E7F, 1), + (0x16E80, 0x16E96, 10), + (0x16E97, 0x16E9A, 17), + (0x16E9B, 0x16E9F, 29), + (0x16EA0, 0x16EB8, 0), + (0x16EB9, 0x16EBA, 29), + (0x16EBB, 0x16ED3, 1), + (0x16ED4, 0x16EFF, 29), + (0x16F00, 0x16F4A, 4), + (0x16F4B, 0x16F4E, 29), + (0x16F4F, 0x16F4F, 5), + (0x16F50, 0x16F50, 4), + (0x16F51, 0x16F87, 6), + (0x16F88, 0x16F8E, 29), + (0x16F8F, 0x16F92, 5), + (0x16F93, 0x16F9F, 3), + (0x16FA0, 0x16FDF, 29), + (0x16FE0, 0x16FE1, 3), + (0x16FE2, 0x16FE2, 17), + (0x16FE3, 0x16FE3, 3), + (0x16FE4, 0x16FE4, 5), + (0x16FE5, 0x16FEF, 29), + (0x16FF0, 0x16FF1, 6), + (0x16FF2, 0x16FF3, 3), + (0x16FF4, 0x16FF6, 9), + (0x16FF7, 0x16FFF, 29), + (0x17000, 0x18CDA, 4), + (0x18CDB, 0x18CFE, 29), + (0x18CFF, 0x18D20, 4), + (0x18D21, 0x18D7F, 29), + (0x18D80, 0x18DF2, 4), + (0x18DF3, 0x18DFF, 29), + (0x18E00, 0x19191, 4), + (0x19192, 0x1919F, 29), + (0x191A0, 0x191D2, 4), + (0x191D3, 0x1AFEF, 29), + (0x1AFF0, 0x1AFF3, 3), + (0x1AFF4, 0x1AFF4, 29), + (0x1AFF5, 0x1AFFB, 3), + (0x1AFFC, 0x1AFFC, 29), + (0x1AFFD, 0x1AFFE, 3), + (0x1AFFF, 0x1AFFF, 29), + (0x1B000, 0x1B128, 4), + (0x1B129, 0x1B131, 29), + (0x1B132, 0x1B132, 4), + (0x1B133, 0x1B14F, 29), + (0x1B150, 0x1B152, 4), + (0x1B153, 0x1B154, 29), + (0x1B155, 0x1B155, 4), + (0x1B156, 0x1B163, 29), + (0x1B164, 0x1B168, 4), + (0x1B169, 0x1B16F, 29), + (0x1B170, 0x1B2FB, 4), + (0x1B2FC, 0x1BBFF, 29), + (0x1BC00, 0x1BC6A, 4), + (0x1BC6B, 0x1BC6F, 29), + (0x1BC70, 0x1BC7C, 4), + (0x1BC7D, 0x1BC7F, 29), + (0x1BC80, 0x1BC88, 4), + (0x1BC89, 0x1BC8F, 29), + (0x1BC90, 0x1BC99, 4), + (0x1BC9A, 0x1BC9B, 29), + (0x1BC9C, 0x1BC9C, 21), + (0x1BC9D, 0x1BC9E, 5), + (0x1BC9F, 0x1BC9F, 17), + (0x1BCA0, 0x1BCA3, 26), + (0x1BCA4, 0x1CBFF, 29), + (0x1CC00, 0x1CCEF, 21), + (0x1CCF0, 0x1CCF9, 8), + (0x1CCFA, 0x1CCFC, 21), + (0x1CCFD, 0x1CCFF, 29), + (0x1CD00, 0x1CEB3, 21), + (0x1CEB4, 0x1CEB9, 29), + (0x1CEBA, 0x1CED0, 21), + (0x1CED1, 0x1CED1, 29), + (0x1CED2, 0x1CED4, 21), + (0x1CED5, 0x1CEDC, 29), + (0x1CEDD, 0x1CEDF, 18), + (0x1CEE0, 0x1CEEF, 21), + (0x1CEF0, 0x1CEFD, 18), + (0x1CEFE, 0x1CEFF, 29), + (0x1CF00, 0x1CF2D, 5), + (0x1CF2E, 0x1CF2F, 29), + (0x1CF30, 0x1CF46, 5), + (0x1CF47, 0x1CF4F, 29), + (0x1CF50, 0x1CFC3, 21), + (0x1CFC4, 0x1CFFF, 29), + (0x1D000, 0x1D0F5, 21), + (0x1D0F6, 0x1D0FF, 29), + (0x1D100, 0x1D126, 21), + (0x1D127, 0x1D128, 5), + (0x1D129, 0x1D164, 21), + (0x1D165, 0x1D166, 6), + (0x1D167, 0x1D169, 5), + (0x1D16A, 0x1D16C, 21), + (0x1D16D, 0x1D172, 6), + (0x1D173, 0x1D17A, 26), + (0x1D17B, 0x1D182, 5), + (0x1D183, 0x1D184, 21), + (0x1D185, 0x1D18B, 5), + (0x1D18C, 0x1D1A9, 21), + (0x1D1AA, 0x1D1AD, 5), + (0x1D1AE, 0x1D241, 21), + (0x1D242, 0x1D244, 5), + (0x1D245, 0x1D245, 21), + (0x1D246, 0x1D24F, 29), + (0x1D250, 0x1D252, 6), + (0x1D253, 0x1D25A, 21), + (0x1D25B, 0x1D25C, 5), + (0x1D25D, 0x1D25E, 21), + (0x1D25F, 0x1D25F, 6), + (0x1D260, 0x1D27F, 21), + (0x1D280, 0x1D281, 6), + (0x1D282, 0x1D2BF, 29), + (0x1D2C0, 0x1D2D3, 10), + (0x1D2D4, 0x1D2DF, 29), + (0x1D2E0, 0x1D2F3, 10), + (0x1D2F4, 0x1D2FF, 29), + (0x1D300, 0x1D356, 21), + (0x1D357, 0x1D35F, 29), + (0x1D360, 0x1D378, 10), + (0x1D379, 0x1D3FF, 29), + (0x1D400, 0x1D419, 0), + (0x1D41A, 0x1D433, 1), + (0x1D434, 0x1D44D, 0), + (0x1D44E, 0x1D454, 1), + (0x1D455, 0x1D455, 29), + (0x1D456, 0x1D467, 1), + (0x1D468, 0x1D481, 0), + (0x1D482, 0x1D49B, 1), + (0x1D49C, 0x1D49C, 0), + (0x1D49D, 0x1D49D, 29), + (0x1D49E, 0x1D49F, 0), + (0x1D4A0, 0x1D4A1, 29), + (0x1D4A2, 0x1D4A2, 0), + (0x1D4A3, 0x1D4A4, 29), + (0x1D4A5, 0x1D4A6, 0), + (0x1D4A7, 0x1D4A8, 29), + (0x1D4A9, 0x1D4AC, 0), + (0x1D4AD, 0x1D4AD, 29), + (0x1D4AE, 0x1D4B5, 0), + (0x1D4B6, 0x1D4B9, 1), + (0x1D4BA, 0x1D4BA, 29), + (0x1D4BB, 0x1D4BB, 1), + (0x1D4BC, 0x1D4BC, 29), + (0x1D4BD, 0x1D4C3, 1), + (0x1D4C4, 0x1D4C4, 29), + (0x1D4C5, 0x1D4CF, 1), + (0x1D4D0, 0x1D4E9, 0), + (0x1D4EA, 0x1D503, 1), + (0x1D504, 0x1D505, 0), + (0x1D506, 0x1D506, 29), + (0x1D507, 0x1D50A, 0), + (0x1D50B, 0x1D50C, 29), + (0x1D50D, 0x1D514, 0), + (0x1D515, 0x1D515, 29), + (0x1D516, 0x1D51C, 0), + (0x1D51D, 0x1D51D, 29), + (0x1D51E, 0x1D537, 1), + (0x1D538, 0x1D539, 0), + (0x1D53A, 0x1D53A, 29), + (0x1D53B, 0x1D53E, 0), + (0x1D53F, 0x1D53F, 29), + (0x1D540, 0x1D544, 0), + (0x1D545, 0x1D545, 29), + (0x1D546, 0x1D546, 0), + (0x1D547, 0x1D549, 29), + (0x1D54A, 0x1D550, 0), + (0x1D551, 0x1D551, 29), + (0x1D552, 0x1D56B, 1), + (0x1D56C, 0x1D585, 0), + (0x1D586, 0x1D59F, 1), + (0x1D5A0, 0x1D5B9, 0), + (0x1D5BA, 0x1D5D3, 1), + (0x1D5D4, 0x1D5ED, 0), + (0x1D5EE, 0x1D607, 1), + (0x1D608, 0x1D621, 0), + (0x1D622, 0x1D63B, 1), + (0x1D63C, 0x1D655, 0), + (0x1D656, 0x1D66F, 1), + (0x1D670, 0x1D689, 0), + (0x1D68A, 0x1D6A6, 1), + (0x1D6A7, 0x1D6A7, 29), + (0x1D6A8, 0x1D6C0, 0), + (0x1D6C1, 0x1D6C1, 18), + (0x1D6C2, 0x1D6DA, 1), + (0x1D6DB, 0x1D6DB, 18), + (0x1D6DC, 0x1D6E1, 1), + (0x1D6E2, 0x1D6FA, 0), + (0x1D6FB, 0x1D6FB, 18), + (0x1D6FC, 0x1D714, 1), + (0x1D715, 0x1D715, 18), + (0x1D716, 0x1D71B, 1), + (0x1D71C, 0x1D734, 0), + (0x1D735, 0x1D735, 18), + (0x1D736, 0x1D74E, 1), + (0x1D74F, 0x1D74F, 18), + (0x1D750, 0x1D755, 1), + (0x1D756, 0x1D76E, 0), + (0x1D76F, 0x1D76F, 18), + (0x1D770, 0x1D788, 1), + (0x1D789, 0x1D789, 18), + (0x1D78A, 0x1D78F, 1), + (0x1D790, 0x1D7A8, 0), + (0x1D7A9, 0x1D7A9, 18), + (0x1D7AA, 0x1D7C2, 1), + (0x1D7C3, 0x1D7C3, 18), + (0x1D7C4, 0x1D7C9, 1), + (0x1D7CA, 0x1D7CA, 0), + (0x1D7CB, 0x1D7CB, 1), + (0x1D7CC, 0x1D7CD, 29), + (0x1D7CE, 0x1D7FF, 8), + (0x1D800, 0x1D9FF, 21), + (0x1DA00, 0x1DA36, 5), + (0x1DA37, 0x1DA3A, 21), + (0x1DA3B, 0x1DA6C, 5), + (0x1DA6D, 0x1DA74, 21), + (0x1DA75, 0x1DA75, 5), + (0x1DA76, 0x1DA83, 21), + (0x1DA84, 0x1DA84, 5), + (0x1DA85, 0x1DA86, 21), + (0x1DA87, 0x1DA8B, 17), + (0x1DA8C, 0x1DA9A, 29), + (0x1DA9B, 0x1DA9F, 5), + (0x1DAA0, 0x1DAA0, 29), + (0x1DAA1, 0x1DAAF, 5), + (0x1DAB0, 0x1DAFF, 29), + (0x1DB00, 0x1DB1C, 18), + (0x1DB1D, 0x1DEFF, 29), + (0x1DF00, 0x1DF09, 1), + (0x1DF0A, 0x1DF0A, 4), + (0x1DF0B, 0x1DF3F, 1), + (0x1DF40, 0x1DF40, 0), + (0x1DF41, 0x1DF47, 1), + (0x1DF48, 0x1DF48, 0), + (0x1DF49, 0x1DF49, 1), + (0x1DF4A, 0x1DF4A, 0), + (0x1DF4B, 0x1DF4C, 1), + (0x1DF4D, 0x1DF4D, 0), + (0x1DF4E, 0x1DF50, 1), + (0x1DF51, 0x1DF51, 0), + (0x1DF52, 0x1DF67, 1), + (0x1DF68, 0x1DF68, 0), + (0x1DF69, 0x1DF69, 1), + (0x1DF6A, 0x1DF6A, 0), + (0x1DF6B, 0x1DF6B, 1), + (0x1DF6C, 0x1DF6C, 0), + (0x1DF6D, 0x1DF6D, 1), + (0x1DF6E, 0x1DF6E, 0), + (0x1DF6F, 0x1DF71, 1), + (0x1DF72, 0x1DF72, 0), + (0x1DF73, 0x1DF73, 1), + (0x1DF74, 0x1DF74, 0), + (0x1DF75, 0x1DF75, 1), + (0x1DF76, 0x1DF76, 0), + (0x1DF77, 0x1DF77, 1), + (0x1DF78, 0x1DF78, 0), + (0x1DF79, 0x1DF79, 1), + (0x1DF7A, 0x1DF7A, 0), + (0x1DF7B, 0x1DF7B, 1), + (0x1DF7C, 0x1DF7C, 0), + (0x1DF7D, 0x1DF7D, 1), + (0x1DF7E, 0x1DF7E, 0), + (0x1DF7F, 0x1DF7F, 1), + (0x1DF80, 0x1DF81, 4), + (0x1DF82, 0x1DF8F, 29), + (0x1DF90, 0x1DF96, 1), + (0x1DF97, 0x1DFCC, 29), + (0x1DFCD, 0x1DFFF, 3), + (0x1E000, 0x1E006, 5), + (0x1E007, 0x1E007, 29), + (0x1E008, 0x1E018, 5), + (0x1E019, 0x1E01A, 29), + (0x1E01B, 0x1E021, 5), + (0x1E022, 0x1E022, 29), + (0x1E023, 0x1E024, 5), + (0x1E025, 0x1E025, 29), + (0x1E026, 0x1E02A, 5), + (0x1E02B, 0x1E02F, 29), + (0x1E030, 0x1E06D, 3), + (0x1E06E, 0x1E08E, 29), + (0x1E08F, 0x1E08F, 5), + (0x1E090, 0x1E0FF, 29), + (0x1E100, 0x1E12C, 4), + (0x1E12D, 0x1E12F, 29), + (0x1E130, 0x1E136, 5), + (0x1E137, 0x1E13D, 3), + (0x1E13E, 0x1E13F, 29), + (0x1E140, 0x1E149, 8), + (0x1E14A, 0x1E14D, 29), + (0x1E14E, 0x1E14E, 4), + (0x1E14F, 0x1E14F, 21), + (0x1E150, 0x1E28F, 29), + (0x1E290, 0x1E2AD, 4), + (0x1E2AE, 0x1E2AE, 5), + (0x1E2AF, 0x1E2BF, 29), + (0x1E2C0, 0x1E2EB, 4), + (0x1E2EC, 0x1E2EF, 5), + (0x1E2F0, 0x1E2F9, 8), + (0x1E2FA, 0x1E2FE, 29), + (0x1E2FF, 0x1E2FF, 19), + (0x1E300, 0x1E4CF, 29), + (0x1E4D0, 0x1E4EA, 4), + (0x1E4EB, 0x1E4EB, 3), + (0x1E4EC, 0x1E4EF, 5), + (0x1E4F0, 0x1E4F9, 8), + (0x1E4FA, 0x1E5CF, 29), + (0x1E5D0, 0x1E5ED, 4), + (0x1E5EE, 0x1E5EF, 5), + (0x1E5F0, 0x1E5F0, 4), + (0x1E5F1, 0x1E5FA, 8), + (0x1E5FB, 0x1E5FE, 29), + (0x1E5FF, 0x1E5FF, 17), + (0x1E600, 0x1E6BF, 29), + (0x1E6C0, 0x1E6DE, 4), + (0x1E6DF, 0x1E6DF, 29), + (0x1E6E0, 0x1E6E2, 4), + (0x1E6E3, 0x1E6E3, 5), + (0x1E6E4, 0x1E6E5, 4), + (0x1E6E6, 0x1E6E6, 5), + (0x1E6E7, 0x1E6ED, 4), + (0x1E6EE, 0x1E6EF, 5), + (0x1E6F0, 0x1E6F4, 4), + (0x1E6F5, 0x1E6F5, 5), + (0x1E6F6, 0x1E6FD, 29), + (0x1E6FE, 0x1E6FE, 4), + (0x1E6FF, 0x1E6FF, 3), + (0x1E700, 0x1E7DF, 29), + (0x1E7E0, 0x1E7E6, 4), + (0x1E7E7, 0x1E7E7, 29), + (0x1E7E8, 0x1E7EB, 4), + (0x1E7EC, 0x1E7EC, 29), + (0x1E7ED, 0x1E7EE, 4), + (0x1E7EF, 0x1E7EF, 29), + (0x1E7F0, 0x1E7FE, 4), + (0x1E7FF, 0x1E7FF, 29), + (0x1E800, 0x1E8C4, 4), + (0x1E8C5, 0x1E8C6, 29), + (0x1E8C7, 0x1E8CF, 10), + (0x1E8D0, 0x1E8D6, 5), + (0x1E8D7, 0x1E8FF, 29), + (0x1E900, 0x1E921, 0), + (0x1E922, 0x1E943, 1), + (0x1E944, 0x1E94A, 5), + (0x1E94B, 0x1E94B, 3), + (0x1E94C, 0x1E94F, 29), + (0x1E950, 0x1E959, 8), + (0x1E95A, 0x1E95D, 29), + (0x1E95E, 0x1E95F, 17), + (0x1E960, 0x1EC70, 29), + (0x1EC71, 0x1ECAB, 10), + (0x1ECAC, 0x1ECAC, 21), + (0x1ECAD, 0x1ECAF, 10), + (0x1ECB0, 0x1ECB0, 19), + (0x1ECB1, 0x1ECB4, 10), + (0x1ECB5, 0x1ED00, 29), + (0x1ED01, 0x1ED2D, 10), + (0x1ED2E, 0x1ED2E, 21), + (0x1ED2F, 0x1ED3D, 10), + (0x1ED3E, 0x1EDFF, 29), + (0x1EE00, 0x1EE03, 4), + (0x1EE04, 0x1EE04, 29), + (0x1EE05, 0x1EE1F, 4), + (0x1EE20, 0x1EE20, 29), + (0x1EE21, 0x1EE22, 4), + (0x1EE23, 0x1EE23, 29), + (0x1EE24, 0x1EE24, 4), + (0x1EE25, 0x1EE26, 29), + (0x1EE27, 0x1EE27, 4), + (0x1EE28, 0x1EE28, 29), + (0x1EE29, 0x1EE32, 4), + (0x1EE33, 0x1EE33, 29), + (0x1EE34, 0x1EE37, 4), + (0x1EE38, 0x1EE38, 29), + (0x1EE39, 0x1EE39, 4), + (0x1EE3A, 0x1EE3A, 29), + (0x1EE3B, 0x1EE3B, 4), + (0x1EE3C, 0x1EE41, 29), + (0x1EE42, 0x1EE42, 4), + (0x1EE43, 0x1EE46, 29), + (0x1EE47, 0x1EE47, 4), + (0x1EE48, 0x1EE48, 29), + (0x1EE49, 0x1EE49, 4), + (0x1EE4A, 0x1EE4A, 29), + (0x1EE4B, 0x1EE4B, 4), + (0x1EE4C, 0x1EE4C, 29), + (0x1EE4D, 0x1EE4F, 4), + (0x1EE50, 0x1EE50, 29), + (0x1EE51, 0x1EE52, 4), + (0x1EE53, 0x1EE53, 29), + (0x1EE54, 0x1EE54, 4), + (0x1EE55, 0x1EE56, 29), + (0x1EE57, 0x1EE57, 4), + (0x1EE58, 0x1EE58, 29), + (0x1EE59, 0x1EE59, 4), + (0x1EE5A, 0x1EE5A, 29), + (0x1EE5B, 0x1EE5B, 4), + (0x1EE5C, 0x1EE5C, 29), + (0x1EE5D, 0x1EE5D, 4), + (0x1EE5E, 0x1EE5E, 29), + (0x1EE5F, 0x1EE5F, 4), + (0x1EE60, 0x1EE60, 29), + (0x1EE61, 0x1EE62, 4), + (0x1EE63, 0x1EE63, 29), + (0x1EE64, 0x1EE64, 4), + (0x1EE65, 0x1EE66, 29), + (0x1EE67, 0x1EE6A, 4), + (0x1EE6B, 0x1EE6B, 29), + (0x1EE6C, 0x1EE72, 4), + (0x1EE73, 0x1EE73, 29), + (0x1EE74, 0x1EE77, 4), + (0x1EE78, 0x1EE78, 29), + (0x1EE79, 0x1EE7C, 4), + (0x1EE7D, 0x1EE7D, 29), + (0x1EE7E, 0x1EE7E, 4), + (0x1EE7F, 0x1EE7F, 29), + (0x1EE80, 0x1EE89, 4), + (0x1EE8A, 0x1EE8A, 29), + (0x1EE8B, 0x1EE9B, 4), + (0x1EE9C, 0x1EEA0, 29), + (0x1EEA1, 0x1EEA3, 4), + (0x1EEA4, 0x1EEA4, 29), + (0x1EEA5, 0x1EEA9, 4), + (0x1EEAA, 0x1EEAA, 29), + (0x1EEAB, 0x1EEBB, 4), + (0x1EEBC, 0x1EEEF, 29), + (0x1EEF0, 0x1EEF1, 18), + (0x1EEF2, 0x1EFFF, 29), + (0x1F000, 0x1F02B, 21), + (0x1F02C, 0x1F02F, 29), + (0x1F030, 0x1F093, 21), + (0x1F094, 0x1F09F, 29), + (0x1F0A0, 0x1F0AE, 21), + (0x1F0AF, 0x1F0B0, 29), + (0x1F0B1, 0x1F0BF, 21), + (0x1F0C0, 0x1F0C0, 29), + (0x1F0C1, 0x1F0CF, 21), + (0x1F0D0, 0x1F0D0, 29), + (0x1F0D1, 0x1F0F5, 21), + (0x1F0F6, 0x1F0FF, 29), + (0x1F100, 0x1F10C, 10), + (0x1F10D, 0x1F1AE, 21), + (0x1F1AF, 0x1F1E5, 29), + (0x1F1E6, 0x1F202, 21), + (0x1F203, 0x1F20F, 29), + (0x1F210, 0x1F23B, 21), + (0x1F23C, 0x1F23F, 29), + (0x1F240, 0x1F248, 21), + (0x1F249, 0x1F24F, 29), + (0x1F250, 0x1F251, 21), + (0x1F252, 0x1F25F, 29), + (0x1F260, 0x1F265, 21), + (0x1F266, 0x1F2FF, 29), + (0x1F300, 0x1F3FA, 21), + (0x1F3FB, 0x1F3FF, 20), + (0x1F400, 0x1F6D9, 21), + (0x1F6DA, 0x1F6DB, 29), + (0x1F6DC, 0x1F6EC, 21), + (0x1F6ED, 0x1F6EF, 29), + (0x1F6F0, 0x1F6FC, 21), + (0x1F6FD, 0x1F6FF, 29), + (0x1F700, 0x1F7DB, 21), + (0x1F7DC, 0x1F7DF, 29), + (0x1F7E0, 0x1F7EB, 21), + (0x1F7EC, 0x1F7EF, 29), + (0x1F7F0, 0x1F80B, 21), + (0x1F80C, 0x1F80F, 29), + (0x1F810, 0x1F847, 21), + (0x1F848, 0x1F84F, 29), + (0x1F850, 0x1F859, 21), + (0x1F85A, 0x1F85F, 29), + (0x1F860, 0x1F887, 21), + (0x1F888, 0x1F88F, 29), + (0x1F890, 0x1F8AD, 21), + (0x1F8AE, 0x1F8AF, 29), + (0x1F8B0, 0x1F8BB, 21), + (0x1F8BC, 0x1F8BF, 29), + (0x1F8C0, 0x1F8C1, 21), + (0x1F8C2, 0x1F8CF, 29), + (0x1F8D0, 0x1F8D8, 18), + (0x1F8D9, 0x1F8FF, 29), + (0x1F900, 0x1FA57, 21), + (0x1FA58, 0x1FA5F, 29), + (0x1FA60, 0x1FA6D, 21), + (0x1FA6E, 0x1FA6F, 29), + (0x1FA70, 0x1FA7C, 21), + (0x1FA7D, 0x1FA7F, 29), + (0x1FA80, 0x1FAC6, 21), + (0x1FAC7, 0x1FAC7, 29), + (0x1FAC8, 0x1FAC8, 21), + (0x1FAC9, 0x1FACB, 29), + (0x1FACC, 0x1FADD, 21), + (0x1FADE, 0x1FADE, 29), + (0x1FADF, 0x1FAEB, 21), + (0x1FAEC, 0x1FAEE, 29), + (0x1FAEF, 0x1FAFA, 21), + (0x1FAFB, 0x1FAFF, 29), + (0x1FB00, 0x1FB92, 21), + (0x1FB93, 0x1FB93, 29), + (0x1FB94, 0x1FBEF, 21), + (0x1FBF0, 0x1FBF9, 8), + (0x1FBFA, 0x1FBFA, 21), + (0x1FBFB, 0x1FFFF, 29), + (0x20000, 0x2A6DF, 4), + (0x2A6E0, 0x2A6FF, 29), + (0x2A700, 0x2B81E, 4), + (0x2B81F, 0x2B81F, 29), + (0x2B820, 0x2CEAD, 4), + (0x2CEAE, 0x2CEAF, 29), + (0x2CEB0, 0x2EBE0, 4), + (0x2EBE1, 0x2EBEF, 29), + (0x2EBF0, 0x2EE5D, 4), + (0x2EE5E, 0x2F7FF, 29), + (0x2F800, 0x2FA1D, 4), + (0x2FA1E, 0x2FFFF, 29), + (0x30000, 0x3134A, 4), + (0x3134B, 0x3134F, 29), + (0x31350, 0x33479, 4), + (0x3347A, 0x3CFFF, 29), + (0x3D000, 0x3FC3F, 4), + (0x3FC40, 0xE0000, 29), + (0xE0001, 0xE0001, 26), + (0xE0002, 0xE001F, 29), + (0xE0020, 0xE007F, 26), + (0xE0080, 0xE00FF, 29), + (0xE0100, 0xE01EF, 5), + (0xE01F0, 0xEFFFF, 29), + (0xF0000, 0xFFFFD, 28), + (0xFFFFE, 0xFFFFF, 29), + (0x100000, 0x10FFFD, 28), + (0x10FFFE, 0x10FFFF, 29), +]; + +/// The code points with the binary property ASCII_Hex_Digit, as ranges. +pub static BINARY_ASCII_HEX_DIGIT: &[(u32, u32)] = &[(0x30, 0x39), (0x41, 0x46), (0x61, 0x66)]; + +/// The code points with the binary property Alphabetic, as ranges. +pub static BINARY_ALPHABETIC: &[(u32, u32)] = &[ + (0x41, 0x5A), + (0x61, 0x7A), + (0xAA, 0xAA), + (0xB5, 0xB5), + (0xBA, 0xBA), + (0xC0, 0xD6), + (0xD8, 0xF6), + (0xF8, 0x2C1), + (0x2C6, 0x2D1), + (0x2E0, 0x2E4), + (0x2EC, 0x2EC), + (0x2EE, 0x2EE), + (0x345, 0x345), + (0x363, 0x374), + (0x376, 0x377), + (0x37A, 0x37D), + (0x37F, 0x37F), + (0x386, 0x386), + (0x388, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x3A1), + (0x3A3, 0x3F5), + (0x3F7, 0x481), + (0x48A, 0x52F), + (0x531, 0x556), + (0x558, 0x559), + (0x560, 0x588), + (0x58B, 0x58C), + (0x5B0, 0x5BD), + (0x5BF, 0x5BF), + (0x5C1, 0x5C2), + (0x5C4, 0x5C5), + (0x5C7, 0x5C9), + (0x5D0, 0x5EA), + (0x5EF, 0x5F2), + (0x610, 0x61A), + (0x620, 0x657), + (0x659, 0x65F), + (0x66E, 0x6D3), + (0x6D5, 0x6DC), + (0x6E1, 0x6E8), + (0x6ED, 0x6EF), + (0x6FA, 0x6FC), + (0x6FF, 0x6FF), + (0x710, 0x73F), + (0x74D, 0x7B1), + (0x7CA, 0x7EA), + (0x7F4, 0x7F5), + (0x7FA, 0x7FA), + (0x800, 0x817), + (0x81A, 0x82C), + (0x840, 0x858), + (0x860, 0x86A), + (0x870, 0x887), + (0x889, 0x88F), + (0x897, 0x897), + (0x8A0, 0x8C9), + (0x8D4, 0x8DF), + (0x8E3, 0x8E9), + (0x8F0, 0x93B), + (0x93D, 0x94C), + (0x94E, 0x950), + (0x955, 0x963), + (0x971, 0x983), + (0x985, 0x98C), + (0x98F, 0x990), + (0x993, 0x9A8), + (0x9AA, 0x9B0), + (0x9B2, 0x9B2), + (0x9B6, 0x9B9), + (0x9BD, 0x9C4), + (0x9C7, 0x9C8), + (0x9CB, 0x9CC), + (0x9CE, 0x9CE), + (0x9D7, 0x9D7), + (0x9DC, 0x9DD), + (0x9DF, 0x9E3), + (0x9F0, 0x9F1), + (0x9FC, 0x9FC), + (0xA01, 0xA03), + (0xA05, 0xA0A), + (0xA0F, 0xA10), + (0xA13, 0xA28), + (0xA2A, 0xA30), + (0xA32, 0xA33), + (0xA35, 0xA36), + (0xA38, 0xA39), + (0xA3E, 0xA42), + (0xA47, 0xA48), + (0xA4B, 0xA4C), + (0xA51, 0xA51), + (0xA59, 0xA5C), + (0xA5E, 0xA5E), + (0xA70, 0xA75), + (0xA81, 0xA83), + (0xA85, 0xA8D), + (0xA8F, 0xA91), + (0xA93, 0xAA8), + (0xAAA, 0xAB0), + (0xAB2, 0xAB3), + (0xAB5, 0xAB9), + (0xABD, 0xAC5), + (0xAC7, 0xAC9), + (0xACB, 0xACC), + (0xAD0, 0xAD0), + (0xAE0, 0xAE3), + (0xAF9, 0xAFC), + (0xB01, 0xB03), + (0xB05, 0xB0C), + (0xB0F, 0xB10), + (0xB13, 0xB28), + (0xB2A, 0xB30), + (0xB32, 0xB33), + (0xB35, 0xB39), + (0xB3D, 0xB44), + (0xB47, 0xB48), + (0xB4B, 0xB4C), + (0xB56, 0xB57), + (0xB5C, 0xB5D), + (0xB5F, 0xB63), + (0xB71, 0xB71), + (0xB82, 0xB83), + (0xB85, 0xB8A), + (0xB8E, 0xB90), + (0xB92, 0xB95), + (0xB99, 0xB9A), + (0xB9C, 0xB9C), + (0xB9E, 0xB9F), + (0xBA3, 0xBA4), + (0xBA8, 0xBAA), + (0xBAE, 0xBB9), + (0xBBE, 0xBC2), + (0xBC6, 0xBC8), + (0xBCA, 0xBCC), + (0xBD0, 0xBD0), + (0xBD7, 0xBD7), + (0xC00, 0xC0C), + (0xC0E, 0xC10), + (0xC12, 0xC28), + (0xC2A, 0xC39), + (0xC3D, 0xC44), + (0xC46, 0xC48), + (0xC4A, 0xC4C), + (0xC55, 0xC56), + (0xC58, 0xC5A), + (0xC5C, 0xC5D), + (0xC60, 0xC63), + (0xC80, 0xC83), + (0xC85, 0xC8C), + (0xC8E, 0xC90), + (0xC92, 0xCA8), + (0xCAA, 0xCB3), + (0xCB5, 0xCB9), + (0xCBD, 0xCC4), + (0xCC6, 0xCC8), + (0xCCA, 0xCCC), + (0xCD5, 0xCD6), + (0xCDC, 0xCDE), + (0xCE0, 0xCE3), + (0xCF1, 0xCF3), + (0xD00, 0xD0C), + (0xD0E, 0xD10), + (0xD12, 0xD3A), + (0xD3D, 0xD44), + (0xD46, 0xD48), + (0xD4A, 0xD4C), + (0xD4E, 0xD4E), + (0xD54, 0xD57), + (0xD5F, 0xD63), + (0xD7A, 0xD7F), + (0xD81, 0xD83), + (0xD85, 0xD96), + (0xD9A, 0xDB1), + (0xDB3, 0xDBB), + (0xDBD, 0xDBD), + (0xDC0, 0xDC6), + (0xDCF, 0xDD4), + (0xDD6, 0xDD6), + (0xDD8, 0xDDF), + (0xDF2, 0xDF3), + (0xE01, 0xE3A), + (0xE40, 0xE46), + (0xE4D, 0xE4D), + (0xE81, 0xE82), + (0xE84, 0xE84), + (0xE86, 0xE8A), + (0xE8C, 0xEA3), + (0xEA5, 0xEA5), + (0xEA7, 0xEB9), + (0xEBB, 0xEBD), + (0xEC0, 0xEC4), + (0xEC6, 0xEC6), + (0xECD, 0xECD), + (0xEDC, 0xEDF), + (0xF00, 0xF00), + (0xF40, 0xF47), + (0xF49, 0xF6C), + (0xF71, 0xF83), + (0xF88, 0xF97), + (0xF99, 0xFBC), + (0x1000, 0x1036), + (0x1038, 0x1038), + (0x103B, 0x103F), + (0x1050, 0x108F), + (0x109A, 0x109D), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x10D0, 0x10FA), + (0x10FC, 0x1248), + (0x124A, 0x124D), + (0x1250, 0x1256), + (0x1258, 0x1258), + (0x125A, 0x125D), + (0x1260, 0x1288), + (0x128A, 0x128D), + (0x1290, 0x12B0), + (0x12B2, 0x12B5), + (0x12B8, 0x12BE), + (0x12C0, 0x12C0), + (0x12C2, 0x12C5), + (0x12C8, 0x12D6), + (0x12D8, 0x1310), + (0x1312, 0x1315), + (0x1318, 0x135A), + (0x1380, 0x138F), + (0x13A0, 0x13F5), + (0x13F8, 0x13FD), + (0x1401, 0x166C), + (0x166F, 0x167F), + (0x1681, 0x169A), + (0x16A0, 0x16EA), + (0x16EE, 0x16F8), + (0x1700, 0x1713), + (0x171F, 0x1733), + (0x1740, 0x1753), + (0x1760, 0x176C), + (0x176E, 0x1770), + (0x1772, 0x1773), + (0x1780, 0x17B3), + (0x17B6, 0x17C8), + (0x17D7, 0x17D7), + (0x17DC, 0x17DC), + (0x1820, 0x1878), + (0x1880, 0x18AA), + (0x18B0, 0x18F5), + (0x1900, 0x191E), + (0x1920, 0x192B), + (0x1930, 0x1938), + (0x1950, 0x196D), + (0x1970, 0x1974), + (0x1980, 0x19AB), + (0x19B0, 0x19C9), + (0x1A00, 0x1A1B), + (0x1A20, 0x1A5E), + (0x1A61, 0x1A74), + (0x1AA7, 0x1AA7), + (0x1ABF, 0x1AC0), + (0x1ACC, 0x1ACE), + (0x1B00, 0x1B33), + (0x1B35, 0x1B43), + (0x1B45, 0x1B4C), + (0x1B80, 0x1BA9), + (0x1BAC, 0x1BAF), + (0x1BBA, 0x1BE5), + (0x1BE7, 0x1BF1), + (0x1C00, 0x1C36), + (0x1C4D, 0x1C4F), + (0x1C5A, 0x1C7D), + (0x1C80, 0x1C8A), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1CE9, 0x1CEC), + (0x1CEE, 0x1CF3), + (0x1CF5, 0x1CF6), + (0x1CFA, 0x1CFA), + (0x1D00, 0x1DBF), + (0x1DD3, 0x1DF4), + (0x1E00, 0x1F15), + (0x1F18, 0x1F1D), + (0x1F20, 0x1F45), + (0x1F48, 0x1F4D), + (0x1F50, 0x1F57), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F7D), + (0x1F80, 0x1FB4), + (0x1FB6, 0x1FBC), + (0x1FBE, 0x1FBE), + (0x1FC2, 0x1FC4), + (0x1FC6, 0x1FCC), + (0x1FD0, 0x1FD3), + (0x1FD6, 0x1FDB), + (0x1FE0, 0x1FEC), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FFC), + (0x2071, 0x2071), + (0x207F, 0x207F), + (0x208F, 0x209F), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210A, 0x2113), + (0x2115, 0x2115), + (0x2119, 0x211D), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212A, 0x212D), + (0x212F, 0x2139), + (0x213C, 0x213F), + (0x2145, 0x2149), + (0x214E, 0x214E), + (0x2160, 0x2188), + (0x24B6, 0x24E9), + (0x2C00, 0x2CE4), + (0x2CEB, 0x2CEE), + (0x2CF2, 0x2CF3), + (0x2D00, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0x2D30, 0x2D67), + (0x2D6F, 0x2D6F), + (0x2D80, 0x2D96), + (0x2DA0, 0x2DA6), + (0x2DA8, 0x2DAE), + (0x2DB0, 0x2DB6), + (0x2DB8, 0x2DBE), + (0x2DC0, 0x2DC6), + (0x2DC8, 0x2DCE), + (0x2DD0, 0x2DD6), + (0x2DD8, 0x2DDE), + (0x2DE0, 0x2DFF), + (0x2E2F, 0x2E2F), + (0x3005, 0x3007), + (0x3021, 0x3029), + (0x3031, 0x3035), + (0x3038, 0x303C), + (0x3041, 0x3096), + (0x309D, 0x309F), + (0x30A1, 0x30FA), + (0x30FC, 0x30FF), + (0x3105, 0x312F), + (0x3131, 0x318E), + (0x31A0, 0x31BF), + (0x31F0, 0x31FF), + (0x3400, 0x4DBF), + (0x4E00, 0xA48C), + (0xA4D0, 0xA4FD), + (0xA500, 0xA60C), + (0xA610, 0xA61F), + (0xA62A, 0xA62B), + (0xA640, 0xA66E), + (0xA674, 0xA67B), + (0xA67F, 0xA6EF), + (0xA717, 0xA71F), + (0xA722, 0xA788), + (0xA78B, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F1, 0xA805), + (0xA807, 0xA827), + (0xA840, 0xA873), + (0xA880, 0xA8C3), + (0xA8C5, 0xA8C5), + (0xA8F2, 0xA8F7), + (0xA8FB, 0xA8FB), + (0xA8FD, 0xA8FF), + (0xA90A, 0xA92A), + (0xA930, 0xA952), + (0xA960, 0xA97C), + (0xA980, 0xA9B2), + (0xA9B4, 0xA9BF), + (0xA9CF, 0xA9CF), + (0xA9E0, 0xA9EF), + (0xA9FA, 0xA9FE), + (0xAA00, 0xAA36), + (0xAA40, 0xAA4D), + (0xAA60, 0xAA76), + (0xAA7A, 0xAABE), + (0xAAC0, 0xAAC0), + (0xAAC2, 0xAAC2), + (0xAADB, 0xAADD), + (0xAAE0, 0xAAEF), + (0xAAF2, 0xAAF5), + (0xAB01, 0xAB06), + (0xAB09, 0xAB0E), + (0xAB11, 0xAB16), + (0xAB20, 0xAB26), + (0xAB28, 0xAB2E), + (0xAB30, 0xAB5A), + (0xAB5C, 0xAB69), + (0xAB6C, 0xAB6D), + (0xAB70, 0xABEA), + (0xAC00, 0xD7A3), + (0xD7B0, 0xD7C6), + (0xD7CB, 0xD7FB), + (0xF900, 0xFA6D), + (0xFA70, 0xFAD9), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFB1D, 0xFB28), + (0xFB2A, 0xFB36), + (0xFB38, 0xFB3C), + (0xFB3E, 0xFB3E), + (0xFB40, 0xFB41), + (0xFB43, 0xFB44), + (0xFB46, 0xFBB1), + (0xFBD3, 0xFD3D), + (0xFD50, 0xFD8F), + (0xFD92, 0xFDC7), + (0xFDF0, 0xFDFB), + (0xFE70, 0xFE74), + (0xFE76, 0xFEFC), + (0xFF21, 0xFF3A), + (0xFF41, 0xFF5A), + (0xFF66, 0xFFBE), + (0xFFC2, 0xFFC7), + (0xFFCA, 0xFFCF), + (0xFFD2, 0xFFD7), + (0xFFDA, 0xFFDC), + (0x10000, 0x1000B), + (0x1000D, 0x10026), + (0x10028, 0x1003A), + (0x1003C, 0x1003D), + (0x1003F, 0x1004D), + (0x10050, 0x1005D), + (0x10080, 0x100FA), + (0x10140, 0x10174), + (0x10280, 0x1029C), + (0x102A0, 0x102D0), + (0x10300, 0x1031F), + (0x1032D, 0x1034A), + (0x10350, 0x1037A), + (0x10380, 0x1039D), + (0x103A0, 0x103C3), + (0x103C8, 0x103CF), + (0x103D1, 0x103D5), + (0x10400, 0x1049D), + (0x104B0, 0x104D3), + (0x104D8, 0x104FB), + (0x10500, 0x10527), + (0x10530, 0x10563), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x105C0, 0x105F3), + (0x10600, 0x10736), + (0x10740, 0x10755), + (0x10760, 0x10767), + (0x10780, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BF), + (0x10800, 0x10805), + (0x10808, 0x10808), + (0x1080A, 0x10835), + (0x10837, 0x10838), + (0x1083C, 0x1083C), + (0x1083F, 0x10855), + (0x10860, 0x10876), + (0x10880, 0x1089E), + (0x108E0, 0x108F2), + (0x108F4, 0x108F5), + (0x10900, 0x10915), + (0x10920, 0x10939), + (0x10940, 0x10959), + (0x10980, 0x109B7), + (0x109BE, 0x109BF), + (0x10A00, 0x10A03), + (0x10A05, 0x10A06), + (0x10A0C, 0x10A13), + (0x10A15, 0x10A17), + (0x10A19, 0x10A35), + (0x10A60, 0x10A7C), + (0x10A80, 0x10A9C), + (0x10AC0, 0x10AC7), + (0x10AC9, 0x10AE4), + (0x10B00, 0x10B35), + (0x10B40, 0x10B55), + (0x10B60, 0x10B72), + (0x10B80, 0x10B91), + (0x10C00, 0x10C48), + (0x10C80, 0x10CB2), + (0x10CC0, 0x10CF2), + (0x10D00, 0x10D27), + (0x10D4A, 0x10D65), + (0x10D69, 0x10D69), + (0x10D6F, 0x10D85), + (0x10E80, 0x10EA9), + (0x10EAB, 0x10EAC), + (0x10EB0, 0x10EB1), + (0x10EC2, 0x10EC7), + (0x10ECB, 0x10ECD), + (0x10ED9, 0x10EEE), + (0x10EF3, 0x10EF3), + (0x10EF5, 0x10EF5), + (0x10EF7, 0x10EF8), + (0x10EFA, 0x10EFC), + (0x10F00, 0x10F1C), + (0x10F27, 0x10F27), + (0x10F30, 0x10F45), + (0x10F70, 0x10F81), + (0x10FB0, 0x10FC4), + (0x10FE0, 0x10FF6), + (0x11000, 0x11045), + (0x11071, 0x11075), + (0x11080, 0x110B8), + (0x110C2, 0x110C2), + (0x110D0, 0x110E8), + (0x11100, 0x11132), + (0x11144, 0x11147), + (0x11150, 0x11172), + (0x11176, 0x11176), + (0x11180, 0x111BF), + (0x111C1, 0x111C4), + (0x111CE, 0x111CF), + (0x111DA, 0x111DA), + (0x111DC, 0x111DC), + (0x11200, 0x11211), + (0x11213, 0x11234), + (0x11237, 0x11237), + (0x1123E, 0x11241), + (0x11280, 0x11286), + (0x11288, 0x11288), + (0x1128A, 0x1128D), + (0x1128F, 0x1129D), + (0x1129F, 0x112A8), + (0x112B0, 0x112E8), + (0x11300, 0x11303), + (0x11305, 0x1130C), + (0x1130F, 0x11310), + (0x11313, 0x11328), + (0x1132A, 0x11330), + (0x11332, 0x11333), + (0x11335, 0x11339), + (0x1133D, 0x11344), + (0x11347, 0x11348), + (0x1134B, 0x1134C), + (0x11350, 0x11350), + (0x11357, 0x11357), + (0x1135D, 0x11363), + (0x11380, 0x11389), + (0x1138B, 0x1138B), + (0x1138E, 0x1138E), + (0x11390, 0x113B5), + (0x113B7, 0x113C0), + (0x113C2, 0x113C2), + (0x113C5, 0x113C5), + (0x113C7, 0x113CA), + (0x113CC, 0x113CD), + (0x113D1, 0x113D1), + (0x113D3, 0x113D3), + (0x11400, 0x11441), + (0x11443, 0x11445), + (0x11447, 0x1144A), + (0x1145F, 0x11461), + (0x11480, 0x114C1), + (0x114C4, 0x114C5), + (0x114C7, 0x114C7), + (0x11580, 0x115B5), + (0x115B8, 0x115BE), + (0x115D8, 0x115DD), + (0x11600, 0x1163E), + (0x11640, 0x11640), + (0x11644, 0x11644), + (0x11680, 0x116B5), + (0x116B8, 0x116B8), + (0x11700, 0x1171A), + (0x1171D, 0x1172A), + (0x11740, 0x11746), + (0x11800, 0x11838), + (0x118A0, 0x118DF), + (0x118FF, 0x11906), + (0x11909, 0x11909), + (0x1190C, 0x11913), + (0x11915, 0x11916), + (0x11918, 0x11935), + (0x11937, 0x11938), + (0x1193B, 0x1193C), + (0x1193F, 0x11942), + (0x119A0, 0x119A7), + (0x119AA, 0x119D7), + (0x119DA, 0x119DF), + (0x119E1, 0x119E1), + (0x119E3, 0x119E4), + (0x11A00, 0x11A32), + (0x11A35, 0x11A3E), + (0x11A50, 0x11A97), + (0x11A9D, 0x11A9D), + (0x11AB0, 0x11AF8), + (0x11B0A, 0x11B0A), + (0x11B60, 0x11B67), + (0x11BC0, 0x11BE0), + (0x11C00, 0x11C08), + (0x11C0A, 0x11C36), + (0x11C38, 0x11C3E), + (0x11C40, 0x11C40), + (0x11C72, 0x11C8F), + (0x11C92, 0x11CA7), + (0x11CA9, 0x11CB6), + (0x11D00, 0x11D06), + (0x11D08, 0x11D09), + (0x11D0B, 0x11D36), + (0x11D3A, 0x11D3A), + (0x11D3C, 0x11D3D), + (0x11D3F, 0x11D41), + (0x11D43, 0x11D43), + (0x11D46, 0x11D47), + (0x11D60, 0x11D65), + (0x11D67, 0x11D68), + (0x11D6A, 0x11D8E), + (0x11D90, 0x11D91), + (0x11D93, 0x11D96), + (0x11D98, 0x11D98), + (0x11DB0, 0x11DDB), + (0x11DF0, 0x11DF1), + (0x11EE0, 0x11EF6), + (0x11F00, 0x11F10), + (0x11F12, 0x11F3A), + (0x11F3E, 0x11F40), + (0x11FB0, 0x11FB0), + (0x12000, 0x12399), + (0x12400, 0x1246F), + (0x12475, 0x12543), + (0x12550, 0x12686), + (0x12F90, 0x12FF0), + (0x13000, 0x1342F), + (0x13441, 0x13446), + (0x13460, 0x143FA), + (0x14400, 0x14646), + (0x16100, 0x1612E), + (0x16800, 0x16A38), + (0x16A40, 0x16A5E), + (0x16A70, 0x16ABE), + (0x16AD0, 0x16AED), + (0x16B00, 0x16B2F), + (0x16B40, 0x16B43), + (0x16B63, 0x16B77), + (0x16B7D, 0x16B8F), + (0x16D40, 0x16D6C), + (0x16E40, 0x16E7F), + (0x16EA0, 0x16EB8), + (0x16EBB, 0x16ED3), + (0x16F00, 0x16F4A), + (0x16F4F, 0x16F87), + (0x16F8F, 0x16F9F), + (0x16FE0, 0x16FE1), + (0x16FE3, 0x16FE3), + (0x16FF0, 0x16FF6), + (0x17000, 0x18CDA), + (0x18CFF, 0x18D20), + (0x18D80, 0x18DF2), + (0x18E00, 0x19191), + (0x191A0, 0x191D2), + (0x1AFF0, 0x1AFF3), + (0x1AFF5, 0x1AFFB), + (0x1AFFD, 0x1AFFE), + (0x1B000, 0x1B128), + (0x1B132, 0x1B132), + (0x1B150, 0x1B152), + (0x1B155, 0x1B155), + (0x1B164, 0x1B168), + (0x1B170, 0x1B2FB), + (0x1BC00, 0x1BC6A), + (0x1BC70, 0x1BC7C), + (0x1BC80, 0x1BC88), + (0x1BC90, 0x1BC99), + (0x1BC9E, 0x1BC9E), + (0x1D400, 0x1D454), + (0x1D456, 0x1D49C), + (0x1D49E, 0x1D49F), + (0x1D4A2, 0x1D4A2), + (0x1D4A5, 0x1D4A6), + (0x1D4A9, 0x1D4AC), + (0x1D4AE, 0x1D4B9), + (0x1D4BB, 0x1D4BB), + (0x1D4BD, 0x1D4C3), + (0x1D4C5, 0x1D505), + (0x1D507, 0x1D50A), + (0x1D50D, 0x1D514), + (0x1D516, 0x1D51C), + (0x1D51E, 0x1D539), + (0x1D53B, 0x1D53E), + (0x1D540, 0x1D544), + (0x1D546, 0x1D546), + (0x1D54A, 0x1D550), + (0x1D552, 0x1D6A6), + (0x1D6A8, 0x1D6C0), + (0x1D6C2, 0x1D6DA), + (0x1D6DC, 0x1D6FA), + (0x1D6FC, 0x1D714), + (0x1D716, 0x1D734), + (0x1D736, 0x1D74E), + (0x1D750, 0x1D76E), + (0x1D770, 0x1D788), + (0x1D78A, 0x1D7A8), + (0x1D7AA, 0x1D7C2), + (0x1D7C4, 0x1D7CB), + (0x1DF00, 0x1DF81), + (0x1DF90, 0x1DF96), + (0x1DFCD, 0x1E006), + (0x1E008, 0x1E018), + (0x1E01B, 0x1E021), + (0x1E023, 0x1E024), + (0x1E026, 0x1E02A), + (0x1E030, 0x1E06D), + (0x1E08F, 0x1E08F), + (0x1E100, 0x1E12C), + (0x1E137, 0x1E13D), + (0x1E14E, 0x1E14E), + (0x1E290, 0x1E2AD), + (0x1E2C0, 0x1E2EB), + (0x1E4D0, 0x1E4EB), + (0x1E5D0, 0x1E5ED), + (0x1E5F0, 0x1E5F0), + (0x1E6C0, 0x1E6DE), + (0x1E6E0, 0x1E6F5), + (0x1E6FE, 0x1E6FF), + (0x1E7E0, 0x1E7E6), + (0x1E7E8, 0x1E7EB), + (0x1E7ED, 0x1E7EE), + (0x1E7F0, 0x1E7FE), + (0x1E800, 0x1E8C4), + (0x1E900, 0x1E943), + (0x1E947, 0x1E947), + (0x1E94B, 0x1E94B), + (0x1EE00, 0x1EE03), + (0x1EE05, 0x1EE1F), + (0x1EE21, 0x1EE22), + (0x1EE24, 0x1EE24), + (0x1EE27, 0x1EE27), + (0x1EE29, 0x1EE32), + (0x1EE34, 0x1EE37), + (0x1EE39, 0x1EE39), + (0x1EE3B, 0x1EE3B), + (0x1EE42, 0x1EE42), + (0x1EE47, 0x1EE47), + (0x1EE49, 0x1EE49), + (0x1EE4B, 0x1EE4B), + (0x1EE4D, 0x1EE4F), + (0x1EE51, 0x1EE52), + (0x1EE54, 0x1EE54), + (0x1EE57, 0x1EE57), + (0x1EE59, 0x1EE59), + (0x1EE5B, 0x1EE5B), + (0x1EE5D, 0x1EE5D), + (0x1EE5F, 0x1EE5F), + (0x1EE61, 0x1EE62), + (0x1EE64, 0x1EE64), + (0x1EE67, 0x1EE6A), + (0x1EE6C, 0x1EE72), + (0x1EE74, 0x1EE77), + (0x1EE79, 0x1EE7C), + (0x1EE7E, 0x1EE7E), + (0x1EE80, 0x1EE89), + (0x1EE8B, 0x1EE9B), + (0x1EEA1, 0x1EEA3), + (0x1EEA5, 0x1EEA9), + (0x1EEAB, 0x1EEBB), + (0x1F130, 0x1F149), + (0x1F150, 0x1F169), + (0x1F170, 0x1F189), + (0x20000, 0x2A6DF), + (0x2A700, 0x2B81E), + (0x2B820, 0x2CEAD), + (0x2CEB0, 0x2EBE0), + (0x2EBF0, 0x2EE5D), + (0x2F800, 0x2FA1D), + (0x30000, 0x3134A), + (0x31350, 0x33479), + (0x3D000, 0x3FC3F), +]; + +/// The code points with the binary property Bidi_Control, as ranges. +pub static BINARY_BIDI_CONTROL: &[(u32, u32)] = &[ + (0x61C, 0x61C), + (0x200E, 0x200F), + (0x202A, 0x202E), + (0x2066, 0x2069), +]; + +/// The code points with the binary property Bidi_Mirrored, as ranges. +pub static BINARY_BIDI_MIRRORED: &[(u32, u32)] = &[ + (0x28, 0x29), + (0x3C, 0x3C), + (0x3E, 0x3E), + (0x5B, 0x5B), + (0x5D, 0x5D), + (0x7B, 0x7B), + (0x7D, 0x7D), + (0xAB, 0xAB), + (0xBB, 0xBB), + (0xF3A, 0xF3D), + (0x169B, 0x169C), + (0x2039, 0x203A), + (0x2045, 0x2046), + (0x207D, 0x207E), + (0x208D, 0x208E), + (0x2140, 0x2140), + (0x2201, 0x2204), + (0x2208, 0x220D), + (0x2211, 0x2211), + (0x2215, 0x2216), + (0x221A, 0x221D), + (0x221F, 0x2222), + (0x2224, 0x2224), + (0x2226, 0x2226), + (0x222B, 0x2233), + (0x2239, 0x2239), + (0x223B, 0x224C), + (0x2252, 0x2255), + (0x225F, 0x2260), + (0x2262, 0x2262), + (0x2264, 0x226B), + (0x226D, 0x228C), + (0x228F, 0x2292), + (0x2298, 0x2298), + (0x22A2, 0x22A3), + (0x22A6, 0x22B8), + (0x22BE, 0x22BF), + (0x22C9, 0x22CD), + (0x22D0, 0x22D1), + (0x22D6, 0x22ED), + (0x22F0, 0x22FF), + (0x2308, 0x230B), + (0x2320, 0x2321), + (0x2329, 0x232A), + (0x2768, 0x2775), + (0x27C0, 0x27C0), + (0x27C3, 0x27C6), + (0x27C8, 0x27C9), + (0x27CB, 0x27CD), + (0x27D3, 0x27D6), + (0x27DC, 0x27DE), + (0x27E2, 0x27EF), + (0x2983, 0x2998), + (0x299B, 0x29A0), + (0x29A2, 0x29AF), + (0x29B8, 0x29B8), + (0x29C0, 0x29C5), + (0x29C9, 0x29C9), + (0x29CE, 0x29D2), + (0x29D4, 0x29D5), + (0x29D8, 0x29DC), + (0x29E1, 0x29E1), + (0x29E3, 0x29E5), + (0x29E8, 0x29E9), + (0x29F4, 0x29F9), + (0x29FC, 0x29FD), + (0x2A0A, 0x2A1C), + (0x2A1E, 0x2A21), + (0x2A24, 0x2A24), + (0x2A26, 0x2A26), + (0x2A29, 0x2A29), + (0x2A2B, 0x2A2E), + (0x2A34, 0x2A35), + (0x2A3C, 0x2A3E), + (0x2A57, 0x2A58), + (0x2A64, 0x2A65), + (0x2A6A, 0x2A6D), + (0x2A6F, 0x2A70), + (0x2A73, 0x2A74), + (0x2A79, 0x2AA3), + (0x2AA6, 0x2AAD), + (0x2AAF, 0x2AD6), + (0x2ADC, 0x2ADC), + (0x2ADE, 0x2ADE), + (0x2AE2, 0x2AE6), + (0x2AEC, 0x2AEE), + (0x2AF3, 0x2AF3), + (0x2AF7, 0x2AFB), + (0x2AFD, 0x2AFD), + (0x2BFE, 0x2BFE), + (0x2E02, 0x2E05), + (0x2E09, 0x2E0A), + (0x2E0C, 0x2E0D), + (0x2E1C, 0x2E1D), + (0x2E20, 0x2E29), + (0x2E55, 0x2E5C), + (0x2E62, 0x2E63), + (0x3008, 0x3011), + (0x3014, 0x301B), + (0xFE59, 0xFE5E), + (0xFE64, 0xFE65), + (0xFF08, 0xFF09), + (0xFF1C, 0xFF1C), + (0xFF1E, 0xFF1E), + (0xFF3B, 0xFF3B), + (0xFF3D, 0xFF3D), + (0xFF5B, 0xFF5B), + (0xFF5D, 0xFF5D), + (0xFF5F, 0xFF60), + (0xFF62, 0xFF63), + (0x1CEDD, 0x1CEDF), + (0x1D6DB, 0x1D6DB), + (0x1D715, 0x1D715), + (0x1D74F, 0x1D74F), + (0x1D789, 0x1D789), + (0x1D7C3, 0x1D7C3), + (0x1DB03, 0x1DB09), + (0x1DB10, 0x1DB10), + (0x1DB17, 0x1DB18), + (0x1DB1B, 0x1DB1B), +]; + +/// The code points with the binary property Case_Ignorable, as ranges. +pub static BINARY_CASE_IGNORABLE: &[(u32, u32)] = &[ + (0x27, 0x27), + (0x2E, 0x2E), + (0x3A, 0x3A), + (0x5E, 0x5E), + (0x60, 0x60), + (0xA8, 0xA8), + (0xAD, 0xAD), + (0xAF, 0xAF), + (0xB4, 0xB4), + (0xB7, 0xB8), + (0x2B0, 0x36F), + (0x374, 0x375), + (0x37A, 0x37A), + (0x384, 0x385), + (0x387, 0x387), + (0x483, 0x489), + (0x558, 0x559), + (0x55F, 0x55F), + (0x58B, 0x58C), + (0x591, 0x5BD), + (0x5BF, 0x5BF), + (0x5C1, 0x5C2), + (0x5C4, 0x5C5), + (0x5C7, 0x5C9), + (0x5F4, 0x5F4), + (0x600, 0x605), + (0x610, 0x61A), + (0x61C, 0x61C), + (0x640, 0x640), + (0x64B, 0x65F), + (0x670, 0x670), + (0x6D6, 0x6DD), + (0x6DF, 0x6E8), + (0x6EA, 0x6ED), + (0x70F, 0x70F), + (0x711, 0x711), + (0x730, 0x74A), + (0x7A6, 0x7B0), + (0x7EB, 0x7F5), + (0x7FA, 0x7FA), + (0x7FD, 0x7FD), + (0x816, 0x82D), + (0x859, 0x85B), + (0x888, 0x888), + (0x890, 0x891), + (0x897, 0x89F), + (0x8C9, 0x902), + (0x93A, 0x93A), + (0x93C, 0x93C), + (0x941, 0x948), + (0x94D, 0x94D), + (0x951, 0x957), + (0x962, 0x963), + (0x971, 0x971), + (0x981, 0x981), + (0x9BC, 0x9BC), + (0x9C1, 0x9C4), + (0x9CD, 0x9CD), + (0x9E2, 0x9E3), + (0x9FE, 0x9FE), + (0xA01, 0xA02), + (0xA3C, 0xA3C), + (0xA41, 0xA42), + (0xA47, 0xA48), + (0xA4B, 0xA4D), + (0xA51, 0xA51), + (0xA70, 0xA71), + (0xA75, 0xA75), + (0xA81, 0xA82), + (0xABC, 0xABC), + (0xAC1, 0xAC5), + (0xAC7, 0xAC8), + (0xACD, 0xACD), + (0xAE2, 0xAE3), + (0xAFA, 0xAFF), + (0xB01, 0xB01), + (0xB3C, 0xB3C), + (0xB3F, 0xB3F), + (0xB41, 0xB44), + (0xB4D, 0xB4D), + (0xB53, 0xB56), + (0xB62, 0xB63), + (0xB82, 0xB82), + (0xBC0, 0xBC0), + (0xBCD, 0xBCD), + (0xC00, 0xC00), + (0xC04, 0xC04), + (0xC3C, 0xC3C), + (0xC3E, 0xC40), + (0xC46, 0xC48), + (0xC4A, 0xC4D), + (0xC55, 0xC56), + (0xC62, 0xC63), + (0xC81, 0xC81), + (0xCBC, 0xCBC), + (0xCBF, 0xCBF), + (0xCC6, 0xCC6), + (0xCCC, 0xCCD), + (0xCE2, 0xCE3), + (0xD00, 0xD01), + (0xD3B, 0xD3C), + (0xD41, 0xD44), + (0xD4D, 0xD4D), + (0xD62, 0xD63), + (0xD81, 0xD81), + (0xDCA, 0xDCA), + (0xDD2, 0xDD4), + (0xDD6, 0xDD6), + (0xE31, 0xE31), + (0xE34, 0xE3A), + (0xE46, 0xE4E), + (0xEB1, 0xEB1), + (0xEB4, 0xEBC), + (0xEC6, 0xEC6), + (0xEC8, 0xECE), + (0xF18, 0xF19), + (0xF35, 0xF35), + (0xF37, 0xF37), + (0xF39, 0xF39), + (0xF71, 0xF7E), + (0xF80, 0xF84), + (0xF86, 0xF87), + (0xF8D, 0xF97), + (0xF99, 0xFBC), + (0xFC6, 0xFC6), + (0x102D, 0x1030), + (0x1032, 0x1037), + (0x1039, 0x103A), + (0x103D, 0x103E), + (0x1058, 0x1059), + (0x105E, 0x1060), + (0x1071, 0x1074), + (0x1082, 0x1082), + (0x1085, 0x1086), + (0x108D, 0x108D), + (0x109D, 0x109D), + (0x10FC, 0x10FC), + (0x135D, 0x135F), + (0x1712, 0x1714), + (0x1732, 0x1733), + (0x1752, 0x1753), + (0x1772, 0x1773), + (0x17B4, 0x17B5), + (0x17B7, 0x17BD), + (0x17C6, 0x17C6), + (0x17C9, 0x17D3), + (0x17D7, 0x17D7), + (0x17DD, 0x17DD), + (0x180B, 0x180F), + (0x1843, 0x1843), + (0x1885, 0x1886), + (0x18A9, 0x18A9), + (0x1920, 0x1922), + (0x1927, 0x1928), + (0x1932, 0x1932), + (0x1939, 0x193B), + (0x1A17, 0x1A18), + (0x1A1B, 0x1A1B), + (0x1A56, 0x1A56), + (0x1A58, 0x1A5E), + (0x1A60, 0x1A60), + (0x1A62, 0x1A62), + (0x1A65, 0x1A6C), + (0x1A73, 0x1A7C), + (0x1A7F, 0x1A7F), + (0x1AA7, 0x1AA7), + (0x1AB0, 0x1AF0), + (0x1B00, 0x1B03), + (0x1B34, 0x1B34), + (0x1B36, 0x1B3A), + (0x1B3C, 0x1B3C), + (0x1B42, 0x1B42), + (0x1B6B, 0x1B73), + (0x1B80, 0x1B81), + (0x1BA2, 0x1BA5), + (0x1BA8, 0x1BA9), + (0x1BAB, 0x1BAD), + (0x1BE6, 0x1BE6), + (0x1BE8, 0x1BE9), + (0x1BED, 0x1BED), + (0x1BEF, 0x1BF1), + (0x1C2C, 0x1C33), + (0x1C36, 0x1C37), + (0x1C78, 0x1C7D), + (0x1CD0, 0x1CD2), + (0x1CD4, 0x1CE0), + (0x1CE2, 0x1CE8), + (0x1CED, 0x1CED), + (0x1CF4, 0x1CF4), + (0x1CF8, 0x1CF9), + (0x1D2C, 0x1D6A), + (0x1D78, 0x1D78), + (0x1D9B, 0x1DFF), + (0x1FBD, 0x1FBD), + (0x1FBF, 0x1FC1), + (0x1FCD, 0x1FCF), + (0x1FDD, 0x1FDF), + (0x1FED, 0x1FEF), + (0x1FFD, 0x1FFE), + (0x200B, 0x200F), + (0x2018, 0x2019), + (0x2024, 0x2024), + (0x2027, 0x2027), + (0x202A, 0x202E), + (0x2060, 0x2064), + (0x2066, 0x206F), + (0x2071, 0x2071), + (0x207F, 0x207F), + (0x208F, 0x209F), + (0x20D0, 0x20F0), + (0x2C7C, 0x2C7D), + (0x2CEF, 0x2CF1), + (0x2D6F, 0x2D6F), + (0x2D7F, 0x2D7F), + (0x2DE0, 0x2DFF), + (0x2E2F, 0x2E2F), + (0x3005, 0x3005), + (0x302A, 0x302D), + (0x3031, 0x3035), + (0x303B, 0x303B), + (0x3099, 0x309E), + (0x30FC, 0x30FE), + (0xA015, 0xA015), + (0xA4F8, 0xA4FD), + (0xA60C, 0xA60C), + (0xA66F, 0xA672), + (0xA674, 0xA67D), + (0xA67F, 0xA67F), + (0xA69C, 0xA69F), + (0xA6F0, 0xA6F1), + (0xA700, 0xA721), + (0xA770, 0xA770), + (0xA788, 0xA78A), + (0xA7F1, 0xA7F4), + (0xA7F8, 0xA7F9), + (0xA802, 0xA802), + (0xA806, 0xA806), + (0xA80B, 0xA80B), + (0xA825, 0xA826), + (0xA82C, 0xA82C), + (0xA8C4, 0xA8C5), + (0xA8E0, 0xA8F1), + (0xA8FF, 0xA8FF), + (0xA926, 0xA92D), + (0xA947, 0xA951), + (0xA980, 0xA982), + (0xA9B3, 0xA9B3), + (0xA9B6, 0xA9B9), + (0xA9BC, 0xA9BD), + (0xA9CF, 0xA9CF), + (0xA9E5, 0xA9E6), + (0xAA29, 0xAA2E), + (0xAA31, 0xAA32), + (0xAA35, 0xAA36), + (0xAA43, 0xAA43), + (0xAA4C, 0xAA4C), + (0xAA70, 0xAA70), + (0xAA7C, 0xAA7C), + (0xAAB0, 0xAAB0), + (0xAAB2, 0xAAB4), + (0xAAB7, 0xAAB8), + (0xAABE, 0xAABF), + (0xAAC1, 0xAAC1), + (0xAADD, 0xAADD), + (0xAAEC, 0xAAED), + (0xAAF3, 0xAAF4), + (0xAAF6, 0xAAF6), + (0xAB5B, 0xAB5F), + (0xAB69, 0xAB6B), + (0xABE5, 0xABE5), + (0xABE8, 0xABE8), + (0xABED, 0xABED), + (0xFB1E, 0xFB1E), + (0xFBB2, 0xFBC2), + (0xFE00, 0xFE0F), + (0xFE13, 0xFE13), + (0xFE20, 0xFE2F), + (0xFE52, 0xFE52), + (0xFE55, 0xFE55), + (0xFEFF, 0xFEFF), + (0xFF07, 0xFF07), + (0xFF0E, 0xFF0E), + (0xFF1A, 0xFF1A), + (0xFF3E, 0xFF3E), + (0xFF40, 0xFF40), + (0xFF70, 0xFF70), + (0xFF9E, 0xFF9F), + (0xFFE3, 0xFFE3), + (0xFFF9, 0xFFFB), + (0x101FD, 0x101FD), + (0x102E0, 0x102E0), + (0x10376, 0x1037A), + (0x10780, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BF), + (0x10A01, 0x10A03), + (0x10A05, 0x10A06), + (0x10A0C, 0x10A0F), + (0x10A38, 0x10A3A), + (0x10A3F, 0x10A3F), + (0x10AE5, 0x10AE6), + (0x10D24, 0x10D27), + (0x10D4E, 0x10D4E), + (0x10D69, 0x10D6D), + (0x10D6F, 0x10D6F), + (0x10EAB, 0x10EAC), + (0x10EC5, 0x10EC5), + (0x10EC9, 0x10ECF), + (0x10EF0, 0x10EFF), + (0x10F46, 0x10F50), + (0x10F82, 0x10F85), + (0x11001, 0x11001), + (0x11038, 0x11046), + (0x11070, 0x11070), + (0x11073, 0x11074), + (0x1107F, 0x11081), + (0x110B3, 0x110B6), + (0x110B9, 0x110BA), + (0x110BD, 0x110BD), + (0x110C2, 0x110C2), + (0x110CD, 0x110CD), + (0x11100, 0x11102), + (0x11127, 0x1112B), + (0x1112D, 0x11134), + (0x11173, 0x11173), + (0x11180, 0x11181), + (0x111B6, 0x111BE), + (0x111C9, 0x111CC), + (0x111CF, 0x111CF), + (0x1122F, 0x11231), + (0x11234, 0x11234), + (0x11236, 0x11237), + (0x1123E, 0x1123E), + (0x11241, 0x11241), + (0x112DF, 0x112DF), + (0x112E3, 0x112EA), + (0x11300, 0x11301), + (0x1133B, 0x1133C), + (0x11340, 0x11340), + (0x11366, 0x1136C), + (0x11370, 0x11374), + (0x113BB, 0x113C0), + (0x113CE, 0x113CE), + (0x113D0, 0x113D0), + (0x113D2, 0x113D2), + (0x113E1, 0x113E2), + (0x11438, 0x1143F), + (0x11442, 0x11444), + (0x11446, 0x11446), + (0x1145E, 0x1145E), + (0x114B3, 0x114B8), + (0x114BA, 0x114BA), + (0x114BF, 0x114C0), + (0x114C2, 0x114C3), + (0x115B2, 0x115B5), + (0x115BC, 0x115BD), + (0x115BF, 0x115C0), + (0x115DC, 0x115DD), + (0x11633, 0x1163A), + (0x1163D, 0x1163D), + (0x1163F, 0x11640), + (0x116AB, 0x116AB), + (0x116AD, 0x116AD), + (0x116B0, 0x116B5), + (0x116B7, 0x116B7), + (0x1171D, 0x1171D), + (0x1171F, 0x1171F), + (0x11722, 0x11725), + (0x11727, 0x1172B), + (0x1182F, 0x11837), + (0x11839, 0x1183A), + (0x1193B, 0x1193C), + (0x1193E, 0x1193E), + (0x11943, 0x11943), + (0x119D4, 0x119D7), + (0x119DA, 0x119DB), + (0x119E0, 0x119E0), + (0x11A01, 0x11A0A), + (0x11A33, 0x11A38), + (0x11A3B, 0x11A3E), + (0x11A47, 0x11A47), + (0x11A51, 0x11A56), + (0x11A59, 0x11A5B), + (0x11A8A, 0x11A96), + (0x11A98, 0x11A99), + (0x11B60, 0x11B60), + (0x11B62, 0x11B64), + (0x11B66, 0x11B66), + (0x11C30, 0x11C36), + (0x11C38, 0x11C3D), + (0x11C3F, 0x11C3F), + (0x11C92, 0x11CA7), + (0x11CAA, 0x11CB0), + (0x11CB2, 0x11CB3), + (0x11CB5, 0x11CB6), + (0x11D31, 0x11D36), + (0x11D3A, 0x11D3A), + (0x11D3C, 0x11D3D), + (0x11D3F, 0x11D45), + (0x11D47, 0x11D47), + (0x11D90, 0x11D91), + (0x11D95, 0x11D95), + (0x11D97, 0x11D97), + (0x11DD9, 0x11DD9), + (0x11DF0, 0x11DF0), + (0x11EF3, 0x11EF4), + (0x11F00, 0x11F01), + (0x11F36, 0x11F3A), + (0x11F40, 0x11F40), + (0x11F42, 0x11F42), + (0x11F5A, 0x11F5A), + (0x13430, 0x13440), + (0x13447, 0x13455), + (0x1611E, 0x16129), + (0x1612D, 0x1612F), + (0x16AF0, 0x16AF4), + (0x16B30, 0x16B36), + (0x16B40, 0x16B43), + (0x16D40, 0x16D42), + (0x16D6B, 0x16D6C), + (0x16F4F, 0x16F4F), + (0x16F8F, 0x16F9F), + (0x16FE0, 0x16FE1), + (0x16FE3, 0x16FE4), + (0x16FF2, 0x16FF3), + (0x1AFF0, 0x1AFF3), + (0x1AFF5, 0x1AFFB), + (0x1AFFD, 0x1AFFE), + (0x1BC9D, 0x1BC9E), + (0x1BCA0, 0x1BCA3), + (0x1CF00, 0x1CF2D), + (0x1CF30, 0x1CF46), + (0x1D127, 0x1D128), + (0x1D167, 0x1D169), + (0x1D173, 0x1D182), + (0x1D185, 0x1D18B), + (0x1D1AA, 0x1D1AD), + (0x1D242, 0x1D244), + (0x1D25B, 0x1D25C), + (0x1DA00, 0x1DA36), + (0x1DA3B, 0x1DA6C), + (0x1DA75, 0x1DA75), + (0x1DA84, 0x1DA84), + (0x1DA9B, 0x1DA9F), + (0x1DAA1, 0x1DAAF), + (0x1DFCD, 0x1E006), + (0x1E008, 0x1E018), + (0x1E01B, 0x1E021), + (0x1E023, 0x1E024), + (0x1E026, 0x1E02A), + (0x1E030, 0x1E06D), + (0x1E08F, 0x1E08F), + (0x1E130, 0x1E13D), + (0x1E2AE, 0x1E2AE), + (0x1E2EC, 0x1E2EF), + (0x1E4EB, 0x1E4EF), + (0x1E5EE, 0x1E5EF), + (0x1E6E3, 0x1E6E3), + (0x1E6E6, 0x1E6E6), + (0x1E6EE, 0x1E6EF), + (0x1E6F5, 0x1E6F5), + (0x1E6FF, 0x1E6FF), + (0x1E8D0, 0x1E8D6), + (0x1E944, 0x1E94B), + (0x1F3FB, 0x1F3FF), + (0xE0001, 0xE0001), + (0xE0020, 0xE007F), + (0xE0100, 0xE01EF), +]; + +/// The code points with the binary property Cased, as ranges. +pub static BINARY_CASED: &[(u32, u32)] = &[ + (0x41, 0x5A), + (0x61, 0x7A), + (0xAA, 0xAA), + (0xB5, 0xB5), + (0xBA, 0xBA), + (0xC0, 0xD6), + (0xD8, 0xF6), + (0xF8, 0x1BA), + (0x1BC, 0x1BF), + (0x1C4, 0x293), + (0x296, 0x2B8), + (0x2C0, 0x2C1), + (0x2E0, 0x2E4), + (0x345, 0x345), + (0x370, 0x373), + (0x376, 0x377), + (0x37A, 0x37D), + (0x37F, 0x37F), + (0x386, 0x386), + (0x388, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x3A1), + (0x3A3, 0x3F5), + (0x3F7, 0x481), + (0x48A, 0x52F), + (0x531, 0x556), + (0x558, 0x558), + (0x560, 0x588), + (0x58B, 0x58C), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x10D0, 0x10FA), + (0x10FC, 0x10FF), + (0x13A0, 0x13F5), + (0x13F8, 0x13FD), + (0x1C80, 0x1C8A), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1D00, 0x1DBF), + (0x1E00, 0x1F15), + (0x1F18, 0x1F1D), + (0x1F20, 0x1F45), + (0x1F48, 0x1F4D), + (0x1F50, 0x1F57), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F7D), + (0x1F80, 0x1FB4), + (0x1FB6, 0x1FBC), + (0x1FBE, 0x1FBE), + (0x1FC2, 0x1FC4), + (0x1FC6, 0x1FCC), + (0x1FD0, 0x1FD3), + (0x1FD6, 0x1FDB), + (0x1FE0, 0x1FEC), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FFC), + (0x2071, 0x2071), + (0x207F, 0x207F), + (0x2090, 0x209F), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210A, 0x2113), + (0x2115, 0x2115), + (0x2119, 0x211D), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212A, 0x212D), + (0x212F, 0x2134), + (0x2139, 0x2139), + (0x213C, 0x213F), + (0x2145, 0x2149), + (0x214E, 0x214E), + (0x2160, 0x217F), + (0x2183, 0x2184), + (0x24B6, 0x24E9), + (0x2C00, 0x2CE4), + (0x2CEB, 0x2CEE), + (0x2CF2, 0x2CF3), + (0x2D00, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0xA640, 0xA66D), + (0xA680, 0xA69D), + (0xA722, 0xA787), + (0xA78B, 0xA78E), + (0xA790, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F1, 0xA7F6), + (0xA7F8, 0xA7FA), + (0xAB30, 0xAB5A), + (0xAB5C, 0xAB69), + (0xAB6C, 0xAB6D), + (0xAB70, 0xABBF), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFF21, 0xFF3A), + (0xFF41, 0xFF5A), + (0x10400, 0x1044F), + (0x104B0, 0x104D3), + (0x104D8, 0x104FB), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x10780, 0x10780), + (0x10783, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BF), + (0x10C80, 0x10CB2), + (0x10CC0, 0x10CF2), + (0x10D50, 0x10D65), + (0x10D70, 0x10D85), + (0x118A0, 0x118DF), + (0x16E40, 0x16E7F), + (0x16EA0, 0x16EB8), + (0x16EBB, 0x16ED3), + (0x1D400, 0x1D454), + (0x1D456, 0x1D49C), + (0x1D49E, 0x1D49F), + (0x1D4A2, 0x1D4A2), + (0x1D4A5, 0x1D4A6), + (0x1D4A9, 0x1D4AC), + (0x1D4AE, 0x1D4B9), + (0x1D4BB, 0x1D4BB), + (0x1D4BD, 0x1D4C3), + (0x1D4C5, 0x1D505), + (0x1D507, 0x1D50A), + (0x1D50D, 0x1D514), + (0x1D516, 0x1D51C), + (0x1D51E, 0x1D539), + (0x1D53B, 0x1D53E), + (0x1D540, 0x1D544), + (0x1D546, 0x1D546), + (0x1D54A, 0x1D550), + (0x1D552, 0x1D6A6), + (0x1D6A8, 0x1D6C0), + (0x1D6C2, 0x1D6DA), + (0x1D6DC, 0x1D6FA), + (0x1D6FC, 0x1D714), + (0x1D716, 0x1D734), + (0x1D736, 0x1D74E), + (0x1D750, 0x1D76E), + (0x1D770, 0x1D788), + (0x1D78A, 0x1D7A8), + (0x1D7AA, 0x1D7C2), + (0x1D7C4, 0x1D7CB), + (0x1DF00, 0x1DF09), + (0x1DF0B, 0x1DF7F), + (0x1DF90, 0x1DF96), + (0x1DFCD, 0x1DFFF), + (0x1E030, 0x1E06D), + (0x1E900, 0x1E943), + (0x1F130, 0x1F149), + (0x1F150, 0x1F169), + (0x1F170, 0x1F189), +]; + +/// The code points with the binary property Changes_When_Casefolded, as ranges. +pub static BINARY_CHANGES_WHEN_CASEFOLDED: &[(u32, u32)] = &[ + (0x41, 0x5A), + (0xB5, 0xB5), + (0xC0, 0xD6), + (0xD8, 0xDF), + (0x100, 0x100), + (0x102, 0x102), + (0x104, 0x104), + (0x106, 0x106), + (0x108, 0x108), + (0x10A, 0x10A), + (0x10C, 0x10C), + (0x10E, 0x10E), + (0x110, 0x110), + (0x112, 0x112), + (0x114, 0x114), + (0x116, 0x116), + (0x118, 0x118), + (0x11A, 0x11A), + (0x11C, 0x11C), + (0x11E, 0x11E), + (0x120, 0x120), + (0x122, 0x122), + (0x124, 0x124), + (0x126, 0x126), + (0x128, 0x128), + (0x12A, 0x12A), + (0x12C, 0x12C), + (0x12E, 0x12E), + (0x130, 0x130), + (0x132, 0x132), + (0x134, 0x134), + (0x136, 0x136), + (0x139, 0x139), + (0x13B, 0x13B), + (0x13D, 0x13D), + (0x13F, 0x13F), + (0x141, 0x141), + (0x143, 0x143), + (0x145, 0x145), + (0x147, 0x147), + (0x149, 0x14A), + (0x14C, 0x14C), + (0x14E, 0x14E), + (0x150, 0x150), + (0x152, 0x152), + (0x154, 0x154), + (0x156, 0x156), + (0x158, 0x158), + (0x15A, 0x15A), + (0x15C, 0x15C), + (0x15E, 0x15E), + (0x160, 0x160), + (0x162, 0x162), + (0x164, 0x164), + (0x166, 0x166), + (0x168, 0x168), + (0x16A, 0x16A), + (0x16C, 0x16C), + (0x16E, 0x16E), + (0x170, 0x170), + (0x172, 0x172), + (0x174, 0x174), + (0x176, 0x176), + (0x178, 0x179), + (0x17B, 0x17B), + (0x17D, 0x17D), + (0x17F, 0x17F), + (0x181, 0x182), + (0x184, 0x184), + (0x186, 0x187), + (0x189, 0x18B), + (0x18E, 0x191), + (0x193, 0x194), + (0x196, 0x198), + (0x19C, 0x19D), + (0x19F, 0x1A0), + (0x1A2, 0x1A2), + (0x1A4, 0x1A4), + (0x1A6, 0x1A7), + (0x1A9, 0x1A9), + (0x1AC, 0x1AC), + (0x1AE, 0x1AF), + (0x1B1, 0x1B3), + (0x1B5, 0x1B5), + (0x1B7, 0x1B8), + (0x1BC, 0x1BC), + (0x1C4, 0x1C5), + (0x1C7, 0x1C8), + (0x1CA, 0x1CB), + (0x1CD, 0x1CD), + (0x1CF, 0x1CF), + (0x1D1, 0x1D1), + (0x1D3, 0x1D3), + (0x1D5, 0x1D5), + (0x1D7, 0x1D7), + (0x1D9, 0x1D9), + (0x1DB, 0x1DB), + (0x1DE, 0x1DE), + (0x1E0, 0x1E0), + (0x1E2, 0x1E2), + (0x1E4, 0x1E4), + (0x1E6, 0x1E6), + (0x1E8, 0x1E8), + (0x1EA, 0x1EA), + (0x1EC, 0x1EC), + (0x1EE, 0x1EE), + (0x1F1, 0x1F2), + (0x1F4, 0x1F4), + (0x1F6, 0x1F8), + (0x1FA, 0x1FA), + (0x1FC, 0x1FC), + (0x1FE, 0x1FE), + (0x200, 0x200), + (0x202, 0x202), + (0x204, 0x204), + (0x206, 0x206), + (0x208, 0x208), + (0x20A, 0x20A), + (0x20C, 0x20C), + (0x20E, 0x20E), + (0x210, 0x210), + (0x212, 0x212), + (0x214, 0x214), + (0x216, 0x216), + (0x218, 0x218), + (0x21A, 0x21A), + (0x21C, 0x21C), + (0x21E, 0x21E), + (0x220, 0x220), + (0x222, 0x222), + (0x224, 0x224), + (0x226, 0x226), + (0x228, 0x228), + (0x22A, 0x22A), + (0x22C, 0x22C), + (0x22E, 0x22E), + (0x230, 0x230), + (0x232, 0x232), + (0x23A, 0x23B), + (0x23D, 0x23E), + (0x241, 0x241), + (0x243, 0x246), + (0x248, 0x248), + (0x24A, 0x24A), + (0x24C, 0x24C), + (0x24E, 0x24E), + (0x345, 0x345), + (0x370, 0x370), + (0x372, 0x372), + (0x376, 0x376), + (0x37F, 0x37F), + (0x386, 0x386), + (0x388, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x38F), + (0x391, 0x3A1), + (0x3A3, 0x3AB), + (0x3C2, 0x3C2), + (0x3CF, 0x3D1), + (0x3D5, 0x3D6), + (0x3D8, 0x3D8), + (0x3DA, 0x3DA), + (0x3DC, 0x3DC), + (0x3DE, 0x3DE), + (0x3E0, 0x3E0), + (0x3E2, 0x3E2), + (0x3E4, 0x3E4), + (0x3E6, 0x3E6), + (0x3E8, 0x3E8), + (0x3EA, 0x3EA), + (0x3EC, 0x3EC), + (0x3EE, 0x3EE), + (0x3F0, 0x3F1), + (0x3F4, 0x3F5), + (0x3F7, 0x3F7), + (0x3F9, 0x3FA), + (0x3FD, 0x42F), + (0x460, 0x460), + (0x462, 0x462), + (0x464, 0x464), + (0x466, 0x466), + (0x468, 0x468), + (0x46A, 0x46A), + (0x46C, 0x46C), + (0x46E, 0x46E), + (0x470, 0x470), + (0x472, 0x472), + (0x474, 0x474), + (0x476, 0x476), + (0x478, 0x478), + (0x47A, 0x47A), + (0x47C, 0x47C), + (0x47E, 0x47E), + (0x480, 0x480), + (0x48A, 0x48A), + (0x48C, 0x48C), + (0x48E, 0x48E), + (0x490, 0x490), + (0x492, 0x492), + (0x494, 0x494), + (0x496, 0x496), + (0x498, 0x498), + (0x49A, 0x49A), + (0x49C, 0x49C), + (0x49E, 0x49E), + (0x4A0, 0x4A0), + (0x4A2, 0x4A2), + (0x4A4, 0x4A4), + (0x4A6, 0x4A6), + (0x4A8, 0x4A8), + (0x4AA, 0x4AA), + (0x4AC, 0x4AC), + (0x4AE, 0x4AE), + (0x4B0, 0x4B0), + (0x4B2, 0x4B2), + (0x4B4, 0x4B4), + (0x4B6, 0x4B6), + (0x4B8, 0x4B8), + (0x4BA, 0x4BA), + (0x4BC, 0x4BC), + (0x4BE, 0x4BE), + (0x4C0, 0x4C1), + (0x4C3, 0x4C3), + (0x4C5, 0x4C5), + (0x4C7, 0x4C7), + (0x4C9, 0x4C9), + (0x4CB, 0x4CB), + (0x4CD, 0x4CD), + (0x4D0, 0x4D0), + (0x4D2, 0x4D2), + (0x4D4, 0x4D4), + (0x4D6, 0x4D6), + (0x4D8, 0x4D8), + (0x4DA, 0x4DA), + (0x4DC, 0x4DC), + (0x4DE, 0x4DE), + (0x4E0, 0x4E0), + (0x4E2, 0x4E2), + (0x4E4, 0x4E4), + (0x4E6, 0x4E6), + (0x4E8, 0x4E8), + (0x4EA, 0x4EA), + (0x4EC, 0x4EC), + (0x4EE, 0x4EE), + (0x4F0, 0x4F0), + (0x4F2, 0x4F2), + (0x4F4, 0x4F4), + (0x4F6, 0x4F6), + (0x4F8, 0x4F8), + (0x4FA, 0x4FA), + (0x4FC, 0x4FC), + (0x4FE, 0x4FE), + (0x500, 0x500), + (0x502, 0x502), + (0x504, 0x504), + (0x506, 0x506), + (0x508, 0x508), + (0x50A, 0x50A), + (0x50C, 0x50C), + (0x50E, 0x50E), + (0x510, 0x510), + (0x512, 0x512), + (0x514, 0x514), + (0x516, 0x516), + (0x518, 0x518), + (0x51A, 0x51A), + (0x51C, 0x51C), + (0x51E, 0x51E), + (0x520, 0x520), + (0x522, 0x522), + (0x524, 0x524), + (0x526, 0x526), + (0x528, 0x528), + (0x52A, 0x52A), + (0x52C, 0x52C), + (0x52E, 0x52E), + (0x531, 0x556), + (0x587, 0x587), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x13F8, 0x13FD), + (0x1C80, 0x1C89), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1E00, 0x1E00), + (0x1E02, 0x1E02), + (0x1E04, 0x1E04), + (0x1E06, 0x1E06), + (0x1E08, 0x1E08), + (0x1E0A, 0x1E0A), + (0x1E0C, 0x1E0C), + (0x1E0E, 0x1E0E), + (0x1E10, 0x1E10), + (0x1E12, 0x1E12), + (0x1E14, 0x1E14), + (0x1E16, 0x1E16), + (0x1E18, 0x1E18), + (0x1E1A, 0x1E1A), + (0x1E1C, 0x1E1C), + (0x1E1E, 0x1E1E), + (0x1E20, 0x1E20), + (0x1E22, 0x1E22), + (0x1E24, 0x1E24), + (0x1E26, 0x1E26), + (0x1E28, 0x1E28), + (0x1E2A, 0x1E2A), + (0x1E2C, 0x1E2C), + (0x1E2E, 0x1E2E), + (0x1E30, 0x1E30), + (0x1E32, 0x1E32), + (0x1E34, 0x1E34), + (0x1E36, 0x1E36), + (0x1E38, 0x1E38), + (0x1E3A, 0x1E3A), + (0x1E3C, 0x1E3C), + (0x1E3E, 0x1E3E), + (0x1E40, 0x1E40), + (0x1E42, 0x1E42), + (0x1E44, 0x1E44), + (0x1E46, 0x1E46), + (0x1E48, 0x1E48), + (0x1E4A, 0x1E4A), + (0x1E4C, 0x1E4C), + (0x1E4E, 0x1E4E), + (0x1E50, 0x1E50), + (0x1E52, 0x1E52), + (0x1E54, 0x1E54), + (0x1E56, 0x1E56), + (0x1E58, 0x1E58), + (0x1E5A, 0x1E5A), + (0x1E5C, 0x1E5C), + (0x1E5E, 0x1E5E), + (0x1E60, 0x1E60), + (0x1E62, 0x1E62), + (0x1E64, 0x1E64), + (0x1E66, 0x1E66), + (0x1E68, 0x1E68), + (0x1E6A, 0x1E6A), + (0x1E6C, 0x1E6C), + (0x1E6E, 0x1E6E), + (0x1E70, 0x1E70), + (0x1E72, 0x1E72), + (0x1E74, 0x1E74), + (0x1E76, 0x1E76), + (0x1E78, 0x1E78), + (0x1E7A, 0x1E7A), + (0x1E7C, 0x1E7C), + (0x1E7E, 0x1E7E), + (0x1E80, 0x1E80), + (0x1E82, 0x1E82), + (0x1E84, 0x1E84), + (0x1E86, 0x1E86), + (0x1E88, 0x1E88), + (0x1E8A, 0x1E8A), + (0x1E8C, 0x1E8C), + (0x1E8E, 0x1E8E), + (0x1E90, 0x1E90), + (0x1E92, 0x1E92), + (0x1E94, 0x1E94), + (0x1E9A, 0x1E9B), + (0x1E9E, 0x1E9E), + (0x1EA0, 0x1EA0), + (0x1EA2, 0x1EA2), + (0x1EA4, 0x1EA4), + (0x1EA6, 0x1EA6), + (0x1EA8, 0x1EA8), + (0x1EAA, 0x1EAA), + (0x1EAC, 0x1EAC), + (0x1EAE, 0x1EAE), + (0x1EB0, 0x1EB0), + (0x1EB2, 0x1EB2), + (0x1EB4, 0x1EB4), + (0x1EB6, 0x1EB6), + (0x1EB8, 0x1EB8), + (0x1EBA, 0x1EBA), + (0x1EBC, 0x1EBC), + (0x1EBE, 0x1EBE), + (0x1EC0, 0x1EC0), + (0x1EC2, 0x1EC2), + (0x1EC4, 0x1EC4), + (0x1EC6, 0x1EC6), + (0x1EC8, 0x1EC8), + (0x1ECA, 0x1ECA), + (0x1ECC, 0x1ECC), + (0x1ECE, 0x1ECE), + (0x1ED0, 0x1ED0), + (0x1ED2, 0x1ED2), + (0x1ED4, 0x1ED4), + (0x1ED6, 0x1ED6), + (0x1ED8, 0x1ED8), + (0x1EDA, 0x1EDA), + (0x1EDC, 0x1EDC), + (0x1EDE, 0x1EDE), + (0x1EE0, 0x1EE0), + (0x1EE2, 0x1EE2), + (0x1EE4, 0x1EE4), + (0x1EE6, 0x1EE6), + (0x1EE8, 0x1EE8), + (0x1EEA, 0x1EEA), + (0x1EEC, 0x1EEC), + (0x1EEE, 0x1EEE), + (0x1EF0, 0x1EF0), + (0x1EF2, 0x1EF2), + (0x1EF4, 0x1EF4), + (0x1EF6, 0x1EF6), + (0x1EF8, 0x1EF8), + (0x1EFA, 0x1EFA), + (0x1EFC, 0x1EFC), + (0x1EFE, 0x1EFE), + (0x1F08, 0x1F0F), + (0x1F18, 0x1F1D), + (0x1F28, 0x1F2F), + (0x1F38, 0x1F3F), + (0x1F48, 0x1F4D), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F5F), + (0x1F68, 0x1F6F), + (0x1F80, 0x1FAF), + (0x1FB2, 0x1FB4), + (0x1FB7, 0x1FBC), + (0x1FC2, 0x1FC4), + (0x1FC7, 0x1FCC), + (0x1FD8, 0x1FDB), + (0x1FE8, 0x1FEC), + (0x1FF2, 0x1FF4), + (0x1FF7, 0x1FFC), + (0x2126, 0x2126), + (0x212A, 0x212B), + (0x2132, 0x2132), + (0x2160, 0x216F), + (0x2183, 0x2183), + (0x24B6, 0x24CF), + (0x2C00, 0x2C2F), + (0x2C60, 0x2C60), + (0x2C62, 0x2C64), + (0x2C67, 0x2C67), + (0x2C69, 0x2C69), + (0x2C6B, 0x2C6B), + (0x2C6D, 0x2C70), + (0x2C72, 0x2C72), + (0x2C75, 0x2C75), + (0x2C7E, 0x2C80), + (0x2C82, 0x2C82), + (0x2C84, 0x2C84), + (0x2C86, 0x2C86), + (0x2C88, 0x2C88), + (0x2C8A, 0x2C8A), + (0x2C8C, 0x2C8C), + (0x2C8E, 0x2C8E), + (0x2C90, 0x2C90), + (0x2C92, 0x2C92), + (0x2C94, 0x2C94), + (0x2C96, 0x2C96), + (0x2C98, 0x2C98), + (0x2C9A, 0x2C9A), + (0x2C9C, 0x2C9C), + (0x2C9E, 0x2C9E), + (0x2CA0, 0x2CA0), + (0x2CA2, 0x2CA2), + (0x2CA4, 0x2CA4), + (0x2CA6, 0x2CA6), + (0x2CA8, 0x2CA8), + (0x2CAA, 0x2CAA), + (0x2CAC, 0x2CAC), + (0x2CAE, 0x2CAE), + (0x2CB0, 0x2CB0), + (0x2CB2, 0x2CB2), + (0x2CB4, 0x2CB4), + (0x2CB6, 0x2CB6), + (0x2CB8, 0x2CB8), + (0x2CBA, 0x2CBA), + (0x2CBC, 0x2CBC), + (0x2CBE, 0x2CBE), + (0x2CC0, 0x2CC0), + (0x2CC2, 0x2CC2), + (0x2CC4, 0x2CC4), + (0x2CC6, 0x2CC6), + (0x2CC8, 0x2CC8), + (0x2CCA, 0x2CCA), + (0x2CCC, 0x2CCC), + (0x2CCE, 0x2CCE), + (0x2CD0, 0x2CD0), + (0x2CD2, 0x2CD2), + (0x2CD4, 0x2CD4), + (0x2CD6, 0x2CD6), + (0x2CD8, 0x2CD8), + (0x2CDA, 0x2CDA), + (0x2CDC, 0x2CDC), + (0x2CDE, 0x2CDE), + (0x2CE0, 0x2CE0), + (0x2CE2, 0x2CE2), + (0x2CEB, 0x2CEB), + (0x2CED, 0x2CED), + (0x2CF2, 0x2CF2), + (0xA640, 0xA640), + (0xA642, 0xA642), + (0xA644, 0xA644), + (0xA646, 0xA646), + (0xA648, 0xA648), + (0xA64A, 0xA64A), + (0xA64C, 0xA64C), + (0xA64E, 0xA64E), + (0xA650, 0xA650), + (0xA652, 0xA652), + (0xA654, 0xA654), + (0xA656, 0xA656), + (0xA658, 0xA658), + (0xA65A, 0xA65A), + (0xA65C, 0xA65C), + (0xA65E, 0xA65E), + (0xA660, 0xA660), + (0xA662, 0xA662), + (0xA664, 0xA664), + (0xA666, 0xA666), + (0xA668, 0xA668), + (0xA66A, 0xA66A), + (0xA66C, 0xA66C), + (0xA680, 0xA680), + (0xA682, 0xA682), + (0xA684, 0xA684), + (0xA686, 0xA686), + (0xA688, 0xA688), + (0xA68A, 0xA68A), + (0xA68C, 0xA68C), + (0xA68E, 0xA68E), + (0xA690, 0xA690), + (0xA692, 0xA692), + (0xA694, 0xA694), + (0xA696, 0xA696), + (0xA698, 0xA698), + (0xA69A, 0xA69A), + (0xA722, 0xA722), + (0xA724, 0xA724), + (0xA726, 0xA726), + (0xA728, 0xA728), + (0xA72A, 0xA72A), + (0xA72C, 0xA72C), + (0xA72E, 0xA72E), + (0xA732, 0xA732), + (0xA734, 0xA734), + (0xA736, 0xA736), + (0xA738, 0xA738), + (0xA73A, 0xA73A), + (0xA73C, 0xA73C), + (0xA73E, 0xA73E), + (0xA740, 0xA740), + (0xA742, 0xA742), + (0xA744, 0xA744), + (0xA746, 0xA746), + (0xA748, 0xA748), + (0xA74A, 0xA74A), + (0xA74C, 0xA74C), + (0xA74E, 0xA74E), + (0xA750, 0xA750), + (0xA752, 0xA752), + (0xA754, 0xA754), + (0xA756, 0xA756), + (0xA758, 0xA758), + (0xA75A, 0xA75A), + (0xA75C, 0xA75C), + (0xA75E, 0xA75E), + (0xA760, 0xA760), + (0xA762, 0xA762), + (0xA764, 0xA764), + (0xA766, 0xA766), + (0xA768, 0xA768), + (0xA76A, 0xA76A), + (0xA76C, 0xA76C), + (0xA76E, 0xA76E), + (0xA779, 0xA779), + (0xA77B, 0xA77B), + (0xA77D, 0xA77E), + (0xA780, 0xA780), + (0xA782, 0xA782), + (0xA784, 0xA784), + (0xA786, 0xA786), + (0xA78B, 0xA78B), + (0xA78D, 0xA78D), + (0xA790, 0xA790), + (0xA792, 0xA792), + (0xA796, 0xA796), + (0xA798, 0xA798), + (0xA79A, 0xA79A), + (0xA79C, 0xA79C), + (0xA79E, 0xA79E), + (0xA7A0, 0xA7A0), + (0xA7A2, 0xA7A2), + (0xA7A4, 0xA7A4), + (0xA7A6, 0xA7A6), + (0xA7A8, 0xA7A8), + (0xA7AA, 0xA7AE), + (0xA7B0, 0xA7B4), + (0xA7B6, 0xA7B6), + (0xA7B8, 0xA7B8), + (0xA7BA, 0xA7BA), + (0xA7BC, 0xA7BC), + (0xA7BE, 0xA7BE), + (0xA7C0, 0xA7C0), + (0xA7C2, 0xA7C2), + (0xA7C4, 0xA7C7), + (0xA7C9, 0xA7C9), + (0xA7CB, 0xA7CC), + (0xA7CE, 0xA7CE), + (0xA7D0, 0xA7D0), + (0xA7D2, 0xA7D2), + (0xA7D4, 0xA7D4), + (0xA7D6, 0xA7D6), + (0xA7D8, 0xA7D8), + (0xA7DA, 0xA7DA), + (0xA7DC, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F5, 0xA7F5), + (0xAB6C, 0xAB6D), + (0xAB70, 0xABBF), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFF21, 0xFF3A), + (0x10400, 0x10427), + (0x104B0, 0x104D3), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10C80, 0x10CB2), + (0x10D50, 0x10D65), + (0x118A0, 0x118BF), + (0x16E40, 0x16E5F), + (0x16EA0, 0x16EB8), + (0x1DF40, 0x1DF40), + (0x1DF48, 0x1DF48), + (0x1DF4A, 0x1DF4A), + (0x1DF4D, 0x1DF4D), + (0x1DF51, 0x1DF51), + (0x1DF68, 0x1DF68), + (0x1DF6A, 0x1DF6A), + (0x1DF6C, 0x1DF6C), + (0x1DF6E, 0x1DF6E), + (0x1DF72, 0x1DF72), + (0x1DF74, 0x1DF74), + (0x1DF76, 0x1DF76), + (0x1DF78, 0x1DF78), + (0x1DF7A, 0x1DF7A), + (0x1DF7C, 0x1DF7C), + (0x1DF7E, 0x1DF7E), + (0x1DF95, 0x1DF95), + (0x1E900, 0x1E921), +]; + +/// The code points with the binary property Changes_When_Casemapped, as ranges. +pub static BINARY_CHANGES_WHEN_CASEMAPPED: &[(u32, u32)] = &[ + (0x41, 0x5A), + (0x61, 0x7A), + (0xB5, 0xB5), + (0xC0, 0xD6), + (0xD8, 0xF6), + (0xF8, 0x137), + (0x139, 0x18C), + (0x18E, 0x1A9), + (0x1AC, 0x1B9), + (0x1BC, 0x1BD), + (0x1BF, 0x1BF), + (0x1C4, 0x220), + (0x222, 0x233), + (0x23A, 0x254), + (0x256, 0x257), + (0x259, 0x259), + (0x25B, 0x25C), + (0x260, 0x261), + (0x263, 0x266), + (0x268, 0x26C), + (0x26F, 0x26F), + (0x271, 0x272), + (0x275, 0x275), + (0x277, 0x277), + (0x27C, 0x27D), + (0x280, 0x280), + (0x282, 0x283), + (0x287, 0x28C), + (0x292, 0x292), + (0x29D, 0x29E), + (0x345, 0x345), + (0x370, 0x373), + (0x376, 0x377), + (0x37B, 0x37D), + (0x37F, 0x37F), + (0x386, 0x386), + (0x388, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x3A1), + (0x3A3, 0x3D1), + (0x3D5, 0x3F5), + (0x3F7, 0x3FB), + (0x3FD, 0x481), + (0x48A, 0x52F), + (0x531, 0x556), + (0x561, 0x587), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x10D0, 0x10FA), + (0x10FD, 0x10FF), + (0x13A0, 0x13F5), + (0x13F8, 0x13FD), + (0x1C80, 0x1C8A), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1D79, 0x1D79), + (0x1D7D, 0x1D7D), + (0x1D8E, 0x1D8E), + (0x1E00, 0x1E9B), + (0x1E9E, 0x1E9E), + (0x1EA0, 0x1F15), + (0x1F18, 0x1F1D), + (0x1F20, 0x1F45), + (0x1F48, 0x1F4D), + (0x1F50, 0x1F57), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F7D), + (0x1F80, 0x1FB4), + (0x1FB6, 0x1FBC), + (0x1FBE, 0x1FBE), + (0x1FC2, 0x1FC4), + (0x1FC6, 0x1FCC), + (0x1FD0, 0x1FD3), + (0x1FD6, 0x1FDB), + (0x1FE0, 0x1FEC), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FFC), + (0x2126, 0x2126), + (0x212A, 0x212B), + (0x2132, 0x2132), + (0x214E, 0x214E), + (0x2160, 0x217F), + (0x2183, 0x2184), + (0x24B6, 0x24E9), + (0x2C00, 0x2C70), + (0x2C72, 0x2C73), + (0x2C75, 0x2C76), + (0x2C7E, 0x2CE3), + (0x2CEB, 0x2CEE), + (0x2CF2, 0x2CF3), + (0x2D00, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0xA640, 0xA66D), + (0xA680, 0xA69B), + (0xA722, 0xA72F), + (0xA732, 0xA76F), + (0xA779, 0xA787), + (0xA78B, 0xA78D), + (0xA790, 0xA794), + (0xA796, 0xA7AE), + (0xA7B0, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F5, 0xA7F6), + (0xAB4B, 0xAB4C), + (0xAB53, 0xAB53), + (0xAB6C, 0xAB6D), + (0xAB70, 0xABBF), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFF21, 0xFF3A), + (0xFF41, 0xFF5A), + (0x10400, 0x1044F), + (0x104B0, 0x104D3), + (0x104D8, 0x104FB), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x10C80, 0x10CB2), + (0x10CC0, 0x10CF2), + (0x10D50, 0x10D65), + (0x10D70, 0x10D85), + (0x118A0, 0x118DF), + (0x16E40, 0x16E7F), + (0x16EA0, 0x16EB8), + (0x16EBB, 0x16ED3), + (0x1DF40, 0x1DF41), + (0x1DF48, 0x1DF4B), + (0x1DF4D, 0x1DF4E), + (0x1DF51, 0x1DF52), + (0x1DF68, 0x1DF6F), + (0x1DF72, 0x1DF7F), + (0x1DF95, 0x1DF95), + (0x1E900, 0x1E943), +]; + +/// The code points with the binary property Changes_When_Lowercased, as ranges. +pub static BINARY_CHANGES_WHEN_LOWERCASED: &[(u32, u32)] = &[ + (0x41, 0x5A), + (0xC0, 0xD6), + (0xD8, 0xDE), + (0x100, 0x100), + (0x102, 0x102), + (0x104, 0x104), + (0x106, 0x106), + (0x108, 0x108), + (0x10A, 0x10A), + (0x10C, 0x10C), + (0x10E, 0x10E), + (0x110, 0x110), + (0x112, 0x112), + (0x114, 0x114), + (0x116, 0x116), + (0x118, 0x118), + (0x11A, 0x11A), + (0x11C, 0x11C), + (0x11E, 0x11E), + (0x120, 0x120), + (0x122, 0x122), + (0x124, 0x124), + (0x126, 0x126), + (0x128, 0x128), + (0x12A, 0x12A), + (0x12C, 0x12C), + (0x12E, 0x12E), + (0x130, 0x130), + (0x132, 0x132), + (0x134, 0x134), + (0x136, 0x136), + (0x139, 0x139), + (0x13B, 0x13B), + (0x13D, 0x13D), + (0x13F, 0x13F), + (0x141, 0x141), + (0x143, 0x143), + (0x145, 0x145), + (0x147, 0x147), + (0x14A, 0x14A), + (0x14C, 0x14C), + (0x14E, 0x14E), + (0x150, 0x150), + (0x152, 0x152), + (0x154, 0x154), + (0x156, 0x156), + (0x158, 0x158), + (0x15A, 0x15A), + (0x15C, 0x15C), + (0x15E, 0x15E), + (0x160, 0x160), + (0x162, 0x162), + (0x164, 0x164), + (0x166, 0x166), + (0x168, 0x168), + (0x16A, 0x16A), + (0x16C, 0x16C), + (0x16E, 0x16E), + (0x170, 0x170), + (0x172, 0x172), + (0x174, 0x174), + (0x176, 0x176), + (0x178, 0x179), + (0x17B, 0x17B), + (0x17D, 0x17D), + (0x181, 0x182), + (0x184, 0x184), + (0x186, 0x187), + (0x189, 0x18B), + (0x18E, 0x191), + (0x193, 0x194), + (0x196, 0x198), + (0x19C, 0x19D), + (0x19F, 0x1A0), + (0x1A2, 0x1A2), + (0x1A4, 0x1A4), + (0x1A6, 0x1A7), + (0x1A9, 0x1A9), + (0x1AC, 0x1AC), + (0x1AE, 0x1AF), + (0x1B1, 0x1B3), + (0x1B5, 0x1B5), + (0x1B7, 0x1B8), + (0x1BC, 0x1BC), + (0x1C4, 0x1C5), + (0x1C7, 0x1C8), + (0x1CA, 0x1CB), + (0x1CD, 0x1CD), + (0x1CF, 0x1CF), + (0x1D1, 0x1D1), + (0x1D3, 0x1D3), + (0x1D5, 0x1D5), + (0x1D7, 0x1D7), + (0x1D9, 0x1D9), + (0x1DB, 0x1DB), + (0x1DE, 0x1DE), + (0x1E0, 0x1E0), + (0x1E2, 0x1E2), + (0x1E4, 0x1E4), + (0x1E6, 0x1E6), + (0x1E8, 0x1E8), + (0x1EA, 0x1EA), + (0x1EC, 0x1EC), + (0x1EE, 0x1EE), + (0x1F1, 0x1F2), + (0x1F4, 0x1F4), + (0x1F6, 0x1F8), + (0x1FA, 0x1FA), + (0x1FC, 0x1FC), + (0x1FE, 0x1FE), + (0x200, 0x200), + (0x202, 0x202), + (0x204, 0x204), + (0x206, 0x206), + (0x208, 0x208), + (0x20A, 0x20A), + (0x20C, 0x20C), + (0x20E, 0x20E), + (0x210, 0x210), + (0x212, 0x212), + (0x214, 0x214), + (0x216, 0x216), + (0x218, 0x218), + (0x21A, 0x21A), + (0x21C, 0x21C), + (0x21E, 0x21E), + (0x220, 0x220), + (0x222, 0x222), + (0x224, 0x224), + (0x226, 0x226), + (0x228, 0x228), + (0x22A, 0x22A), + (0x22C, 0x22C), + (0x22E, 0x22E), + (0x230, 0x230), + (0x232, 0x232), + (0x23A, 0x23B), + (0x23D, 0x23E), + (0x241, 0x241), + (0x243, 0x246), + (0x248, 0x248), + (0x24A, 0x24A), + (0x24C, 0x24C), + (0x24E, 0x24E), + (0x370, 0x370), + (0x372, 0x372), + (0x376, 0x376), + (0x37F, 0x37F), + (0x386, 0x386), + (0x388, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x38F), + (0x391, 0x3A1), + (0x3A3, 0x3AB), + (0x3CF, 0x3CF), + (0x3D8, 0x3D8), + (0x3DA, 0x3DA), + (0x3DC, 0x3DC), + (0x3DE, 0x3DE), + (0x3E0, 0x3E0), + (0x3E2, 0x3E2), + (0x3E4, 0x3E4), + (0x3E6, 0x3E6), + (0x3E8, 0x3E8), + (0x3EA, 0x3EA), + (0x3EC, 0x3EC), + (0x3EE, 0x3EE), + (0x3F4, 0x3F4), + (0x3F7, 0x3F7), + (0x3F9, 0x3FA), + (0x3FD, 0x42F), + (0x460, 0x460), + (0x462, 0x462), + (0x464, 0x464), + (0x466, 0x466), + (0x468, 0x468), + (0x46A, 0x46A), + (0x46C, 0x46C), + (0x46E, 0x46E), + (0x470, 0x470), + (0x472, 0x472), + (0x474, 0x474), + (0x476, 0x476), + (0x478, 0x478), + (0x47A, 0x47A), + (0x47C, 0x47C), + (0x47E, 0x47E), + (0x480, 0x480), + (0x48A, 0x48A), + (0x48C, 0x48C), + (0x48E, 0x48E), + (0x490, 0x490), + (0x492, 0x492), + (0x494, 0x494), + (0x496, 0x496), + (0x498, 0x498), + (0x49A, 0x49A), + (0x49C, 0x49C), + (0x49E, 0x49E), + (0x4A0, 0x4A0), + (0x4A2, 0x4A2), + (0x4A4, 0x4A4), + (0x4A6, 0x4A6), + (0x4A8, 0x4A8), + (0x4AA, 0x4AA), + (0x4AC, 0x4AC), + (0x4AE, 0x4AE), + (0x4B0, 0x4B0), + (0x4B2, 0x4B2), + (0x4B4, 0x4B4), + (0x4B6, 0x4B6), + (0x4B8, 0x4B8), + (0x4BA, 0x4BA), + (0x4BC, 0x4BC), + (0x4BE, 0x4BE), + (0x4C0, 0x4C1), + (0x4C3, 0x4C3), + (0x4C5, 0x4C5), + (0x4C7, 0x4C7), + (0x4C9, 0x4C9), + (0x4CB, 0x4CB), + (0x4CD, 0x4CD), + (0x4D0, 0x4D0), + (0x4D2, 0x4D2), + (0x4D4, 0x4D4), + (0x4D6, 0x4D6), + (0x4D8, 0x4D8), + (0x4DA, 0x4DA), + (0x4DC, 0x4DC), + (0x4DE, 0x4DE), + (0x4E0, 0x4E0), + (0x4E2, 0x4E2), + (0x4E4, 0x4E4), + (0x4E6, 0x4E6), + (0x4E8, 0x4E8), + (0x4EA, 0x4EA), + (0x4EC, 0x4EC), + (0x4EE, 0x4EE), + (0x4F0, 0x4F0), + (0x4F2, 0x4F2), + (0x4F4, 0x4F4), + (0x4F6, 0x4F6), + (0x4F8, 0x4F8), + (0x4FA, 0x4FA), + (0x4FC, 0x4FC), + (0x4FE, 0x4FE), + (0x500, 0x500), + (0x502, 0x502), + (0x504, 0x504), + (0x506, 0x506), + (0x508, 0x508), + (0x50A, 0x50A), + (0x50C, 0x50C), + (0x50E, 0x50E), + (0x510, 0x510), + (0x512, 0x512), + (0x514, 0x514), + (0x516, 0x516), + (0x518, 0x518), + (0x51A, 0x51A), + (0x51C, 0x51C), + (0x51E, 0x51E), + (0x520, 0x520), + (0x522, 0x522), + (0x524, 0x524), + (0x526, 0x526), + (0x528, 0x528), + (0x52A, 0x52A), + (0x52C, 0x52C), + (0x52E, 0x52E), + (0x531, 0x556), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x13A0, 0x13F5), + (0x1C89, 0x1C89), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1E00, 0x1E00), + (0x1E02, 0x1E02), + (0x1E04, 0x1E04), + (0x1E06, 0x1E06), + (0x1E08, 0x1E08), + (0x1E0A, 0x1E0A), + (0x1E0C, 0x1E0C), + (0x1E0E, 0x1E0E), + (0x1E10, 0x1E10), + (0x1E12, 0x1E12), + (0x1E14, 0x1E14), + (0x1E16, 0x1E16), + (0x1E18, 0x1E18), + (0x1E1A, 0x1E1A), + (0x1E1C, 0x1E1C), + (0x1E1E, 0x1E1E), + (0x1E20, 0x1E20), + (0x1E22, 0x1E22), + (0x1E24, 0x1E24), + (0x1E26, 0x1E26), + (0x1E28, 0x1E28), + (0x1E2A, 0x1E2A), + (0x1E2C, 0x1E2C), + (0x1E2E, 0x1E2E), + (0x1E30, 0x1E30), + (0x1E32, 0x1E32), + (0x1E34, 0x1E34), + (0x1E36, 0x1E36), + (0x1E38, 0x1E38), + (0x1E3A, 0x1E3A), + (0x1E3C, 0x1E3C), + (0x1E3E, 0x1E3E), + (0x1E40, 0x1E40), + (0x1E42, 0x1E42), + (0x1E44, 0x1E44), + (0x1E46, 0x1E46), + (0x1E48, 0x1E48), + (0x1E4A, 0x1E4A), + (0x1E4C, 0x1E4C), + (0x1E4E, 0x1E4E), + (0x1E50, 0x1E50), + (0x1E52, 0x1E52), + (0x1E54, 0x1E54), + (0x1E56, 0x1E56), + (0x1E58, 0x1E58), + (0x1E5A, 0x1E5A), + (0x1E5C, 0x1E5C), + (0x1E5E, 0x1E5E), + (0x1E60, 0x1E60), + (0x1E62, 0x1E62), + (0x1E64, 0x1E64), + (0x1E66, 0x1E66), + (0x1E68, 0x1E68), + (0x1E6A, 0x1E6A), + (0x1E6C, 0x1E6C), + (0x1E6E, 0x1E6E), + (0x1E70, 0x1E70), + (0x1E72, 0x1E72), + (0x1E74, 0x1E74), + (0x1E76, 0x1E76), + (0x1E78, 0x1E78), + (0x1E7A, 0x1E7A), + (0x1E7C, 0x1E7C), + (0x1E7E, 0x1E7E), + (0x1E80, 0x1E80), + (0x1E82, 0x1E82), + (0x1E84, 0x1E84), + (0x1E86, 0x1E86), + (0x1E88, 0x1E88), + (0x1E8A, 0x1E8A), + (0x1E8C, 0x1E8C), + (0x1E8E, 0x1E8E), + (0x1E90, 0x1E90), + (0x1E92, 0x1E92), + (0x1E94, 0x1E94), + (0x1E9E, 0x1E9E), + (0x1EA0, 0x1EA0), + (0x1EA2, 0x1EA2), + (0x1EA4, 0x1EA4), + (0x1EA6, 0x1EA6), + (0x1EA8, 0x1EA8), + (0x1EAA, 0x1EAA), + (0x1EAC, 0x1EAC), + (0x1EAE, 0x1EAE), + (0x1EB0, 0x1EB0), + (0x1EB2, 0x1EB2), + (0x1EB4, 0x1EB4), + (0x1EB6, 0x1EB6), + (0x1EB8, 0x1EB8), + (0x1EBA, 0x1EBA), + (0x1EBC, 0x1EBC), + (0x1EBE, 0x1EBE), + (0x1EC0, 0x1EC0), + (0x1EC2, 0x1EC2), + (0x1EC4, 0x1EC4), + (0x1EC6, 0x1EC6), + (0x1EC8, 0x1EC8), + (0x1ECA, 0x1ECA), + (0x1ECC, 0x1ECC), + (0x1ECE, 0x1ECE), + (0x1ED0, 0x1ED0), + (0x1ED2, 0x1ED2), + (0x1ED4, 0x1ED4), + (0x1ED6, 0x1ED6), + (0x1ED8, 0x1ED8), + (0x1EDA, 0x1EDA), + (0x1EDC, 0x1EDC), + (0x1EDE, 0x1EDE), + (0x1EE0, 0x1EE0), + (0x1EE2, 0x1EE2), + (0x1EE4, 0x1EE4), + (0x1EE6, 0x1EE6), + (0x1EE8, 0x1EE8), + (0x1EEA, 0x1EEA), + (0x1EEC, 0x1EEC), + (0x1EEE, 0x1EEE), + (0x1EF0, 0x1EF0), + (0x1EF2, 0x1EF2), + (0x1EF4, 0x1EF4), + (0x1EF6, 0x1EF6), + (0x1EF8, 0x1EF8), + (0x1EFA, 0x1EFA), + (0x1EFC, 0x1EFC), + (0x1EFE, 0x1EFE), + (0x1F08, 0x1F0F), + (0x1F18, 0x1F1D), + (0x1F28, 0x1F2F), + (0x1F38, 0x1F3F), + (0x1F48, 0x1F4D), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F5F), + (0x1F68, 0x1F6F), + (0x1F88, 0x1F8F), + (0x1F98, 0x1F9F), + (0x1FA8, 0x1FAF), + (0x1FB8, 0x1FBC), + (0x1FC8, 0x1FCC), + (0x1FD8, 0x1FDB), + (0x1FE8, 0x1FEC), + (0x1FF8, 0x1FFC), + (0x2126, 0x2126), + (0x212A, 0x212B), + (0x2132, 0x2132), + (0x2160, 0x216F), + (0x2183, 0x2183), + (0x24B6, 0x24CF), + (0x2C00, 0x2C2F), + (0x2C60, 0x2C60), + (0x2C62, 0x2C64), + (0x2C67, 0x2C67), + (0x2C69, 0x2C69), + (0x2C6B, 0x2C6B), + (0x2C6D, 0x2C70), + (0x2C72, 0x2C72), + (0x2C75, 0x2C75), + (0x2C7E, 0x2C80), + (0x2C82, 0x2C82), + (0x2C84, 0x2C84), + (0x2C86, 0x2C86), + (0x2C88, 0x2C88), + (0x2C8A, 0x2C8A), + (0x2C8C, 0x2C8C), + (0x2C8E, 0x2C8E), + (0x2C90, 0x2C90), + (0x2C92, 0x2C92), + (0x2C94, 0x2C94), + (0x2C96, 0x2C96), + (0x2C98, 0x2C98), + (0x2C9A, 0x2C9A), + (0x2C9C, 0x2C9C), + (0x2C9E, 0x2C9E), + (0x2CA0, 0x2CA0), + (0x2CA2, 0x2CA2), + (0x2CA4, 0x2CA4), + (0x2CA6, 0x2CA6), + (0x2CA8, 0x2CA8), + (0x2CAA, 0x2CAA), + (0x2CAC, 0x2CAC), + (0x2CAE, 0x2CAE), + (0x2CB0, 0x2CB0), + (0x2CB2, 0x2CB2), + (0x2CB4, 0x2CB4), + (0x2CB6, 0x2CB6), + (0x2CB8, 0x2CB8), + (0x2CBA, 0x2CBA), + (0x2CBC, 0x2CBC), + (0x2CBE, 0x2CBE), + (0x2CC0, 0x2CC0), + (0x2CC2, 0x2CC2), + (0x2CC4, 0x2CC4), + (0x2CC6, 0x2CC6), + (0x2CC8, 0x2CC8), + (0x2CCA, 0x2CCA), + (0x2CCC, 0x2CCC), + (0x2CCE, 0x2CCE), + (0x2CD0, 0x2CD0), + (0x2CD2, 0x2CD2), + (0x2CD4, 0x2CD4), + (0x2CD6, 0x2CD6), + (0x2CD8, 0x2CD8), + (0x2CDA, 0x2CDA), + (0x2CDC, 0x2CDC), + (0x2CDE, 0x2CDE), + (0x2CE0, 0x2CE0), + (0x2CE2, 0x2CE2), + (0x2CEB, 0x2CEB), + (0x2CED, 0x2CED), + (0x2CF2, 0x2CF2), + (0xA640, 0xA640), + (0xA642, 0xA642), + (0xA644, 0xA644), + (0xA646, 0xA646), + (0xA648, 0xA648), + (0xA64A, 0xA64A), + (0xA64C, 0xA64C), + (0xA64E, 0xA64E), + (0xA650, 0xA650), + (0xA652, 0xA652), + (0xA654, 0xA654), + (0xA656, 0xA656), + (0xA658, 0xA658), + (0xA65A, 0xA65A), + (0xA65C, 0xA65C), + (0xA65E, 0xA65E), + (0xA660, 0xA660), + (0xA662, 0xA662), + (0xA664, 0xA664), + (0xA666, 0xA666), + (0xA668, 0xA668), + (0xA66A, 0xA66A), + (0xA66C, 0xA66C), + (0xA680, 0xA680), + (0xA682, 0xA682), + (0xA684, 0xA684), + (0xA686, 0xA686), + (0xA688, 0xA688), + (0xA68A, 0xA68A), + (0xA68C, 0xA68C), + (0xA68E, 0xA68E), + (0xA690, 0xA690), + (0xA692, 0xA692), + (0xA694, 0xA694), + (0xA696, 0xA696), + (0xA698, 0xA698), + (0xA69A, 0xA69A), + (0xA722, 0xA722), + (0xA724, 0xA724), + (0xA726, 0xA726), + (0xA728, 0xA728), + (0xA72A, 0xA72A), + (0xA72C, 0xA72C), + (0xA72E, 0xA72E), + (0xA732, 0xA732), + (0xA734, 0xA734), + (0xA736, 0xA736), + (0xA738, 0xA738), + (0xA73A, 0xA73A), + (0xA73C, 0xA73C), + (0xA73E, 0xA73E), + (0xA740, 0xA740), + (0xA742, 0xA742), + (0xA744, 0xA744), + (0xA746, 0xA746), + (0xA748, 0xA748), + (0xA74A, 0xA74A), + (0xA74C, 0xA74C), + (0xA74E, 0xA74E), + (0xA750, 0xA750), + (0xA752, 0xA752), + (0xA754, 0xA754), + (0xA756, 0xA756), + (0xA758, 0xA758), + (0xA75A, 0xA75A), + (0xA75C, 0xA75C), + (0xA75E, 0xA75E), + (0xA760, 0xA760), + (0xA762, 0xA762), + (0xA764, 0xA764), + (0xA766, 0xA766), + (0xA768, 0xA768), + (0xA76A, 0xA76A), + (0xA76C, 0xA76C), + (0xA76E, 0xA76E), + (0xA779, 0xA779), + (0xA77B, 0xA77B), + (0xA77D, 0xA77E), + (0xA780, 0xA780), + (0xA782, 0xA782), + (0xA784, 0xA784), + (0xA786, 0xA786), + (0xA78B, 0xA78B), + (0xA78D, 0xA78D), + (0xA790, 0xA790), + (0xA792, 0xA792), + (0xA796, 0xA796), + (0xA798, 0xA798), + (0xA79A, 0xA79A), + (0xA79C, 0xA79C), + (0xA79E, 0xA79E), + (0xA7A0, 0xA7A0), + (0xA7A2, 0xA7A2), + (0xA7A4, 0xA7A4), + (0xA7A6, 0xA7A6), + (0xA7A8, 0xA7A8), + (0xA7AA, 0xA7AE), + (0xA7B0, 0xA7B4), + (0xA7B6, 0xA7B6), + (0xA7B8, 0xA7B8), + (0xA7BA, 0xA7BA), + (0xA7BC, 0xA7BC), + (0xA7BE, 0xA7BE), + (0xA7C0, 0xA7C0), + (0xA7C2, 0xA7C2), + (0xA7C4, 0xA7C7), + (0xA7C9, 0xA7C9), + (0xA7CB, 0xA7CC), + (0xA7CE, 0xA7CE), + (0xA7D0, 0xA7D0), + (0xA7D2, 0xA7D2), + (0xA7D4, 0xA7D4), + (0xA7D6, 0xA7D6), + (0xA7D8, 0xA7D8), + (0xA7DA, 0xA7DA), + (0xA7DC, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F5, 0xA7F5), + (0xAB6C, 0xAB6D), + (0xFF21, 0xFF3A), + (0x10400, 0x10427), + (0x104B0, 0x104D3), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10C80, 0x10CB2), + (0x10D50, 0x10D65), + (0x118A0, 0x118BF), + (0x16E40, 0x16E5F), + (0x16EA0, 0x16EB8), + (0x1DF40, 0x1DF40), + (0x1DF48, 0x1DF48), + (0x1DF4A, 0x1DF4A), + (0x1DF4D, 0x1DF4D), + (0x1DF51, 0x1DF51), + (0x1DF68, 0x1DF68), + (0x1DF6A, 0x1DF6A), + (0x1DF6C, 0x1DF6C), + (0x1DF6E, 0x1DF6E), + (0x1DF72, 0x1DF72), + (0x1DF74, 0x1DF74), + (0x1DF76, 0x1DF76), + (0x1DF78, 0x1DF78), + (0x1DF7A, 0x1DF7A), + (0x1DF7C, 0x1DF7C), + (0x1DF7E, 0x1DF7E), + (0x1E900, 0x1E921), +]; + +/// The code points with the binary property Changes_When_NFKC_Casefolded, as ranges. +pub static BINARY_CHANGES_WHEN_NFKC_CASEFOLDED: &[(u32, u32)] = &[ + (0x41, 0x5A), + (0xA0, 0xA0), + (0xA8, 0xA8), + (0xAA, 0xAA), + (0xAD, 0xAD), + (0xAF, 0xAF), + (0xB2, 0xB5), + (0xB8, 0xBA), + (0xBC, 0xBE), + (0xC0, 0xD6), + (0xD8, 0xDF), + (0x100, 0x100), + (0x102, 0x102), + (0x104, 0x104), + (0x106, 0x106), + (0x108, 0x108), + (0x10A, 0x10A), + (0x10C, 0x10C), + (0x10E, 0x10E), + (0x110, 0x110), + (0x112, 0x112), + (0x114, 0x114), + (0x116, 0x116), + (0x118, 0x118), + (0x11A, 0x11A), + (0x11C, 0x11C), + (0x11E, 0x11E), + (0x120, 0x120), + (0x122, 0x122), + (0x124, 0x124), + (0x126, 0x126), + (0x128, 0x128), + (0x12A, 0x12A), + (0x12C, 0x12C), + (0x12E, 0x12E), + (0x130, 0x130), + (0x132, 0x134), + (0x136, 0x136), + (0x139, 0x139), + (0x13B, 0x13B), + (0x13D, 0x13D), + (0x13F, 0x141), + (0x143, 0x143), + (0x145, 0x145), + (0x147, 0x147), + (0x149, 0x14A), + (0x14C, 0x14C), + (0x14E, 0x14E), + (0x150, 0x150), + (0x152, 0x152), + (0x154, 0x154), + (0x156, 0x156), + (0x158, 0x158), + (0x15A, 0x15A), + (0x15C, 0x15C), + (0x15E, 0x15E), + (0x160, 0x160), + (0x162, 0x162), + (0x164, 0x164), + (0x166, 0x166), + (0x168, 0x168), + (0x16A, 0x16A), + (0x16C, 0x16C), + (0x16E, 0x16E), + (0x170, 0x170), + (0x172, 0x172), + (0x174, 0x174), + (0x176, 0x176), + (0x178, 0x179), + (0x17B, 0x17B), + (0x17D, 0x17D), + (0x17F, 0x17F), + (0x181, 0x182), + (0x184, 0x184), + (0x186, 0x187), + (0x189, 0x18B), + (0x18E, 0x191), + (0x193, 0x194), + (0x196, 0x198), + (0x19C, 0x19D), + (0x19F, 0x1A0), + (0x1A2, 0x1A2), + (0x1A4, 0x1A4), + (0x1A6, 0x1A7), + (0x1A9, 0x1A9), + (0x1AC, 0x1AC), + (0x1AE, 0x1AF), + (0x1B1, 0x1B3), + (0x1B5, 0x1B5), + (0x1B7, 0x1B8), + (0x1BC, 0x1BC), + (0x1C4, 0x1CD), + (0x1CF, 0x1CF), + (0x1D1, 0x1D1), + (0x1D3, 0x1D3), + (0x1D5, 0x1D5), + (0x1D7, 0x1D7), + (0x1D9, 0x1D9), + (0x1DB, 0x1DB), + (0x1DE, 0x1DE), + (0x1E0, 0x1E0), + (0x1E2, 0x1E2), + (0x1E4, 0x1E4), + (0x1E6, 0x1E6), + (0x1E8, 0x1E8), + (0x1EA, 0x1EA), + (0x1EC, 0x1EC), + (0x1EE, 0x1EE), + (0x1F1, 0x1F4), + (0x1F6, 0x1F8), + (0x1FA, 0x1FA), + (0x1FC, 0x1FC), + (0x1FE, 0x1FE), + (0x200, 0x200), + (0x202, 0x202), + (0x204, 0x204), + (0x206, 0x206), + (0x208, 0x208), + (0x20A, 0x20A), + (0x20C, 0x20C), + (0x20E, 0x20E), + (0x210, 0x210), + (0x212, 0x212), + (0x214, 0x214), + (0x216, 0x216), + (0x218, 0x218), + (0x21A, 0x21A), + (0x21C, 0x21C), + (0x21E, 0x21E), + (0x220, 0x220), + (0x222, 0x222), + (0x224, 0x224), + (0x226, 0x226), + (0x228, 0x228), + (0x22A, 0x22A), + (0x22C, 0x22C), + (0x22E, 0x22E), + (0x230, 0x230), + (0x232, 0x232), + (0x23A, 0x23B), + (0x23D, 0x23E), + (0x241, 0x241), + (0x243, 0x246), + (0x248, 0x248), + (0x24A, 0x24A), + (0x24C, 0x24C), + (0x24E, 0x24E), + (0x2B0, 0x2B8), + (0x2D8, 0x2DD), + (0x2E0, 0x2E4), + (0x340, 0x341), + (0x343, 0x345), + (0x34F, 0x34F), + (0x370, 0x370), + (0x372, 0x372), + (0x374, 0x374), + (0x376, 0x376), + (0x37A, 0x37A), + (0x37E, 0x37F), + (0x384, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x38F), + (0x391, 0x3A1), + (0x3A3, 0x3AB), + (0x3C2, 0x3C2), + (0x3CF, 0x3D6), + (0x3D8, 0x3D8), + (0x3DA, 0x3DA), + (0x3DC, 0x3DC), + (0x3DE, 0x3DE), + (0x3E0, 0x3E0), + (0x3E2, 0x3E2), + (0x3E4, 0x3E4), + (0x3E6, 0x3E6), + (0x3E8, 0x3E8), + (0x3EA, 0x3EA), + (0x3EC, 0x3EC), + (0x3EE, 0x3EE), + (0x3F0, 0x3F2), + (0x3F4, 0x3F5), + (0x3F7, 0x3F7), + (0x3F9, 0x3FA), + (0x3FD, 0x42F), + (0x460, 0x460), + (0x462, 0x462), + (0x464, 0x464), + (0x466, 0x466), + (0x468, 0x468), + (0x46A, 0x46A), + (0x46C, 0x46C), + (0x46E, 0x46E), + (0x470, 0x470), + (0x472, 0x472), + (0x474, 0x474), + (0x476, 0x476), + (0x478, 0x478), + (0x47A, 0x47A), + (0x47C, 0x47C), + (0x47E, 0x47E), + (0x480, 0x480), + (0x48A, 0x48A), + (0x48C, 0x48C), + (0x48E, 0x48E), + (0x490, 0x490), + (0x492, 0x492), + (0x494, 0x494), + (0x496, 0x496), + (0x498, 0x498), + (0x49A, 0x49A), + (0x49C, 0x49C), + (0x49E, 0x49E), + (0x4A0, 0x4A0), + (0x4A2, 0x4A2), + (0x4A4, 0x4A4), + (0x4A6, 0x4A6), + (0x4A8, 0x4A8), + (0x4AA, 0x4AA), + (0x4AC, 0x4AC), + (0x4AE, 0x4AE), + (0x4B0, 0x4B0), + (0x4B2, 0x4B2), + (0x4B4, 0x4B4), + (0x4B6, 0x4B6), + (0x4B8, 0x4B8), + (0x4BA, 0x4BA), + (0x4BC, 0x4BC), + (0x4BE, 0x4BE), + (0x4C0, 0x4C1), + (0x4C3, 0x4C3), + (0x4C5, 0x4C5), + (0x4C7, 0x4C7), + (0x4C9, 0x4C9), + (0x4CB, 0x4CB), + (0x4CD, 0x4CD), + (0x4D0, 0x4D0), + (0x4D2, 0x4D2), + (0x4D4, 0x4D4), + (0x4D6, 0x4D6), + (0x4D8, 0x4D8), + (0x4DA, 0x4DA), + (0x4DC, 0x4DC), + (0x4DE, 0x4DE), + (0x4E0, 0x4E0), + (0x4E2, 0x4E2), + (0x4E4, 0x4E4), + (0x4E6, 0x4E6), + (0x4E8, 0x4E8), + (0x4EA, 0x4EA), + (0x4EC, 0x4EC), + (0x4EE, 0x4EE), + (0x4F0, 0x4F0), + (0x4F2, 0x4F2), + (0x4F4, 0x4F4), + (0x4F6, 0x4F6), + (0x4F8, 0x4F8), + (0x4FA, 0x4FA), + (0x4FC, 0x4FC), + (0x4FE, 0x4FE), + (0x500, 0x500), + (0x502, 0x502), + (0x504, 0x504), + (0x506, 0x506), + (0x508, 0x508), + (0x50A, 0x50A), + (0x50C, 0x50C), + (0x50E, 0x50E), + (0x510, 0x510), + (0x512, 0x512), + (0x514, 0x514), + (0x516, 0x516), + (0x518, 0x518), + (0x51A, 0x51A), + (0x51C, 0x51C), + (0x51E, 0x51E), + (0x520, 0x520), + (0x522, 0x522), + (0x524, 0x524), + (0x526, 0x526), + (0x528, 0x528), + (0x52A, 0x52A), + (0x52C, 0x52C), + (0x52E, 0x52E), + (0x531, 0x556), + (0x558, 0x558), + (0x587, 0x587), + (0x58B, 0x58C), + (0x61C, 0x61C), + (0x675, 0x678), + (0x958, 0x95F), + (0x9DC, 0x9DD), + (0x9DF, 0x9DF), + (0xA33, 0xA33), + (0xA36, 0xA36), + (0xA59, 0xA5B), + (0xA5E, 0xA5E), + (0xB5C, 0xB5D), + (0xE33, 0xE33), + (0xEB3, 0xEB3), + (0xEDC, 0xEDD), + (0xF0C, 0xF0C), + (0xF43, 0xF43), + (0xF4D, 0xF4D), + (0xF52, 0xF52), + (0xF57, 0xF57), + (0xF5C, 0xF5C), + (0xF69, 0xF69), + (0xF73, 0xF73), + (0xF75, 0xF79), + (0xF81, 0xF81), + (0xF93, 0xF93), + (0xF9D, 0xF9D), + (0xFA2, 0xFA2), + (0xFA7, 0xFA7), + (0xFAC, 0xFAC), + (0xFB9, 0xFB9), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x10FC, 0x10FC), + (0x115F, 0x1160), + (0x13F8, 0x13FD), + (0x17B4, 0x17B5), + (0x180B, 0x180F), + (0x1C80, 0x1C89), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1D2C, 0x1D2E), + (0x1D30, 0x1D3A), + (0x1D3C, 0x1D4D), + (0x1D4F, 0x1D6A), + (0x1D78, 0x1D78), + (0x1D9B, 0x1DBF), + (0x1E00, 0x1E00), + (0x1E02, 0x1E02), + (0x1E04, 0x1E04), + (0x1E06, 0x1E06), + (0x1E08, 0x1E08), + (0x1E0A, 0x1E0A), + (0x1E0C, 0x1E0C), + (0x1E0E, 0x1E0E), + (0x1E10, 0x1E10), + (0x1E12, 0x1E12), + (0x1E14, 0x1E14), + (0x1E16, 0x1E16), + (0x1E18, 0x1E18), + (0x1E1A, 0x1E1A), + (0x1E1C, 0x1E1C), + (0x1E1E, 0x1E1E), + (0x1E20, 0x1E20), + (0x1E22, 0x1E22), + (0x1E24, 0x1E24), + (0x1E26, 0x1E26), + (0x1E28, 0x1E28), + (0x1E2A, 0x1E2A), + (0x1E2C, 0x1E2C), + (0x1E2E, 0x1E2E), + (0x1E30, 0x1E30), + (0x1E32, 0x1E32), + (0x1E34, 0x1E34), + (0x1E36, 0x1E36), + (0x1E38, 0x1E38), + (0x1E3A, 0x1E3A), + (0x1E3C, 0x1E3C), + (0x1E3E, 0x1E3E), + (0x1E40, 0x1E40), + (0x1E42, 0x1E42), + (0x1E44, 0x1E44), + (0x1E46, 0x1E46), + (0x1E48, 0x1E48), + (0x1E4A, 0x1E4A), + (0x1E4C, 0x1E4C), + (0x1E4E, 0x1E4E), + (0x1E50, 0x1E50), + (0x1E52, 0x1E52), + (0x1E54, 0x1E54), + (0x1E56, 0x1E56), + (0x1E58, 0x1E58), + (0x1E5A, 0x1E5A), + (0x1E5C, 0x1E5C), + (0x1E5E, 0x1E5E), + (0x1E60, 0x1E60), + (0x1E62, 0x1E62), + (0x1E64, 0x1E64), + (0x1E66, 0x1E66), + (0x1E68, 0x1E68), + (0x1E6A, 0x1E6A), + (0x1E6C, 0x1E6C), + (0x1E6E, 0x1E6E), + (0x1E70, 0x1E70), + (0x1E72, 0x1E72), + (0x1E74, 0x1E74), + (0x1E76, 0x1E76), + (0x1E78, 0x1E78), + (0x1E7A, 0x1E7A), + (0x1E7C, 0x1E7C), + (0x1E7E, 0x1E7E), + (0x1E80, 0x1E80), + (0x1E82, 0x1E82), + (0x1E84, 0x1E84), + (0x1E86, 0x1E86), + (0x1E88, 0x1E88), + (0x1E8A, 0x1E8A), + (0x1E8C, 0x1E8C), + (0x1E8E, 0x1E8E), + (0x1E90, 0x1E90), + (0x1E92, 0x1E92), + (0x1E94, 0x1E94), + (0x1E9A, 0x1E9B), + (0x1E9E, 0x1E9E), + (0x1EA0, 0x1EA0), + (0x1EA2, 0x1EA2), + (0x1EA4, 0x1EA4), + (0x1EA6, 0x1EA6), + (0x1EA8, 0x1EA8), + (0x1EAA, 0x1EAA), + (0x1EAC, 0x1EAC), + (0x1EAE, 0x1EAE), + (0x1EB0, 0x1EB0), + (0x1EB2, 0x1EB2), + (0x1EB4, 0x1EB4), + (0x1EB6, 0x1EB6), + (0x1EB8, 0x1EB8), + (0x1EBA, 0x1EBA), + (0x1EBC, 0x1EBC), + (0x1EBE, 0x1EBE), + (0x1EC0, 0x1EC0), + (0x1EC2, 0x1EC2), + (0x1EC4, 0x1EC4), + (0x1EC6, 0x1EC6), + (0x1EC8, 0x1EC8), + (0x1ECA, 0x1ECA), + (0x1ECC, 0x1ECC), + (0x1ECE, 0x1ECE), + (0x1ED0, 0x1ED0), + (0x1ED2, 0x1ED2), + (0x1ED4, 0x1ED4), + (0x1ED6, 0x1ED6), + (0x1ED8, 0x1ED8), + (0x1EDA, 0x1EDA), + (0x1EDC, 0x1EDC), + (0x1EDE, 0x1EDE), + (0x1EE0, 0x1EE0), + (0x1EE2, 0x1EE2), + (0x1EE4, 0x1EE4), + (0x1EE6, 0x1EE6), + (0x1EE8, 0x1EE8), + (0x1EEA, 0x1EEA), + (0x1EEC, 0x1EEC), + (0x1EEE, 0x1EEE), + (0x1EF0, 0x1EF0), + (0x1EF2, 0x1EF2), + (0x1EF4, 0x1EF4), + (0x1EF6, 0x1EF6), + (0x1EF8, 0x1EF8), + (0x1EFA, 0x1EFA), + (0x1EFC, 0x1EFC), + (0x1EFE, 0x1EFE), + (0x1F08, 0x1F0F), + (0x1F18, 0x1F1D), + (0x1F28, 0x1F2F), + (0x1F38, 0x1F3F), + (0x1F48, 0x1F4D), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F5F), + (0x1F68, 0x1F6F), + (0x1F71, 0x1F71), + (0x1F73, 0x1F73), + (0x1F75, 0x1F75), + (0x1F77, 0x1F77), + (0x1F79, 0x1F79), + (0x1F7B, 0x1F7B), + (0x1F7D, 0x1F7D), + (0x1F80, 0x1FAF), + (0x1FB2, 0x1FB4), + (0x1FB7, 0x1FC4), + (0x1FC7, 0x1FCF), + (0x1FD3, 0x1FD3), + (0x1FD8, 0x1FDB), + (0x1FDD, 0x1FDF), + (0x1FE3, 0x1FE3), + (0x1FE8, 0x1FEF), + (0x1FF2, 0x1FF4), + (0x1FF7, 0x1FFE), + (0x2000, 0x200F), + (0x2011, 0x2011), + (0x2017, 0x2017), + (0x2024, 0x2026), + (0x202A, 0x202F), + (0x2033, 0x2034), + (0x2036, 0x2037), + (0x203C, 0x203C), + (0x203E, 0x203E), + (0x2047, 0x2049), + (0x2057, 0x2057), + (0x205F, 0x2071), + (0x2074, 0x208E), + (0x2090, 0x209F), + (0x20A8, 0x20A8), + (0x2100, 0x2103), + (0x2105, 0x2107), + (0x2109, 0x2113), + (0x2115, 0x2116), + (0x2119, 0x211D), + (0x2120, 0x2122), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212A, 0x212D), + (0x212F, 0x2139), + (0x213B, 0x2140), + (0x2145, 0x2149), + (0x2150, 0x217F), + (0x2183, 0x2183), + (0x2189, 0x2189), + (0x222C, 0x222D), + (0x222F, 0x2230), + (0x2329, 0x232A), + (0x2460, 0x24EA), + (0x2A0C, 0x2A0C), + (0x2A74, 0x2A76), + (0x2ADC, 0x2ADC), + (0x2C00, 0x2C2F), + (0x2C60, 0x2C60), + (0x2C62, 0x2C64), + (0x2C67, 0x2C67), + (0x2C69, 0x2C69), + (0x2C6B, 0x2C6B), + (0x2C6D, 0x2C70), + (0x2C72, 0x2C72), + (0x2C75, 0x2C75), + (0x2C7C, 0x2C80), + (0x2C82, 0x2C82), + (0x2C84, 0x2C84), + (0x2C86, 0x2C86), + (0x2C88, 0x2C88), + (0x2C8A, 0x2C8A), + (0x2C8C, 0x2C8C), + (0x2C8E, 0x2C8E), + (0x2C90, 0x2C90), + (0x2C92, 0x2C92), + (0x2C94, 0x2C94), + (0x2C96, 0x2C96), + (0x2C98, 0x2C98), + (0x2C9A, 0x2C9A), + (0x2C9C, 0x2C9C), + (0x2C9E, 0x2C9E), + (0x2CA0, 0x2CA0), + (0x2CA2, 0x2CA2), + (0x2CA4, 0x2CA4), + (0x2CA6, 0x2CA6), + (0x2CA8, 0x2CA8), + (0x2CAA, 0x2CAA), + (0x2CAC, 0x2CAC), + (0x2CAE, 0x2CAE), + (0x2CB0, 0x2CB0), + (0x2CB2, 0x2CB2), + (0x2CB4, 0x2CB4), + (0x2CB6, 0x2CB6), + (0x2CB8, 0x2CB8), + (0x2CBA, 0x2CBA), + (0x2CBC, 0x2CBC), + (0x2CBE, 0x2CBE), + (0x2CC0, 0x2CC0), + (0x2CC2, 0x2CC2), + (0x2CC4, 0x2CC4), + (0x2CC6, 0x2CC6), + (0x2CC8, 0x2CC8), + (0x2CCA, 0x2CCA), + (0x2CCC, 0x2CCC), + (0x2CCE, 0x2CCE), + (0x2CD0, 0x2CD0), + (0x2CD2, 0x2CD2), + (0x2CD4, 0x2CD4), + (0x2CD6, 0x2CD6), + (0x2CD8, 0x2CD8), + (0x2CDA, 0x2CDA), + (0x2CDC, 0x2CDC), + (0x2CDE, 0x2CDE), + (0x2CE0, 0x2CE0), + (0x2CE2, 0x2CE2), + (0x2CEB, 0x2CEB), + (0x2CED, 0x2CED), + (0x2CF2, 0x2CF2), + (0x2D6F, 0x2D6F), + (0x2E9F, 0x2E9F), + (0x2EF3, 0x2EF3), + (0x2F00, 0x2FD5), + (0x3000, 0x3000), + (0x3036, 0x3036), + (0x3038, 0x303A), + (0x309B, 0x309C), + (0x309F, 0x309F), + (0x30FF, 0x30FF), + (0x3131, 0x318E), + (0x3192, 0x319F), + (0x3200, 0x321E), + (0x3220, 0x3247), + (0x3250, 0x327E), + (0x3280, 0x33FF), + (0xA640, 0xA640), + (0xA642, 0xA642), + (0xA644, 0xA644), + (0xA646, 0xA646), + (0xA648, 0xA648), + (0xA64A, 0xA64A), + (0xA64C, 0xA64C), + (0xA64E, 0xA64E), + (0xA650, 0xA650), + (0xA652, 0xA652), + (0xA654, 0xA654), + (0xA656, 0xA656), + (0xA658, 0xA658), + (0xA65A, 0xA65A), + (0xA65C, 0xA65C), + (0xA65E, 0xA65E), + (0xA660, 0xA660), + (0xA662, 0xA662), + (0xA664, 0xA664), + (0xA666, 0xA666), + (0xA668, 0xA668), + (0xA66A, 0xA66A), + (0xA66C, 0xA66C), + (0xA680, 0xA680), + (0xA682, 0xA682), + (0xA684, 0xA684), + (0xA686, 0xA686), + (0xA688, 0xA688), + (0xA68A, 0xA68A), + (0xA68C, 0xA68C), + (0xA68E, 0xA68E), + (0xA690, 0xA690), + (0xA692, 0xA692), + (0xA694, 0xA694), + (0xA696, 0xA696), + (0xA698, 0xA698), + (0xA69A, 0xA69A), + (0xA69C, 0xA69D), + (0xA722, 0xA722), + (0xA724, 0xA724), + (0xA726, 0xA726), + (0xA728, 0xA728), + (0xA72A, 0xA72A), + (0xA72C, 0xA72C), + (0xA72E, 0xA72E), + (0xA732, 0xA732), + (0xA734, 0xA734), + (0xA736, 0xA736), + (0xA738, 0xA738), + (0xA73A, 0xA73A), + (0xA73C, 0xA73C), + (0xA73E, 0xA73E), + (0xA740, 0xA740), + (0xA742, 0xA742), + (0xA744, 0xA744), + (0xA746, 0xA746), + (0xA748, 0xA748), + (0xA74A, 0xA74A), + (0xA74C, 0xA74C), + (0xA74E, 0xA74E), + (0xA750, 0xA750), + (0xA752, 0xA752), + (0xA754, 0xA754), + (0xA756, 0xA756), + (0xA758, 0xA758), + (0xA75A, 0xA75A), + (0xA75C, 0xA75C), + (0xA75E, 0xA75E), + (0xA760, 0xA760), + (0xA762, 0xA762), + (0xA764, 0xA764), + (0xA766, 0xA766), + (0xA768, 0xA768), + (0xA76A, 0xA76A), + (0xA76C, 0xA76C), + (0xA76E, 0xA76E), + (0xA770, 0xA770), + (0xA779, 0xA779), + (0xA77B, 0xA77B), + (0xA77D, 0xA77E), + (0xA780, 0xA780), + (0xA782, 0xA782), + (0xA784, 0xA784), + (0xA786, 0xA786), + (0xA78B, 0xA78B), + (0xA78D, 0xA78D), + (0xA790, 0xA790), + (0xA792, 0xA792), + (0xA796, 0xA796), + (0xA798, 0xA798), + (0xA79A, 0xA79A), + (0xA79C, 0xA79C), + (0xA79E, 0xA79E), + (0xA7A0, 0xA7A0), + (0xA7A2, 0xA7A2), + (0xA7A4, 0xA7A4), + (0xA7A6, 0xA7A6), + (0xA7A8, 0xA7A8), + (0xA7AA, 0xA7AE), + (0xA7B0, 0xA7B4), + (0xA7B6, 0xA7B6), + (0xA7B8, 0xA7B8), + (0xA7BA, 0xA7BA), + (0xA7BC, 0xA7BC), + (0xA7BE, 0xA7BE), + (0xA7C0, 0xA7C0), + (0xA7C2, 0xA7C2), + (0xA7C4, 0xA7C7), + (0xA7C9, 0xA7C9), + (0xA7CB, 0xA7CC), + (0xA7CE, 0xA7CE), + (0xA7D0, 0xA7D0), + (0xA7D2, 0xA7D2), + (0xA7D4, 0xA7D4), + (0xA7D6, 0xA7D6), + (0xA7D8, 0xA7D8), + (0xA7DA, 0xA7DA), + (0xA7DC, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F1, 0xA7F5), + (0xA7F8, 0xA7F9), + (0xAB5C, 0xAB5F), + (0xAB69, 0xAB69), + (0xAB6C, 0xAB6D), + (0xAB70, 0xABBF), + (0xF900, 0xFA0D), + (0xFA10, 0xFA10), + (0xFA12, 0xFA12), + (0xFA15, 0xFA1E), + (0xFA20, 0xFA20), + (0xFA22, 0xFA22), + (0xFA25, 0xFA26), + (0xFA2A, 0xFA6D), + (0xFA70, 0xFAD9), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFB1D, 0xFB1D), + (0xFB1F, 0xFB36), + (0xFB38, 0xFB3C), + (0xFB3E, 0xFB3E), + (0xFB40, 0xFB41), + (0xFB43, 0xFB44), + (0xFB46, 0xFBB1), + (0xFBD3, 0xFD3D), + (0xFD50, 0xFD8F), + (0xFD92, 0xFDC7), + (0xFDF0, 0xFDFC), + (0xFE00, 0xFE19), + (0xFE30, 0xFE44), + (0xFE47, 0xFE52), + (0xFE54, 0xFE66), + (0xFE68, 0xFE6B), + (0xFE70, 0xFE72), + (0xFE74, 0xFE74), + (0xFE76, 0xFEFC), + (0xFEFF, 0xFEFF), + (0xFF01, 0xFFBE), + (0xFFC2, 0xFFC7), + (0xFFCA, 0xFFCF), + (0xFFD2, 0xFFD7), + (0xFFDA, 0xFFDC), + (0xFFE0, 0xFFE6), + (0xFFE8, 0xFFEE), + (0xFFF0, 0xFFF8), + (0x10400, 0x10427), + (0x104B0, 0x104D3), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10781, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BF), + (0x10C80, 0x10CB2), + (0x10D50, 0x10D65), + (0x118A0, 0x118BF), + (0x16E40, 0x16E5F), + (0x16EA0, 0x16EB8), + (0x1B123, 0x1B126), + (0x1BCA0, 0x1BCA3), + (0x1CCD6, 0x1CCF9), + (0x1D15E, 0x1D164), + (0x1D173, 0x1D17A), + (0x1D1BB, 0x1D1C0), + (0x1D400, 0x1D454), + (0x1D456, 0x1D49C), + (0x1D49E, 0x1D49F), + (0x1D4A2, 0x1D4A2), + (0x1D4A5, 0x1D4A6), + (0x1D4A9, 0x1D4AC), + (0x1D4AE, 0x1D4B9), + (0x1D4BB, 0x1D4BB), + (0x1D4BD, 0x1D4C3), + (0x1D4C5, 0x1D505), + (0x1D507, 0x1D50A), + (0x1D50D, 0x1D514), + (0x1D516, 0x1D51C), + (0x1D51E, 0x1D539), + (0x1D53B, 0x1D53E), + (0x1D540, 0x1D544), + (0x1D546, 0x1D546), + (0x1D54A, 0x1D550), + (0x1D552, 0x1D6A6), + (0x1D6A8, 0x1D7CB), + (0x1D7CE, 0x1D7FF), + (0x1DF40, 0x1DF40), + (0x1DF48, 0x1DF48), + (0x1DF4A, 0x1DF4A), + (0x1DF4D, 0x1DF4D), + (0x1DF51, 0x1DF51), + (0x1DF68, 0x1DF68), + (0x1DF6A, 0x1DF6A), + (0x1DF6C, 0x1DF6C), + (0x1DF6E, 0x1DF6E), + (0x1DF72, 0x1DF72), + (0x1DF74, 0x1DF74), + (0x1DF76, 0x1DF76), + (0x1DF78, 0x1DF78), + (0x1DF7A, 0x1DF7A), + (0x1DF7C, 0x1DF7C), + (0x1DF7E, 0x1DF7E), + (0x1DF95, 0x1DF95), + (0x1DFCD, 0x1DFFF), + (0x1E030, 0x1E06D), + (0x1E900, 0x1E921), + (0x1EE00, 0x1EE03), + (0x1EE05, 0x1EE1F), + (0x1EE21, 0x1EE22), + (0x1EE24, 0x1EE24), + (0x1EE27, 0x1EE27), + (0x1EE29, 0x1EE32), + (0x1EE34, 0x1EE37), + (0x1EE39, 0x1EE39), + (0x1EE3B, 0x1EE3B), + (0x1EE42, 0x1EE42), + (0x1EE47, 0x1EE47), + (0x1EE49, 0x1EE49), + (0x1EE4B, 0x1EE4B), + (0x1EE4D, 0x1EE4F), + (0x1EE51, 0x1EE52), + (0x1EE54, 0x1EE54), + (0x1EE57, 0x1EE57), + (0x1EE59, 0x1EE59), + (0x1EE5B, 0x1EE5B), + (0x1EE5D, 0x1EE5D), + (0x1EE5F, 0x1EE5F), + (0x1EE61, 0x1EE62), + (0x1EE64, 0x1EE64), + (0x1EE67, 0x1EE6A), + (0x1EE6C, 0x1EE72), + (0x1EE74, 0x1EE77), + (0x1EE79, 0x1EE7C), + (0x1EE7E, 0x1EE7E), + (0x1EE80, 0x1EE89), + (0x1EE8B, 0x1EE9B), + (0x1EEA1, 0x1EEA3), + (0x1EEA5, 0x1EEA9), + (0x1EEAB, 0x1EEBB), + (0x1F100, 0x1F10A), + (0x1F110, 0x1F12E), + (0x1F130, 0x1F14F), + (0x1F16A, 0x1F16C), + (0x1F190, 0x1F190), + (0x1F200, 0x1F202), + (0x1F210, 0x1F23B), + (0x1F240, 0x1F248), + (0x1F250, 0x1F251), + (0x1FBF0, 0x1FBF9), + (0x2F800, 0x2FA1D), + (0xE0000, 0xE0FFF), +]; + +/// The code points with the binary property Changes_When_Titlecased, as ranges. +pub static BINARY_CHANGES_WHEN_TITLECASED: &[(u32, u32)] = &[ + (0x61, 0x7A), + (0xB5, 0xB5), + (0xDF, 0xF6), + (0xF8, 0xFF), + (0x101, 0x101), + (0x103, 0x103), + (0x105, 0x105), + (0x107, 0x107), + (0x109, 0x109), + (0x10B, 0x10B), + (0x10D, 0x10D), + (0x10F, 0x10F), + (0x111, 0x111), + (0x113, 0x113), + (0x115, 0x115), + (0x117, 0x117), + (0x119, 0x119), + (0x11B, 0x11B), + (0x11D, 0x11D), + (0x11F, 0x11F), + (0x121, 0x121), + (0x123, 0x123), + (0x125, 0x125), + (0x127, 0x127), + (0x129, 0x129), + (0x12B, 0x12B), + (0x12D, 0x12D), + (0x12F, 0x12F), + (0x131, 0x131), + (0x133, 0x133), + (0x135, 0x135), + (0x137, 0x137), + (0x13A, 0x13A), + (0x13C, 0x13C), + (0x13E, 0x13E), + (0x140, 0x140), + (0x142, 0x142), + (0x144, 0x144), + (0x146, 0x146), + (0x148, 0x149), + (0x14B, 0x14B), + (0x14D, 0x14D), + (0x14F, 0x14F), + (0x151, 0x151), + (0x153, 0x153), + (0x155, 0x155), + (0x157, 0x157), + (0x159, 0x159), + (0x15B, 0x15B), + (0x15D, 0x15D), + (0x15F, 0x15F), + (0x161, 0x161), + (0x163, 0x163), + (0x165, 0x165), + (0x167, 0x167), + (0x169, 0x169), + (0x16B, 0x16B), + (0x16D, 0x16D), + (0x16F, 0x16F), + (0x171, 0x171), + (0x173, 0x173), + (0x175, 0x175), + (0x177, 0x177), + (0x17A, 0x17A), + (0x17C, 0x17C), + (0x17E, 0x180), + (0x183, 0x183), + (0x185, 0x185), + (0x188, 0x188), + (0x18C, 0x18C), + (0x192, 0x192), + (0x195, 0x195), + (0x199, 0x19B), + (0x19E, 0x19E), + (0x1A1, 0x1A1), + (0x1A3, 0x1A3), + (0x1A5, 0x1A5), + (0x1A8, 0x1A8), + (0x1AD, 0x1AD), + (0x1B0, 0x1B0), + (0x1B4, 0x1B4), + (0x1B6, 0x1B6), + (0x1B9, 0x1B9), + (0x1BD, 0x1BD), + (0x1BF, 0x1BF), + (0x1C4, 0x1C4), + (0x1C6, 0x1C7), + (0x1C9, 0x1CA), + (0x1CC, 0x1CC), + (0x1CE, 0x1CE), + (0x1D0, 0x1D0), + (0x1D2, 0x1D2), + (0x1D4, 0x1D4), + (0x1D6, 0x1D6), + (0x1D8, 0x1D8), + (0x1DA, 0x1DA), + (0x1DC, 0x1DD), + (0x1DF, 0x1DF), + (0x1E1, 0x1E1), + (0x1E3, 0x1E3), + (0x1E5, 0x1E5), + (0x1E7, 0x1E7), + (0x1E9, 0x1E9), + (0x1EB, 0x1EB), + (0x1ED, 0x1ED), + (0x1EF, 0x1F1), + (0x1F3, 0x1F3), + (0x1F5, 0x1F5), + (0x1F9, 0x1F9), + (0x1FB, 0x1FB), + (0x1FD, 0x1FD), + (0x1FF, 0x1FF), + (0x201, 0x201), + (0x203, 0x203), + (0x205, 0x205), + (0x207, 0x207), + (0x209, 0x209), + (0x20B, 0x20B), + (0x20D, 0x20D), + (0x20F, 0x20F), + (0x211, 0x211), + (0x213, 0x213), + (0x215, 0x215), + (0x217, 0x217), + (0x219, 0x219), + (0x21B, 0x21B), + (0x21D, 0x21D), + (0x21F, 0x21F), + (0x223, 0x223), + (0x225, 0x225), + (0x227, 0x227), + (0x229, 0x229), + (0x22B, 0x22B), + (0x22D, 0x22D), + (0x22F, 0x22F), + (0x231, 0x231), + (0x233, 0x233), + (0x23C, 0x23C), + (0x23F, 0x240), + (0x242, 0x242), + (0x247, 0x247), + (0x249, 0x249), + (0x24B, 0x24B), + (0x24D, 0x24D), + (0x24F, 0x254), + (0x256, 0x257), + (0x259, 0x259), + (0x25B, 0x25C), + (0x260, 0x261), + (0x263, 0x266), + (0x268, 0x26C), + (0x26F, 0x26F), + (0x271, 0x272), + (0x275, 0x275), + (0x277, 0x277), + (0x27C, 0x27D), + (0x280, 0x280), + (0x282, 0x283), + (0x287, 0x28C), + (0x292, 0x292), + (0x29D, 0x29E), + (0x345, 0x345), + (0x371, 0x371), + (0x373, 0x373), + (0x377, 0x377), + (0x37B, 0x37D), + (0x390, 0x390), + (0x3AC, 0x3CE), + (0x3D0, 0x3D1), + (0x3D5, 0x3D7), + (0x3D9, 0x3D9), + (0x3DB, 0x3DB), + (0x3DD, 0x3DD), + (0x3DF, 0x3DF), + (0x3E1, 0x3E1), + (0x3E3, 0x3E3), + (0x3E5, 0x3E5), + (0x3E7, 0x3E7), + (0x3E9, 0x3E9), + (0x3EB, 0x3EB), + (0x3ED, 0x3ED), + (0x3EF, 0x3F3), + (0x3F5, 0x3F5), + (0x3F8, 0x3F8), + (0x3FB, 0x3FB), + (0x430, 0x45F), + (0x461, 0x461), + (0x463, 0x463), + (0x465, 0x465), + (0x467, 0x467), + (0x469, 0x469), + (0x46B, 0x46B), + (0x46D, 0x46D), + (0x46F, 0x46F), + (0x471, 0x471), + (0x473, 0x473), + (0x475, 0x475), + (0x477, 0x477), + (0x479, 0x479), + (0x47B, 0x47B), + (0x47D, 0x47D), + (0x47F, 0x47F), + (0x481, 0x481), + (0x48B, 0x48B), + (0x48D, 0x48D), + (0x48F, 0x48F), + (0x491, 0x491), + (0x493, 0x493), + (0x495, 0x495), + (0x497, 0x497), + (0x499, 0x499), + (0x49B, 0x49B), + (0x49D, 0x49D), + (0x49F, 0x49F), + (0x4A1, 0x4A1), + (0x4A3, 0x4A3), + (0x4A5, 0x4A5), + (0x4A7, 0x4A7), + (0x4A9, 0x4A9), + (0x4AB, 0x4AB), + (0x4AD, 0x4AD), + (0x4AF, 0x4AF), + (0x4B1, 0x4B1), + (0x4B3, 0x4B3), + (0x4B5, 0x4B5), + (0x4B7, 0x4B7), + (0x4B9, 0x4B9), + (0x4BB, 0x4BB), + (0x4BD, 0x4BD), + (0x4BF, 0x4BF), + (0x4C2, 0x4C2), + (0x4C4, 0x4C4), + (0x4C6, 0x4C6), + (0x4C8, 0x4C8), + (0x4CA, 0x4CA), + (0x4CC, 0x4CC), + (0x4CE, 0x4CF), + (0x4D1, 0x4D1), + (0x4D3, 0x4D3), + (0x4D5, 0x4D5), + (0x4D7, 0x4D7), + (0x4D9, 0x4D9), + (0x4DB, 0x4DB), + (0x4DD, 0x4DD), + (0x4DF, 0x4DF), + (0x4E1, 0x4E1), + (0x4E3, 0x4E3), + (0x4E5, 0x4E5), + (0x4E7, 0x4E7), + (0x4E9, 0x4E9), + (0x4EB, 0x4EB), + (0x4ED, 0x4ED), + (0x4EF, 0x4EF), + (0x4F1, 0x4F1), + (0x4F3, 0x4F3), + (0x4F5, 0x4F5), + (0x4F7, 0x4F7), + (0x4F9, 0x4F9), + (0x4FB, 0x4FB), + (0x4FD, 0x4FD), + (0x4FF, 0x4FF), + (0x501, 0x501), + (0x503, 0x503), + (0x505, 0x505), + (0x507, 0x507), + (0x509, 0x509), + (0x50B, 0x50B), + (0x50D, 0x50D), + (0x50F, 0x50F), + (0x511, 0x511), + (0x513, 0x513), + (0x515, 0x515), + (0x517, 0x517), + (0x519, 0x519), + (0x51B, 0x51B), + (0x51D, 0x51D), + (0x51F, 0x51F), + (0x521, 0x521), + (0x523, 0x523), + (0x525, 0x525), + (0x527, 0x527), + (0x529, 0x529), + (0x52B, 0x52B), + (0x52D, 0x52D), + (0x52F, 0x52F), + (0x561, 0x587), + (0x13F8, 0x13FD), + (0x1C80, 0x1C88), + (0x1C8A, 0x1C8A), + (0x1D79, 0x1D79), + (0x1D7D, 0x1D7D), + (0x1D8E, 0x1D8E), + (0x1E01, 0x1E01), + (0x1E03, 0x1E03), + (0x1E05, 0x1E05), + (0x1E07, 0x1E07), + (0x1E09, 0x1E09), + (0x1E0B, 0x1E0B), + (0x1E0D, 0x1E0D), + (0x1E0F, 0x1E0F), + (0x1E11, 0x1E11), + (0x1E13, 0x1E13), + (0x1E15, 0x1E15), + (0x1E17, 0x1E17), + (0x1E19, 0x1E19), + (0x1E1B, 0x1E1B), + (0x1E1D, 0x1E1D), + (0x1E1F, 0x1E1F), + (0x1E21, 0x1E21), + (0x1E23, 0x1E23), + (0x1E25, 0x1E25), + (0x1E27, 0x1E27), + (0x1E29, 0x1E29), + (0x1E2B, 0x1E2B), + (0x1E2D, 0x1E2D), + (0x1E2F, 0x1E2F), + (0x1E31, 0x1E31), + (0x1E33, 0x1E33), + (0x1E35, 0x1E35), + (0x1E37, 0x1E37), + (0x1E39, 0x1E39), + (0x1E3B, 0x1E3B), + (0x1E3D, 0x1E3D), + (0x1E3F, 0x1E3F), + (0x1E41, 0x1E41), + (0x1E43, 0x1E43), + (0x1E45, 0x1E45), + (0x1E47, 0x1E47), + (0x1E49, 0x1E49), + (0x1E4B, 0x1E4B), + (0x1E4D, 0x1E4D), + (0x1E4F, 0x1E4F), + (0x1E51, 0x1E51), + (0x1E53, 0x1E53), + (0x1E55, 0x1E55), + (0x1E57, 0x1E57), + (0x1E59, 0x1E59), + (0x1E5B, 0x1E5B), + (0x1E5D, 0x1E5D), + (0x1E5F, 0x1E5F), + (0x1E61, 0x1E61), + (0x1E63, 0x1E63), + (0x1E65, 0x1E65), + (0x1E67, 0x1E67), + (0x1E69, 0x1E69), + (0x1E6B, 0x1E6B), + (0x1E6D, 0x1E6D), + (0x1E6F, 0x1E6F), + (0x1E71, 0x1E71), + (0x1E73, 0x1E73), + (0x1E75, 0x1E75), + (0x1E77, 0x1E77), + (0x1E79, 0x1E79), + (0x1E7B, 0x1E7B), + (0x1E7D, 0x1E7D), + (0x1E7F, 0x1E7F), + (0x1E81, 0x1E81), + (0x1E83, 0x1E83), + (0x1E85, 0x1E85), + (0x1E87, 0x1E87), + (0x1E89, 0x1E89), + (0x1E8B, 0x1E8B), + (0x1E8D, 0x1E8D), + (0x1E8F, 0x1E8F), + (0x1E91, 0x1E91), + (0x1E93, 0x1E93), + (0x1E95, 0x1E9B), + (0x1EA1, 0x1EA1), + (0x1EA3, 0x1EA3), + (0x1EA5, 0x1EA5), + (0x1EA7, 0x1EA7), + (0x1EA9, 0x1EA9), + (0x1EAB, 0x1EAB), + (0x1EAD, 0x1EAD), + (0x1EAF, 0x1EAF), + (0x1EB1, 0x1EB1), + (0x1EB3, 0x1EB3), + (0x1EB5, 0x1EB5), + (0x1EB7, 0x1EB7), + (0x1EB9, 0x1EB9), + (0x1EBB, 0x1EBB), + (0x1EBD, 0x1EBD), + (0x1EBF, 0x1EBF), + (0x1EC1, 0x1EC1), + (0x1EC3, 0x1EC3), + (0x1EC5, 0x1EC5), + (0x1EC7, 0x1EC7), + (0x1EC9, 0x1EC9), + (0x1ECB, 0x1ECB), + (0x1ECD, 0x1ECD), + (0x1ECF, 0x1ECF), + (0x1ED1, 0x1ED1), + (0x1ED3, 0x1ED3), + (0x1ED5, 0x1ED5), + (0x1ED7, 0x1ED7), + (0x1ED9, 0x1ED9), + (0x1EDB, 0x1EDB), + (0x1EDD, 0x1EDD), + (0x1EDF, 0x1EDF), + (0x1EE1, 0x1EE1), + (0x1EE3, 0x1EE3), + (0x1EE5, 0x1EE5), + (0x1EE7, 0x1EE7), + (0x1EE9, 0x1EE9), + (0x1EEB, 0x1EEB), + (0x1EED, 0x1EED), + (0x1EEF, 0x1EEF), + (0x1EF1, 0x1EF1), + (0x1EF3, 0x1EF3), + (0x1EF5, 0x1EF5), + (0x1EF7, 0x1EF7), + (0x1EF9, 0x1EF9), + (0x1EFB, 0x1EFB), + (0x1EFD, 0x1EFD), + (0x1EFF, 0x1F07), + (0x1F10, 0x1F15), + (0x1F20, 0x1F27), + (0x1F30, 0x1F37), + (0x1F40, 0x1F45), + (0x1F50, 0x1F57), + (0x1F60, 0x1F67), + (0x1F70, 0x1F7D), + (0x1F80, 0x1F87), + (0x1F90, 0x1F97), + (0x1FA0, 0x1FA7), + (0x1FB0, 0x1FB4), + (0x1FB6, 0x1FB7), + (0x1FBE, 0x1FBE), + (0x1FC2, 0x1FC4), + (0x1FC6, 0x1FC7), + (0x1FD0, 0x1FD3), + (0x1FD6, 0x1FD7), + (0x1FE0, 0x1FE7), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FF7), + (0x214E, 0x214E), + (0x2170, 0x217F), + (0x2184, 0x2184), + (0x24D0, 0x24E9), + (0x2C30, 0x2C5F), + (0x2C61, 0x2C61), + (0x2C65, 0x2C66), + (0x2C68, 0x2C68), + (0x2C6A, 0x2C6A), + (0x2C6C, 0x2C6C), + (0x2C73, 0x2C73), + (0x2C76, 0x2C76), + (0x2C81, 0x2C81), + (0x2C83, 0x2C83), + (0x2C85, 0x2C85), + (0x2C87, 0x2C87), + (0x2C89, 0x2C89), + (0x2C8B, 0x2C8B), + (0x2C8D, 0x2C8D), + (0x2C8F, 0x2C8F), + (0x2C91, 0x2C91), + (0x2C93, 0x2C93), + (0x2C95, 0x2C95), + (0x2C97, 0x2C97), + (0x2C99, 0x2C99), + (0x2C9B, 0x2C9B), + (0x2C9D, 0x2C9D), + (0x2C9F, 0x2C9F), + (0x2CA1, 0x2CA1), + (0x2CA3, 0x2CA3), + (0x2CA5, 0x2CA5), + (0x2CA7, 0x2CA7), + (0x2CA9, 0x2CA9), + (0x2CAB, 0x2CAB), + (0x2CAD, 0x2CAD), + (0x2CAF, 0x2CAF), + (0x2CB1, 0x2CB1), + (0x2CB3, 0x2CB3), + (0x2CB5, 0x2CB5), + (0x2CB7, 0x2CB7), + (0x2CB9, 0x2CB9), + (0x2CBB, 0x2CBB), + (0x2CBD, 0x2CBD), + (0x2CBF, 0x2CBF), + (0x2CC1, 0x2CC1), + (0x2CC3, 0x2CC3), + (0x2CC5, 0x2CC5), + (0x2CC7, 0x2CC7), + (0x2CC9, 0x2CC9), + (0x2CCB, 0x2CCB), + (0x2CCD, 0x2CCD), + (0x2CCF, 0x2CCF), + (0x2CD1, 0x2CD1), + (0x2CD3, 0x2CD3), + (0x2CD5, 0x2CD5), + (0x2CD7, 0x2CD7), + (0x2CD9, 0x2CD9), + (0x2CDB, 0x2CDB), + (0x2CDD, 0x2CDD), + (0x2CDF, 0x2CDF), + (0x2CE1, 0x2CE1), + (0x2CE3, 0x2CE3), + (0x2CEC, 0x2CEC), + (0x2CEE, 0x2CEE), + (0x2CF3, 0x2CF3), + (0x2D00, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0xA641, 0xA641), + (0xA643, 0xA643), + (0xA645, 0xA645), + (0xA647, 0xA647), + (0xA649, 0xA649), + (0xA64B, 0xA64B), + (0xA64D, 0xA64D), + (0xA64F, 0xA64F), + (0xA651, 0xA651), + (0xA653, 0xA653), + (0xA655, 0xA655), + (0xA657, 0xA657), + (0xA659, 0xA659), + (0xA65B, 0xA65B), + (0xA65D, 0xA65D), + (0xA65F, 0xA65F), + (0xA661, 0xA661), + (0xA663, 0xA663), + (0xA665, 0xA665), + (0xA667, 0xA667), + (0xA669, 0xA669), + (0xA66B, 0xA66B), + (0xA66D, 0xA66D), + (0xA681, 0xA681), + (0xA683, 0xA683), + (0xA685, 0xA685), + (0xA687, 0xA687), + (0xA689, 0xA689), + (0xA68B, 0xA68B), + (0xA68D, 0xA68D), + (0xA68F, 0xA68F), + (0xA691, 0xA691), + (0xA693, 0xA693), + (0xA695, 0xA695), + (0xA697, 0xA697), + (0xA699, 0xA699), + (0xA69B, 0xA69B), + (0xA723, 0xA723), + (0xA725, 0xA725), + (0xA727, 0xA727), + (0xA729, 0xA729), + (0xA72B, 0xA72B), + (0xA72D, 0xA72D), + (0xA72F, 0xA72F), + (0xA733, 0xA733), + (0xA735, 0xA735), + (0xA737, 0xA737), + (0xA739, 0xA739), + (0xA73B, 0xA73B), + (0xA73D, 0xA73D), + (0xA73F, 0xA73F), + (0xA741, 0xA741), + (0xA743, 0xA743), + (0xA745, 0xA745), + (0xA747, 0xA747), + (0xA749, 0xA749), + (0xA74B, 0xA74B), + (0xA74D, 0xA74D), + (0xA74F, 0xA74F), + (0xA751, 0xA751), + (0xA753, 0xA753), + (0xA755, 0xA755), + (0xA757, 0xA757), + (0xA759, 0xA759), + (0xA75B, 0xA75B), + (0xA75D, 0xA75D), + (0xA75F, 0xA75F), + (0xA761, 0xA761), + (0xA763, 0xA763), + (0xA765, 0xA765), + (0xA767, 0xA767), + (0xA769, 0xA769), + (0xA76B, 0xA76B), + (0xA76D, 0xA76D), + (0xA76F, 0xA76F), + (0xA77A, 0xA77A), + (0xA77C, 0xA77C), + (0xA77F, 0xA77F), + (0xA781, 0xA781), + (0xA783, 0xA783), + (0xA785, 0xA785), + (0xA787, 0xA787), + (0xA78C, 0xA78C), + (0xA791, 0xA791), + (0xA793, 0xA794), + (0xA797, 0xA797), + (0xA799, 0xA799), + (0xA79B, 0xA79B), + (0xA79D, 0xA79D), + (0xA79F, 0xA79F), + (0xA7A1, 0xA7A1), + (0xA7A3, 0xA7A3), + (0xA7A5, 0xA7A5), + (0xA7A7, 0xA7A7), + (0xA7A9, 0xA7A9), + (0xA7B5, 0xA7B5), + (0xA7B7, 0xA7B7), + (0xA7B9, 0xA7B9), + (0xA7BB, 0xA7BB), + (0xA7BD, 0xA7BD), + (0xA7BF, 0xA7BF), + (0xA7C1, 0xA7C1), + (0xA7C3, 0xA7C3), + (0xA7C8, 0xA7C8), + (0xA7CA, 0xA7CA), + (0xA7CD, 0xA7CD), + (0xA7CF, 0xA7CF), + (0xA7D1, 0xA7D1), + (0xA7D3, 0xA7D3), + (0xA7D5, 0xA7D5), + (0xA7D7, 0xA7D7), + (0xA7D9, 0xA7D9), + (0xA7DB, 0xA7DB), + (0xA7F6, 0xA7F6), + (0xAB4B, 0xAB4C), + (0xAB53, 0xAB53), + (0xAB70, 0xABBF), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFF41, 0xFF5A), + (0x10428, 0x1044F), + (0x104D8, 0x104FB), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x10CC0, 0x10CF2), + (0x10D70, 0x10D85), + (0x118C0, 0x118DF), + (0x16E60, 0x16E7F), + (0x16EBB, 0x16ED3), + (0x1DF41, 0x1DF41), + (0x1DF49, 0x1DF49), + (0x1DF4B, 0x1DF4B), + (0x1DF4E, 0x1DF4E), + (0x1DF52, 0x1DF52), + (0x1DF69, 0x1DF69), + (0x1DF6B, 0x1DF6B), + (0x1DF6D, 0x1DF6D), + (0x1DF6F, 0x1DF6F), + (0x1DF73, 0x1DF73), + (0x1DF75, 0x1DF75), + (0x1DF77, 0x1DF77), + (0x1DF79, 0x1DF79), + (0x1DF7B, 0x1DF7B), + (0x1DF7D, 0x1DF7D), + (0x1DF7F, 0x1DF7F), + (0x1DF95, 0x1DF95), + (0x1E922, 0x1E943), +]; + +/// The code points with the binary property Changes_When_Uppercased, as ranges. +pub static BINARY_CHANGES_WHEN_UPPERCASED: &[(u32, u32)] = &[ + (0x61, 0x7A), + (0xB5, 0xB5), + (0xDF, 0xF6), + (0xF8, 0xFF), + (0x101, 0x101), + (0x103, 0x103), + (0x105, 0x105), + (0x107, 0x107), + (0x109, 0x109), + (0x10B, 0x10B), + (0x10D, 0x10D), + (0x10F, 0x10F), + (0x111, 0x111), + (0x113, 0x113), + (0x115, 0x115), + (0x117, 0x117), + (0x119, 0x119), + (0x11B, 0x11B), + (0x11D, 0x11D), + (0x11F, 0x11F), + (0x121, 0x121), + (0x123, 0x123), + (0x125, 0x125), + (0x127, 0x127), + (0x129, 0x129), + (0x12B, 0x12B), + (0x12D, 0x12D), + (0x12F, 0x12F), + (0x131, 0x131), + (0x133, 0x133), + (0x135, 0x135), + (0x137, 0x137), + (0x13A, 0x13A), + (0x13C, 0x13C), + (0x13E, 0x13E), + (0x140, 0x140), + (0x142, 0x142), + (0x144, 0x144), + (0x146, 0x146), + (0x148, 0x149), + (0x14B, 0x14B), + (0x14D, 0x14D), + (0x14F, 0x14F), + (0x151, 0x151), + (0x153, 0x153), + (0x155, 0x155), + (0x157, 0x157), + (0x159, 0x159), + (0x15B, 0x15B), + (0x15D, 0x15D), + (0x15F, 0x15F), + (0x161, 0x161), + (0x163, 0x163), + (0x165, 0x165), + (0x167, 0x167), + (0x169, 0x169), + (0x16B, 0x16B), + (0x16D, 0x16D), + (0x16F, 0x16F), + (0x171, 0x171), + (0x173, 0x173), + (0x175, 0x175), + (0x177, 0x177), + (0x17A, 0x17A), + (0x17C, 0x17C), + (0x17E, 0x180), + (0x183, 0x183), + (0x185, 0x185), + (0x188, 0x188), + (0x18C, 0x18C), + (0x192, 0x192), + (0x195, 0x195), + (0x199, 0x19B), + (0x19E, 0x19E), + (0x1A1, 0x1A1), + (0x1A3, 0x1A3), + (0x1A5, 0x1A5), + (0x1A8, 0x1A8), + (0x1AD, 0x1AD), + (0x1B0, 0x1B0), + (0x1B4, 0x1B4), + (0x1B6, 0x1B6), + (0x1B9, 0x1B9), + (0x1BD, 0x1BD), + (0x1BF, 0x1BF), + (0x1C5, 0x1C6), + (0x1C8, 0x1C9), + (0x1CB, 0x1CC), + (0x1CE, 0x1CE), + (0x1D0, 0x1D0), + (0x1D2, 0x1D2), + (0x1D4, 0x1D4), + (0x1D6, 0x1D6), + (0x1D8, 0x1D8), + (0x1DA, 0x1DA), + (0x1DC, 0x1DD), + (0x1DF, 0x1DF), + (0x1E1, 0x1E1), + (0x1E3, 0x1E3), + (0x1E5, 0x1E5), + (0x1E7, 0x1E7), + (0x1E9, 0x1E9), + (0x1EB, 0x1EB), + (0x1ED, 0x1ED), + (0x1EF, 0x1F0), + (0x1F2, 0x1F3), + (0x1F5, 0x1F5), + (0x1F9, 0x1F9), + (0x1FB, 0x1FB), + (0x1FD, 0x1FD), + (0x1FF, 0x1FF), + (0x201, 0x201), + (0x203, 0x203), + (0x205, 0x205), + (0x207, 0x207), + (0x209, 0x209), + (0x20B, 0x20B), + (0x20D, 0x20D), + (0x20F, 0x20F), + (0x211, 0x211), + (0x213, 0x213), + (0x215, 0x215), + (0x217, 0x217), + (0x219, 0x219), + (0x21B, 0x21B), + (0x21D, 0x21D), + (0x21F, 0x21F), + (0x223, 0x223), + (0x225, 0x225), + (0x227, 0x227), + (0x229, 0x229), + (0x22B, 0x22B), + (0x22D, 0x22D), + (0x22F, 0x22F), + (0x231, 0x231), + (0x233, 0x233), + (0x23C, 0x23C), + (0x23F, 0x240), + (0x242, 0x242), + (0x247, 0x247), + (0x249, 0x249), + (0x24B, 0x24B), + (0x24D, 0x24D), + (0x24F, 0x254), + (0x256, 0x257), + (0x259, 0x259), + (0x25B, 0x25C), + (0x260, 0x261), + (0x263, 0x266), + (0x268, 0x26C), + (0x26F, 0x26F), + (0x271, 0x272), + (0x275, 0x275), + (0x277, 0x277), + (0x27C, 0x27D), + (0x280, 0x280), + (0x282, 0x283), + (0x287, 0x28C), + (0x292, 0x292), + (0x29D, 0x29E), + (0x345, 0x345), + (0x371, 0x371), + (0x373, 0x373), + (0x377, 0x377), + (0x37B, 0x37D), + (0x390, 0x390), + (0x3AC, 0x3CE), + (0x3D0, 0x3D1), + (0x3D5, 0x3D7), + (0x3D9, 0x3D9), + (0x3DB, 0x3DB), + (0x3DD, 0x3DD), + (0x3DF, 0x3DF), + (0x3E1, 0x3E1), + (0x3E3, 0x3E3), + (0x3E5, 0x3E5), + (0x3E7, 0x3E7), + (0x3E9, 0x3E9), + (0x3EB, 0x3EB), + (0x3ED, 0x3ED), + (0x3EF, 0x3F3), + (0x3F5, 0x3F5), + (0x3F8, 0x3F8), + (0x3FB, 0x3FB), + (0x430, 0x45F), + (0x461, 0x461), + (0x463, 0x463), + (0x465, 0x465), + (0x467, 0x467), + (0x469, 0x469), + (0x46B, 0x46B), + (0x46D, 0x46D), + (0x46F, 0x46F), + (0x471, 0x471), + (0x473, 0x473), + (0x475, 0x475), + (0x477, 0x477), + (0x479, 0x479), + (0x47B, 0x47B), + (0x47D, 0x47D), + (0x47F, 0x47F), + (0x481, 0x481), + (0x48B, 0x48B), + (0x48D, 0x48D), + (0x48F, 0x48F), + (0x491, 0x491), + (0x493, 0x493), + (0x495, 0x495), + (0x497, 0x497), + (0x499, 0x499), + (0x49B, 0x49B), + (0x49D, 0x49D), + (0x49F, 0x49F), + (0x4A1, 0x4A1), + (0x4A3, 0x4A3), + (0x4A5, 0x4A5), + (0x4A7, 0x4A7), + (0x4A9, 0x4A9), + (0x4AB, 0x4AB), + (0x4AD, 0x4AD), + (0x4AF, 0x4AF), + (0x4B1, 0x4B1), + (0x4B3, 0x4B3), + (0x4B5, 0x4B5), + (0x4B7, 0x4B7), + (0x4B9, 0x4B9), + (0x4BB, 0x4BB), + (0x4BD, 0x4BD), + (0x4BF, 0x4BF), + (0x4C2, 0x4C2), + (0x4C4, 0x4C4), + (0x4C6, 0x4C6), + (0x4C8, 0x4C8), + (0x4CA, 0x4CA), + (0x4CC, 0x4CC), + (0x4CE, 0x4CF), + (0x4D1, 0x4D1), + (0x4D3, 0x4D3), + (0x4D5, 0x4D5), + (0x4D7, 0x4D7), + (0x4D9, 0x4D9), + (0x4DB, 0x4DB), + (0x4DD, 0x4DD), + (0x4DF, 0x4DF), + (0x4E1, 0x4E1), + (0x4E3, 0x4E3), + (0x4E5, 0x4E5), + (0x4E7, 0x4E7), + (0x4E9, 0x4E9), + (0x4EB, 0x4EB), + (0x4ED, 0x4ED), + (0x4EF, 0x4EF), + (0x4F1, 0x4F1), + (0x4F3, 0x4F3), + (0x4F5, 0x4F5), + (0x4F7, 0x4F7), + (0x4F9, 0x4F9), + (0x4FB, 0x4FB), + (0x4FD, 0x4FD), + (0x4FF, 0x4FF), + (0x501, 0x501), + (0x503, 0x503), + (0x505, 0x505), + (0x507, 0x507), + (0x509, 0x509), + (0x50B, 0x50B), + (0x50D, 0x50D), + (0x50F, 0x50F), + (0x511, 0x511), + (0x513, 0x513), + (0x515, 0x515), + (0x517, 0x517), + (0x519, 0x519), + (0x51B, 0x51B), + (0x51D, 0x51D), + (0x51F, 0x51F), + (0x521, 0x521), + (0x523, 0x523), + (0x525, 0x525), + (0x527, 0x527), + (0x529, 0x529), + (0x52B, 0x52B), + (0x52D, 0x52D), + (0x52F, 0x52F), + (0x561, 0x587), + (0x10D0, 0x10FA), + (0x10FD, 0x10FF), + (0x13F8, 0x13FD), + (0x1C80, 0x1C88), + (0x1C8A, 0x1C8A), + (0x1D79, 0x1D79), + (0x1D7D, 0x1D7D), + (0x1D8E, 0x1D8E), + (0x1E01, 0x1E01), + (0x1E03, 0x1E03), + (0x1E05, 0x1E05), + (0x1E07, 0x1E07), + (0x1E09, 0x1E09), + (0x1E0B, 0x1E0B), + (0x1E0D, 0x1E0D), + (0x1E0F, 0x1E0F), + (0x1E11, 0x1E11), + (0x1E13, 0x1E13), + (0x1E15, 0x1E15), + (0x1E17, 0x1E17), + (0x1E19, 0x1E19), + (0x1E1B, 0x1E1B), + (0x1E1D, 0x1E1D), + (0x1E1F, 0x1E1F), + (0x1E21, 0x1E21), + (0x1E23, 0x1E23), + (0x1E25, 0x1E25), + (0x1E27, 0x1E27), + (0x1E29, 0x1E29), + (0x1E2B, 0x1E2B), + (0x1E2D, 0x1E2D), + (0x1E2F, 0x1E2F), + (0x1E31, 0x1E31), + (0x1E33, 0x1E33), + (0x1E35, 0x1E35), + (0x1E37, 0x1E37), + (0x1E39, 0x1E39), + (0x1E3B, 0x1E3B), + (0x1E3D, 0x1E3D), + (0x1E3F, 0x1E3F), + (0x1E41, 0x1E41), + (0x1E43, 0x1E43), + (0x1E45, 0x1E45), + (0x1E47, 0x1E47), + (0x1E49, 0x1E49), + (0x1E4B, 0x1E4B), + (0x1E4D, 0x1E4D), + (0x1E4F, 0x1E4F), + (0x1E51, 0x1E51), + (0x1E53, 0x1E53), + (0x1E55, 0x1E55), + (0x1E57, 0x1E57), + (0x1E59, 0x1E59), + (0x1E5B, 0x1E5B), + (0x1E5D, 0x1E5D), + (0x1E5F, 0x1E5F), + (0x1E61, 0x1E61), + (0x1E63, 0x1E63), + (0x1E65, 0x1E65), + (0x1E67, 0x1E67), + (0x1E69, 0x1E69), + (0x1E6B, 0x1E6B), + (0x1E6D, 0x1E6D), + (0x1E6F, 0x1E6F), + (0x1E71, 0x1E71), + (0x1E73, 0x1E73), + (0x1E75, 0x1E75), + (0x1E77, 0x1E77), + (0x1E79, 0x1E79), + (0x1E7B, 0x1E7B), + (0x1E7D, 0x1E7D), + (0x1E7F, 0x1E7F), + (0x1E81, 0x1E81), + (0x1E83, 0x1E83), + (0x1E85, 0x1E85), + (0x1E87, 0x1E87), + (0x1E89, 0x1E89), + (0x1E8B, 0x1E8B), + (0x1E8D, 0x1E8D), + (0x1E8F, 0x1E8F), + (0x1E91, 0x1E91), + (0x1E93, 0x1E93), + (0x1E95, 0x1E9B), + (0x1EA1, 0x1EA1), + (0x1EA3, 0x1EA3), + (0x1EA5, 0x1EA5), + (0x1EA7, 0x1EA7), + (0x1EA9, 0x1EA9), + (0x1EAB, 0x1EAB), + (0x1EAD, 0x1EAD), + (0x1EAF, 0x1EAF), + (0x1EB1, 0x1EB1), + (0x1EB3, 0x1EB3), + (0x1EB5, 0x1EB5), + (0x1EB7, 0x1EB7), + (0x1EB9, 0x1EB9), + (0x1EBB, 0x1EBB), + (0x1EBD, 0x1EBD), + (0x1EBF, 0x1EBF), + (0x1EC1, 0x1EC1), + (0x1EC3, 0x1EC3), + (0x1EC5, 0x1EC5), + (0x1EC7, 0x1EC7), + (0x1EC9, 0x1EC9), + (0x1ECB, 0x1ECB), + (0x1ECD, 0x1ECD), + (0x1ECF, 0x1ECF), + (0x1ED1, 0x1ED1), + (0x1ED3, 0x1ED3), + (0x1ED5, 0x1ED5), + (0x1ED7, 0x1ED7), + (0x1ED9, 0x1ED9), + (0x1EDB, 0x1EDB), + (0x1EDD, 0x1EDD), + (0x1EDF, 0x1EDF), + (0x1EE1, 0x1EE1), + (0x1EE3, 0x1EE3), + (0x1EE5, 0x1EE5), + (0x1EE7, 0x1EE7), + (0x1EE9, 0x1EE9), + (0x1EEB, 0x1EEB), + (0x1EED, 0x1EED), + (0x1EEF, 0x1EEF), + (0x1EF1, 0x1EF1), + (0x1EF3, 0x1EF3), + (0x1EF5, 0x1EF5), + (0x1EF7, 0x1EF7), + (0x1EF9, 0x1EF9), + (0x1EFB, 0x1EFB), + (0x1EFD, 0x1EFD), + (0x1EFF, 0x1F07), + (0x1F10, 0x1F15), + (0x1F20, 0x1F27), + (0x1F30, 0x1F37), + (0x1F40, 0x1F45), + (0x1F50, 0x1F57), + (0x1F60, 0x1F67), + (0x1F70, 0x1F7D), + (0x1F80, 0x1FB4), + (0x1FB6, 0x1FB7), + (0x1FBC, 0x1FBC), + (0x1FBE, 0x1FBE), + (0x1FC2, 0x1FC4), + (0x1FC6, 0x1FC7), + (0x1FCC, 0x1FCC), + (0x1FD0, 0x1FD3), + (0x1FD6, 0x1FD7), + (0x1FE0, 0x1FE7), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FF7), + (0x1FFC, 0x1FFC), + (0x214E, 0x214E), + (0x2170, 0x217F), + (0x2184, 0x2184), + (0x24D0, 0x24E9), + (0x2C30, 0x2C5F), + (0x2C61, 0x2C61), + (0x2C65, 0x2C66), + (0x2C68, 0x2C68), + (0x2C6A, 0x2C6A), + (0x2C6C, 0x2C6C), + (0x2C73, 0x2C73), + (0x2C76, 0x2C76), + (0x2C81, 0x2C81), + (0x2C83, 0x2C83), + (0x2C85, 0x2C85), + (0x2C87, 0x2C87), + (0x2C89, 0x2C89), + (0x2C8B, 0x2C8B), + (0x2C8D, 0x2C8D), + (0x2C8F, 0x2C8F), + (0x2C91, 0x2C91), + (0x2C93, 0x2C93), + (0x2C95, 0x2C95), + (0x2C97, 0x2C97), + (0x2C99, 0x2C99), + (0x2C9B, 0x2C9B), + (0x2C9D, 0x2C9D), + (0x2C9F, 0x2C9F), + (0x2CA1, 0x2CA1), + (0x2CA3, 0x2CA3), + (0x2CA5, 0x2CA5), + (0x2CA7, 0x2CA7), + (0x2CA9, 0x2CA9), + (0x2CAB, 0x2CAB), + (0x2CAD, 0x2CAD), + (0x2CAF, 0x2CAF), + (0x2CB1, 0x2CB1), + (0x2CB3, 0x2CB3), + (0x2CB5, 0x2CB5), + (0x2CB7, 0x2CB7), + (0x2CB9, 0x2CB9), + (0x2CBB, 0x2CBB), + (0x2CBD, 0x2CBD), + (0x2CBF, 0x2CBF), + (0x2CC1, 0x2CC1), + (0x2CC3, 0x2CC3), + (0x2CC5, 0x2CC5), + (0x2CC7, 0x2CC7), + (0x2CC9, 0x2CC9), + (0x2CCB, 0x2CCB), + (0x2CCD, 0x2CCD), + (0x2CCF, 0x2CCF), + (0x2CD1, 0x2CD1), + (0x2CD3, 0x2CD3), + (0x2CD5, 0x2CD5), + (0x2CD7, 0x2CD7), + (0x2CD9, 0x2CD9), + (0x2CDB, 0x2CDB), + (0x2CDD, 0x2CDD), + (0x2CDF, 0x2CDF), + (0x2CE1, 0x2CE1), + (0x2CE3, 0x2CE3), + (0x2CEC, 0x2CEC), + (0x2CEE, 0x2CEE), + (0x2CF3, 0x2CF3), + (0x2D00, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0xA641, 0xA641), + (0xA643, 0xA643), + (0xA645, 0xA645), + (0xA647, 0xA647), + (0xA649, 0xA649), + (0xA64B, 0xA64B), + (0xA64D, 0xA64D), + (0xA64F, 0xA64F), + (0xA651, 0xA651), + (0xA653, 0xA653), + (0xA655, 0xA655), + (0xA657, 0xA657), + (0xA659, 0xA659), + (0xA65B, 0xA65B), + (0xA65D, 0xA65D), + (0xA65F, 0xA65F), + (0xA661, 0xA661), + (0xA663, 0xA663), + (0xA665, 0xA665), + (0xA667, 0xA667), + (0xA669, 0xA669), + (0xA66B, 0xA66B), + (0xA66D, 0xA66D), + (0xA681, 0xA681), + (0xA683, 0xA683), + (0xA685, 0xA685), + (0xA687, 0xA687), + (0xA689, 0xA689), + (0xA68B, 0xA68B), + (0xA68D, 0xA68D), + (0xA68F, 0xA68F), + (0xA691, 0xA691), + (0xA693, 0xA693), + (0xA695, 0xA695), + (0xA697, 0xA697), + (0xA699, 0xA699), + (0xA69B, 0xA69B), + (0xA723, 0xA723), + (0xA725, 0xA725), + (0xA727, 0xA727), + (0xA729, 0xA729), + (0xA72B, 0xA72B), + (0xA72D, 0xA72D), + (0xA72F, 0xA72F), + (0xA733, 0xA733), + (0xA735, 0xA735), + (0xA737, 0xA737), + (0xA739, 0xA739), + (0xA73B, 0xA73B), + (0xA73D, 0xA73D), + (0xA73F, 0xA73F), + (0xA741, 0xA741), + (0xA743, 0xA743), + (0xA745, 0xA745), + (0xA747, 0xA747), + (0xA749, 0xA749), + (0xA74B, 0xA74B), + (0xA74D, 0xA74D), + (0xA74F, 0xA74F), + (0xA751, 0xA751), + (0xA753, 0xA753), + (0xA755, 0xA755), + (0xA757, 0xA757), + (0xA759, 0xA759), + (0xA75B, 0xA75B), + (0xA75D, 0xA75D), + (0xA75F, 0xA75F), + (0xA761, 0xA761), + (0xA763, 0xA763), + (0xA765, 0xA765), + (0xA767, 0xA767), + (0xA769, 0xA769), + (0xA76B, 0xA76B), + (0xA76D, 0xA76D), + (0xA76F, 0xA76F), + (0xA77A, 0xA77A), + (0xA77C, 0xA77C), + (0xA77F, 0xA77F), + (0xA781, 0xA781), + (0xA783, 0xA783), + (0xA785, 0xA785), + (0xA787, 0xA787), + (0xA78C, 0xA78C), + (0xA791, 0xA791), + (0xA793, 0xA794), + (0xA797, 0xA797), + (0xA799, 0xA799), + (0xA79B, 0xA79B), + (0xA79D, 0xA79D), + (0xA79F, 0xA79F), + (0xA7A1, 0xA7A1), + (0xA7A3, 0xA7A3), + (0xA7A5, 0xA7A5), + (0xA7A7, 0xA7A7), + (0xA7A9, 0xA7A9), + (0xA7B5, 0xA7B5), + (0xA7B7, 0xA7B7), + (0xA7B9, 0xA7B9), + (0xA7BB, 0xA7BB), + (0xA7BD, 0xA7BD), + (0xA7BF, 0xA7BF), + (0xA7C1, 0xA7C1), + (0xA7C3, 0xA7C3), + (0xA7C8, 0xA7C8), + (0xA7CA, 0xA7CA), + (0xA7CD, 0xA7CD), + (0xA7CF, 0xA7CF), + (0xA7D1, 0xA7D1), + (0xA7D3, 0xA7D3), + (0xA7D5, 0xA7D5), + (0xA7D7, 0xA7D7), + (0xA7D9, 0xA7D9), + (0xA7DB, 0xA7DB), + (0xA7F6, 0xA7F6), + (0xAB4B, 0xAB4C), + (0xAB53, 0xAB53), + (0xAB70, 0xABBF), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFF41, 0xFF5A), + (0x10428, 0x1044F), + (0x104D8, 0x104FB), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x10CC0, 0x10CF2), + (0x10D70, 0x10D85), + (0x118C0, 0x118DF), + (0x16E60, 0x16E7F), + (0x16EBB, 0x16ED3), + (0x1DF41, 0x1DF41), + (0x1DF49, 0x1DF49), + (0x1DF4B, 0x1DF4B), + (0x1DF4E, 0x1DF4E), + (0x1DF52, 0x1DF52), + (0x1DF69, 0x1DF69), + (0x1DF6B, 0x1DF6B), + (0x1DF6D, 0x1DF6D), + (0x1DF6F, 0x1DF6F), + (0x1DF73, 0x1DF73), + (0x1DF75, 0x1DF75), + (0x1DF77, 0x1DF77), + (0x1DF79, 0x1DF79), + (0x1DF7B, 0x1DF7B), + (0x1DF7D, 0x1DF7D), + (0x1DF7F, 0x1DF7F), + (0x1DF95, 0x1DF95), + (0x1E922, 0x1E943), +]; + +/// The code points with the binary property Dash, as ranges. +pub static BINARY_DASH: &[(u32, u32)] = &[ + (0x2D, 0x2D), + (0x58A, 0x58A), + (0x5BE, 0x5BE), + (0x1400, 0x1400), + (0x1806, 0x1806), + (0x2010, 0x2015), + (0x2053, 0x2053), + (0x207B, 0x207B), + (0x208B, 0x208B), + (0x2212, 0x2212), + (0x2E17, 0x2E17), + (0x2E1A, 0x2E1A), + (0x2E3A, 0x2E3B), + (0x2E40, 0x2E40), + (0x2E5D, 0x2E5D), + (0x301C, 0x301C), + (0x3030, 0x3030), + (0x30A0, 0x30A0), + (0xFE31, 0xFE32), + (0xFE58, 0xFE58), + (0xFE63, 0xFE63), + (0xFF0D, 0xFF0D), + (0x10D6E, 0x10D6E), + (0x10EAD, 0x10EAD), +]; + +/// The code points with the binary property Default_Ignorable_Code_Point, as ranges. +pub static BINARY_DEFAULT_IGNORABLE_CODE_POINT: &[(u32, u32)] = &[ + (0xAD, 0xAD), + (0x34F, 0x34F), + (0x61C, 0x61C), + (0x115F, 0x1160), + (0x17B4, 0x17B5), + (0x180B, 0x180F), + (0x200B, 0x200F), + (0x202A, 0x202E), + (0x2060, 0x206F), + (0x3164, 0x3164), + (0xFE00, 0xFE0F), + (0xFEFF, 0xFEFF), + (0xFFA0, 0xFFA0), + (0xFFF0, 0xFFF8), + (0x1BCA0, 0x1BCA3), + (0x1D173, 0x1D17A), + (0xE0000, 0xE0FFF), +]; + +/// The code points with the binary property Deprecated, as ranges. +pub static BINARY_DEPRECATED: &[(u32, u32)] = &[ + (0x149, 0x149), + (0x673, 0x673), + (0xF77, 0xF77), + (0xF79, 0xF79), + (0x17A3, 0x17A4), + (0x206A, 0x206F), + (0x2329, 0x232A), + (0xE0001, 0xE0001), +]; + +/// The code points with the binary property Diacritic, as ranges. +pub static BINARY_DIACRITIC: &[(u32, u32)] = &[ + (0x5E, 0x5E), + (0x60, 0x60), + (0xA8, 0xA8), + (0xAF, 0xAF), + (0xB4, 0xB4), + (0xB7, 0xB8), + (0x2B0, 0x34E), + (0x350, 0x357), + (0x35D, 0x362), + (0x374, 0x375), + (0x37A, 0x37A), + (0x384, 0x385), + (0x483, 0x487), + (0x558, 0x559), + (0x58B, 0x58C), + (0x591, 0x5BD), + (0x5BF, 0x5BF), + (0x5C1, 0x5C2), + (0x5C4, 0x5C5), + (0x5C7, 0x5C9), + (0x64B, 0x652), + (0x656, 0x658), + (0x6DF, 0x6E0), + (0x6E2, 0x6E2), + (0x6E5, 0x6E6), + (0x6EA, 0x6EC), + (0x730, 0x74A), + (0x7A6, 0x7B0), + (0x7EB, 0x7F5), + (0x818, 0x819), + (0x898, 0x89F), + (0x8C9, 0x8D3), + (0x8E3, 0x8FE), + (0x93C, 0x93C), + (0x94D, 0x94D), + (0x951, 0x954), + (0x971, 0x971), + (0x9BC, 0x9BC), + (0x9CD, 0x9CD), + (0xA3C, 0xA3C), + (0xA4D, 0xA4D), + (0xABC, 0xABC), + (0xACD, 0xACD), + (0xAFD, 0xAFF), + (0xB3C, 0xB3C), + (0xB4D, 0xB4D), + (0xB53, 0xB55), + (0xBCD, 0xBCD), + (0xC3C, 0xC3C), + (0xC4D, 0xC4D), + (0xCBC, 0xCBC), + (0xCCD, 0xCCD), + (0xD3B, 0xD3C), + (0xD4D, 0xD4D), + (0xDCA, 0xDCA), + (0xE3A, 0xE3A), + (0xE47, 0xE4C), + (0xE4E, 0xE4E), + (0xEBA, 0xEBA), + (0xEC8, 0xECC), + (0xF18, 0xF19), + (0xF35, 0xF35), + (0xF37, 0xF37), + (0xF39, 0xF39), + (0xF3E, 0xF3F), + (0xF82, 0xF84), + (0xF86, 0xF87), + (0xFC6, 0xFC6), + (0x1037, 0x1037), + (0x1039, 0x103A), + (0x1063, 0x1064), + (0x1069, 0x106D), + (0x1087, 0x108D), + (0x108F, 0x108F), + (0x109A, 0x109B), + (0x135D, 0x135F), + (0x1714, 0x1715), + (0x1734, 0x1734), + (0x17C9, 0x17D3), + (0x17DD, 0x17DD), + (0x1939, 0x193B), + (0x1A60, 0x1A60), + (0x1A75, 0x1A7C), + (0x1A7F, 0x1A7F), + (0x1AB0, 0x1ABE), + (0x1AC1, 0x1ACB), + (0x1ACF, 0x1AF0), + (0x1B34, 0x1B34), + (0x1B44, 0x1B44), + (0x1B6B, 0x1B73), + (0x1BAA, 0x1BAB), + (0x1BE6, 0x1BE6), + (0x1BF2, 0x1BF3), + (0x1C36, 0x1C37), + (0x1C78, 0x1C7D), + (0x1CD0, 0x1CE8), + (0x1CED, 0x1CED), + (0x1CF4, 0x1CF4), + (0x1CF7, 0x1CF9), + (0x1D2C, 0x1D6A), + (0x1D9B, 0x1DBE), + (0x1DC4, 0x1DCF), + (0x1DF5, 0x1DFF), + (0x1FBD, 0x1FBD), + (0x1FBF, 0x1FC1), + (0x1FCD, 0x1FCF), + (0x1FDD, 0x1FDF), + (0x1FED, 0x1FEF), + (0x1FFD, 0x1FFE), + (0x208F, 0x208F), + (0x2CEF, 0x2CF1), + (0x2E2F, 0x2E2F), + (0x302A, 0x302F), + (0x3099, 0x309C), + (0x30FC, 0x30FC), + (0xA66F, 0xA66F), + (0xA67C, 0xA67D), + (0xA67F, 0xA67F), + (0xA69C, 0xA69D), + (0xA6F0, 0xA6F1), + (0xA700, 0xA721), + (0xA788, 0xA78A), + (0xA7F1, 0xA7F1), + (0xA7F8, 0xA7F9), + (0xA806, 0xA806), + (0xA82C, 0xA82C), + (0xA8C4, 0xA8C4), + (0xA8E0, 0xA8F1), + (0xA92B, 0xA92E), + (0xA953, 0xA953), + (0xA9B3, 0xA9B3), + (0xA9C0, 0xA9C0), + (0xA9E5, 0xA9E5), + (0xAA7B, 0xAA7D), + (0xAABF, 0xAAC2), + (0xAAF6, 0xAAF6), + (0xAB5B, 0xAB5F), + (0xAB69, 0xAB6B), + (0xABEC, 0xABED), + (0xFB1E, 0xFB1E), + (0xFE20, 0xFE2F), + (0xFF3E, 0xFF3E), + (0xFF40, 0xFF40), + (0xFF70, 0xFF70), + (0xFF9E, 0xFF9F), + (0xFFE3, 0xFFE3), + (0x102E0, 0x102E0), + (0x10780, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BA), + (0x10A38, 0x10A3A), + (0x10A3F, 0x10A3F), + (0x10AE5, 0x10AE6), + (0x10D22, 0x10D27), + (0x10D4E, 0x10D4E), + (0x10D69, 0x10D6D), + (0x10ECB, 0x10ECF), + (0x10EF0, 0x10EF7), + (0x10EF9, 0x10EFA), + (0x10EFD, 0x10EFF), + (0x10F46, 0x10F50), + (0x10F82, 0x10F85), + (0x11046, 0x11046), + (0x11070, 0x11070), + (0x110B9, 0x110BA), + (0x11133, 0x11134), + (0x11173, 0x11173), + (0x111C0, 0x111C0), + (0x111CA, 0x111CC), + (0x11235, 0x11236), + (0x112E9, 0x112EA), + (0x1133B, 0x1133C), + (0x1134D, 0x1134D), + (0x11366, 0x1136C), + (0x11370, 0x11374), + (0x113CE, 0x113D0), + (0x113D2, 0x113D3), + (0x113E1, 0x113E2), + (0x11442, 0x11442), + (0x11446, 0x11446), + (0x114C2, 0x114C3), + (0x115BF, 0x115C0), + (0x1163F, 0x1163F), + (0x116B6, 0x116B7), + (0x1172B, 0x1172B), + (0x11839, 0x1183A), + (0x1193D, 0x1193E), + (0x11943, 0x11943), + (0x119E0, 0x119E0), + (0x11A34, 0x11A34), + (0x11A47, 0x11A47), + (0x11A99, 0x11A99), + (0x11C3F, 0x11C3F), + (0x11D42, 0x11D42), + (0x11D44, 0x11D45), + (0x11D97, 0x11D97), + (0x11DD9, 0x11DD9), + (0x11F41, 0x11F42), + (0x11F5A, 0x11F5A), + (0x13447, 0x13455), + (0x1612F, 0x1612F), + (0x16AF0, 0x16AF4), + (0x16B30, 0x16B36), + (0x16D6B, 0x16D6C), + (0x16F8F, 0x16F9F), + (0x16FF0, 0x16FF1), + (0x1AFF0, 0x1AFF3), + (0x1AFF5, 0x1AFFB), + (0x1AFFD, 0x1AFFE), + (0x1CF00, 0x1CF2D), + (0x1CF30, 0x1CF46), + (0x1D167, 0x1D169), + (0x1D16D, 0x1D172), + (0x1D17B, 0x1D182), + (0x1D185, 0x1D18B), + (0x1D1AA, 0x1D1AD), + (0x1D250, 0x1D252), + (0x1D25B, 0x1D25C), + (0x1DFCD, 0x1DFCF), + (0x1DFD1, 0x1DFFF), + (0x1E030, 0x1E06D), + (0x1E130, 0x1E136), + (0x1E2AE, 0x1E2AE), + (0x1E2EC, 0x1E2EF), + (0x1E5EE, 0x1E5EF), + (0x1E8D0, 0x1E8D6), + (0x1E944, 0x1E946), + (0x1E948, 0x1E94A), +]; + +/// The code points with the binary property Emoji, as ranges. +pub static BINARY_EMOJI: &[(u32, u32)] = &[ + (0x23, 0x23), + (0x2A, 0x2A), + (0x30, 0x39), + (0xA9, 0xA9), + (0xAE, 0xAE), + (0x203C, 0x203C), + (0x2049, 0x2049), + (0x2122, 0x2122), + (0x2139, 0x2139), + (0x2194, 0x2199), + (0x21A9, 0x21AA), + (0x231A, 0x231B), + (0x2328, 0x2328), + (0x23CF, 0x23CF), + (0x23E9, 0x23F3), + (0x23F8, 0x23FA), + (0x24C2, 0x24C2), + (0x25AA, 0x25AB), + (0x25B6, 0x25B6), + (0x25C0, 0x25C0), + (0x25FB, 0x25FE), + (0x2600, 0x2604), + (0x260E, 0x260E), + (0x2611, 0x2611), + (0x2614, 0x2615), + (0x2618, 0x2618), + (0x261D, 0x261D), + (0x2620, 0x2620), + (0x2622, 0x2623), + (0x2626, 0x2626), + (0x262A, 0x262A), + (0x262E, 0x262F), + (0x2638, 0x263A), + (0x2640, 0x2640), + (0x2642, 0x2642), + (0x2648, 0x2653), + (0x265F, 0x2660), + (0x2663, 0x2663), + (0x2665, 0x2666), + (0x2668, 0x2668), + (0x267B, 0x267B), + (0x267E, 0x267F), + (0x2692, 0x2697), + (0x2699, 0x2699), + (0x269B, 0x269C), + (0x26A0, 0x26A1), + (0x26A7, 0x26A7), + (0x26AA, 0x26AB), + (0x26B0, 0x26B1), + (0x26BD, 0x26BE), + (0x26C4, 0x26C5), + (0x26C8, 0x26C8), + (0x26CE, 0x26CF), + (0x26D1, 0x26D1), + (0x26D3, 0x26D4), + (0x26E9, 0x26EA), + (0x26F0, 0x26F5), + (0x26F7, 0x26FA), + (0x26FD, 0x26FD), + (0x2702, 0x2702), + (0x2705, 0x2705), + (0x2708, 0x270D), + (0x270F, 0x270F), + (0x2712, 0x2712), + (0x2714, 0x2714), + (0x2716, 0x2716), + (0x271D, 0x271D), + (0x2721, 0x2721), + (0x2728, 0x2728), + (0x2733, 0x2734), + (0x2744, 0x2744), + (0x2747, 0x2747), + (0x274C, 0x274C), + (0x274E, 0x274E), + (0x2753, 0x2755), + (0x2757, 0x2757), + (0x2763, 0x2764), + (0x2795, 0x2797), + (0x27A1, 0x27A1), + (0x27B0, 0x27B0), + (0x27BF, 0x27BF), + (0x2934, 0x2935), + (0x2B05, 0x2B07), + (0x2B1B, 0x2B1C), + (0x2B50, 0x2B50), + (0x2B55, 0x2B55), + (0x3030, 0x3030), + (0x303D, 0x303D), + (0x3297, 0x3297), + (0x3299, 0x3299), + (0x1F004, 0x1F004), + (0x1F0CF, 0x1F0CF), + (0x1F170, 0x1F171), + (0x1F17E, 0x1F17F), + (0x1F18E, 0x1F18E), + (0x1F191, 0x1F19A), + (0x1F1E6, 0x1F1FF), + (0x1F201, 0x1F202), + (0x1F21A, 0x1F21A), + (0x1F22F, 0x1F22F), + (0x1F232, 0x1F23A), + (0x1F250, 0x1F251), + (0x1F300, 0x1F321), + (0x1F324, 0x1F393), + (0x1F396, 0x1F397), + (0x1F399, 0x1F39B), + (0x1F39E, 0x1F3F0), + (0x1F3F3, 0x1F3F5), + (0x1F3F7, 0x1F4FD), + (0x1F4FF, 0x1F53D), + (0x1F549, 0x1F54E), + (0x1F550, 0x1F567), + (0x1F56F, 0x1F570), + (0x1F573, 0x1F57A), + (0x1F587, 0x1F587), + (0x1F58A, 0x1F58D), + (0x1F590, 0x1F590), + (0x1F595, 0x1F596), + (0x1F5A4, 0x1F5A5), + (0x1F5A8, 0x1F5A8), + (0x1F5B1, 0x1F5B2), + (0x1F5BC, 0x1F5BC), + (0x1F5C2, 0x1F5C4), + (0x1F5D1, 0x1F5D3), + (0x1F5DC, 0x1F5DE), + (0x1F5E1, 0x1F5E1), + (0x1F5E3, 0x1F5E3), + (0x1F5E8, 0x1F5E8), + (0x1F5EF, 0x1F5EF), + (0x1F5F3, 0x1F5F3), + (0x1F5FA, 0x1F64F), + (0x1F680, 0x1F6C5), + (0x1F6CB, 0x1F6D2), + (0x1F6D5, 0x1F6D9), + (0x1F6DC, 0x1F6E5), + (0x1F6E9, 0x1F6E9), + (0x1F6EB, 0x1F6EC), + (0x1F6F0, 0x1F6F0), + (0x1F6F3, 0x1F6FC), + (0x1F7E0, 0x1F7EB), + (0x1F7F0, 0x1F7F0), + (0x1F90C, 0x1F93A), + (0x1F93C, 0x1F945), + (0x1F947, 0x1F9FF), + (0x1FA70, 0x1FA7C), + (0x1FA80, 0x1FAC6), + (0x1FAC8, 0x1FAC8), + (0x1FACC, 0x1FADD), + (0x1FADF, 0x1FAEB), + (0x1FAEF, 0x1FAFA), +]; + +/// The code points with the binary property Emoji_Component, as ranges. +pub static BINARY_EMOJI_COMPONENT: &[(u32, u32)] = &[ + (0x23, 0x23), + (0x2A, 0x2A), + (0x30, 0x39), + (0x200D, 0x200D), + (0x20E3, 0x20E3), + (0xFE0F, 0xFE0F), + (0x1F1E6, 0x1F1FF), + (0x1F3FB, 0x1F3FF), + (0x1F9B0, 0x1F9B3), + (0xE0020, 0xE007F), +]; + +/// The code points with the binary property Emoji_Modifier, as ranges. +pub static BINARY_EMOJI_MODIFIER: &[(u32, u32)] = &[(0x1F3FB, 0x1F3FF)]; + +/// The code points with the binary property Emoji_Modifier_Base, as ranges. +pub static BINARY_EMOJI_MODIFIER_BASE: &[(u32, u32)] = &[ + (0x261D, 0x261D), + (0x26F9, 0x26F9), + (0x270A, 0x270D), + (0x1F385, 0x1F385), + (0x1F3C2, 0x1F3C4), + (0x1F3C7, 0x1F3C7), + (0x1F3CA, 0x1F3CC), + (0x1F442, 0x1F443), + (0x1F446, 0x1F450), + (0x1F466, 0x1F478), + (0x1F47C, 0x1F47C), + (0x1F481, 0x1F483), + (0x1F485, 0x1F487), + (0x1F48F, 0x1F48F), + (0x1F491, 0x1F491), + (0x1F4AA, 0x1F4AA), + (0x1F574, 0x1F575), + (0x1F57A, 0x1F57A), + (0x1F590, 0x1F590), + (0x1F595, 0x1F596), + (0x1F645, 0x1F647), + (0x1F64B, 0x1F64F), + (0x1F6A3, 0x1F6A3), + (0x1F6B4, 0x1F6B6), + (0x1F6C0, 0x1F6C0), + (0x1F6CC, 0x1F6CC), + (0x1F90C, 0x1F90C), + (0x1F90F, 0x1F90F), + (0x1F918, 0x1F91F), + (0x1F926, 0x1F926), + (0x1F930, 0x1F939), + (0x1F93C, 0x1F93E), + (0x1F977, 0x1F977), + (0x1F9B5, 0x1F9B6), + (0x1F9B8, 0x1F9B9), + (0x1F9BB, 0x1F9BB), + (0x1F9CD, 0x1F9CF), + (0x1F9D1, 0x1F9DD), + (0x1FAC3, 0x1FAC5), + (0x1FAF0, 0x1FAFA), +]; + +/// The code points with the binary property Emoji_Presentation, as ranges. +pub static BINARY_EMOJI_PRESENTATION: &[(u32, u32)] = &[ + (0x231A, 0x231B), + (0x23E9, 0x23EC), + (0x23F0, 0x23F0), + (0x23F3, 0x23F3), + (0x25FD, 0x25FE), + (0x2614, 0x2615), + (0x2648, 0x2653), + (0x267F, 0x267F), + (0x2693, 0x2693), + (0x26A1, 0x26A1), + (0x26AA, 0x26AB), + (0x26BD, 0x26BE), + (0x26C4, 0x26C5), + (0x26CE, 0x26CE), + (0x26D4, 0x26D4), + (0x26EA, 0x26EA), + (0x26F2, 0x26F3), + (0x26F5, 0x26F5), + (0x26FA, 0x26FA), + (0x26FD, 0x26FD), + (0x2705, 0x2705), + (0x270A, 0x270B), + (0x2728, 0x2728), + (0x274C, 0x274C), + (0x274E, 0x274E), + (0x2753, 0x2755), + (0x2757, 0x2757), + (0x2795, 0x2797), + (0x27B0, 0x27B0), + (0x27BF, 0x27BF), + (0x2B1B, 0x2B1C), + (0x2B50, 0x2B50), + (0x2B55, 0x2B55), + (0x1F004, 0x1F004), + (0x1F0CF, 0x1F0CF), + (0x1F18E, 0x1F18E), + (0x1F191, 0x1F19A), + (0x1F1E6, 0x1F1FF), + (0x1F201, 0x1F201), + (0x1F21A, 0x1F21A), + (0x1F22F, 0x1F22F), + (0x1F232, 0x1F236), + (0x1F238, 0x1F23A), + (0x1F250, 0x1F251), + (0x1F300, 0x1F320), + (0x1F32D, 0x1F335), + (0x1F337, 0x1F37C), + (0x1F37E, 0x1F393), + (0x1F3A0, 0x1F3CA), + (0x1F3CF, 0x1F3D3), + (0x1F3E0, 0x1F3F0), + (0x1F3F4, 0x1F3F4), + (0x1F3F8, 0x1F43E), + (0x1F440, 0x1F440), + (0x1F442, 0x1F4FC), + (0x1F4FF, 0x1F53D), + (0x1F54B, 0x1F54E), + (0x1F550, 0x1F567), + (0x1F57A, 0x1F57A), + (0x1F595, 0x1F596), + (0x1F5A4, 0x1F5A4), + (0x1F5FB, 0x1F64F), + (0x1F680, 0x1F6C5), + (0x1F6CC, 0x1F6CC), + (0x1F6D0, 0x1F6D2), + (0x1F6D5, 0x1F6D9), + (0x1F6DC, 0x1F6DF), + (0x1F6EB, 0x1F6EC), + (0x1F6F4, 0x1F6FC), + (0x1F7E0, 0x1F7EB), + (0x1F7F0, 0x1F7F0), + (0x1F90C, 0x1F93A), + (0x1F93C, 0x1F945), + (0x1F947, 0x1F9FF), + (0x1FA70, 0x1FA7C), + (0x1FA80, 0x1FAC6), + (0x1FAC8, 0x1FAC8), + (0x1FACC, 0x1FADD), + (0x1FADF, 0x1FAEB), + (0x1FAEF, 0x1FAFA), +]; + +/// The code points with the binary property Extended_Pictographic, as ranges. +pub static BINARY_EXTENDED_PICTOGRAPHIC: &[(u32, u32)] = &[ + (0xA9, 0xA9), + (0xAE, 0xAE), + (0x203C, 0x203C), + (0x2049, 0x2049), + (0x2122, 0x2122), + (0x2139, 0x2139), + (0x2194, 0x2199), + (0x21A9, 0x21AA), + (0x231A, 0x231B), + (0x2328, 0x2328), + (0x23CF, 0x23CF), + (0x23E9, 0x23F3), + (0x23F8, 0x23FA), + (0x24C2, 0x24C2), + (0x25AA, 0x25AB), + (0x25B6, 0x25B6), + (0x25C0, 0x25C0), + (0x25FB, 0x25FE), + (0x2600, 0x2604), + (0x260E, 0x260E), + (0x2611, 0x2611), + (0x2614, 0x2615), + (0x2618, 0x2618), + (0x261D, 0x261D), + (0x2620, 0x2620), + (0x2622, 0x2623), + (0x2626, 0x2626), + (0x262A, 0x262A), + (0x262E, 0x262F), + (0x2638, 0x263A), + (0x2640, 0x2640), + (0x2642, 0x2642), + (0x2648, 0x2653), + (0x265F, 0x2660), + (0x2663, 0x2663), + (0x2665, 0x2666), + (0x2668, 0x2668), + (0x267B, 0x267B), + (0x267E, 0x267F), + (0x2692, 0x2697), + (0x2699, 0x2699), + (0x269B, 0x269C), + (0x26A0, 0x26A1), + (0x26A7, 0x26A7), + (0x26AA, 0x26AB), + (0x26B0, 0x26B1), + (0x26BD, 0x26BE), + (0x26C4, 0x26C5), + (0x26C8, 0x26C8), + (0x26CE, 0x26CF), + (0x26D1, 0x26D1), + (0x26D3, 0x26D4), + (0x26E9, 0x26EA), + (0x26F0, 0x26F5), + (0x26F7, 0x26FA), + (0x26FD, 0x26FD), + (0x2702, 0x2702), + (0x2705, 0x2705), + (0x2708, 0x270D), + (0x270F, 0x270F), + (0x2712, 0x2712), + (0x2714, 0x2714), + (0x2716, 0x2716), + (0x271D, 0x271D), + (0x2721, 0x2721), + (0x2728, 0x2728), + (0x2733, 0x2734), + (0x2744, 0x2744), + (0x2747, 0x2747), + (0x274C, 0x274C), + (0x274E, 0x274E), + (0x2753, 0x2755), + (0x2757, 0x2757), + (0x2763, 0x2764), + (0x2795, 0x2797), + (0x27A1, 0x27A1), + (0x27B0, 0x27B0), + (0x27BF, 0x27BF), + (0x2934, 0x2935), + (0x2B05, 0x2B07), + (0x2B1B, 0x2B1C), + (0x2B50, 0x2B50), + (0x2B55, 0x2B55), + (0x3030, 0x3030), + (0x303D, 0x303D), + (0x3297, 0x3297), + (0x3299, 0x3299), + (0x1F004, 0x1F004), + (0x1F02C, 0x1F02F), + (0x1F094, 0x1F09F), + (0x1F0AF, 0x1F0B0), + (0x1F0C0, 0x1F0C0), + (0x1F0CF, 0x1F0D0), + (0x1F0F6, 0x1F0FF), + (0x1F170, 0x1F171), + (0x1F17E, 0x1F17F), + (0x1F18E, 0x1F18E), + (0x1F191, 0x1F19A), + (0x1F1AF, 0x1F1E5), + (0x1F201, 0x1F20F), + (0x1F21A, 0x1F21A), + (0x1F22F, 0x1F22F), + (0x1F232, 0x1F23A), + (0x1F23C, 0x1F23F), + (0x1F249, 0x1F25F), + (0x1F266, 0x1F321), + (0x1F324, 0x1F393), + (0x1F396, 0x1F397), + (0x1F399, 0x1F39B), + (0x1F39E, 0x1F3F0), + (0x1F3F3, 0x1F3F5), + (0x1F3F7, 0x1F3FA), + (0x1F400, 0x1F4FD), + (0x1F4FF, 0x1F53D), + (0x1F549, 0x1F54E), + (0x1F550, 0x1F567), + (0x1F56F, 0x1F570), + (0x1F573, 0x1F57A), + (0x1F587, 0x1F587), + (0x1F58A, 0x1F58D), + (0x1F590, 0x1F590), + (0x1F595, 0x1F596), + (0x1F5A4, 0x1F5A5), + (0x1F5A8, 0x1F5A8), + (0x1F5B1, 0x1F5B2), + (0x1F5BC, 0x1F5BC), + (0x1F5C2, 0x1F5C4), + (0x1F5D1, 0x1F5D3), + (0x1F5DC, 0x1F5DE), + (0x1F5E1, 0x1F5E1), + (0x1F5E3, 0x1F5E3), + (0x1F5E8, 0x1F5E8), + (0x1F5EF, 0x1F5EF), + (0x1F5F3, 0x1F5F3), + (0x1F5FA, 0x1F64F), + (0x1F680, 0x1F6C5), + (0x1F6CB, 0x1F6D2), + (0x1F6D5, 0x1F6E5), + (0x1F6E9, 0x1F6E9), + (0x1F6EB, 0x1F6F0), + (0x1F6F3, 0x1F6FF), + (0x1F7DC, 0x1F7F0), + (0x1F80C, 0x1F80F), + (0x1F848, 0x1F84F), + (0x1F85A, 0x1F85F), + (0x1F888, 0x1F88F), + (0x1F8AE, 0x1F8AF), + (0x1F8BC, 0x1F8BF), + (0x1F8C2, 0x1F8CF), + (0x1F8D9, 0x1F8FF), + (0x1F90C, 0x1F93A), + (0x1F93C, 0x1F945), + (0x1F947, 0x1F9FF), + (0x1FA58, 0x1FA5F), + (0x1FA6E, 0x1FAFF), + (0x1FC00, 0x1FFFD), +]; + +/// The code points with the binary property Extender, as ranges. +pub static BINARY_EXTENDER: &[(u32, u32)] = &[ + (0xB7, 0xB7), + (0x2D0, 0x2D1), + (0x640, 0x640), + (0x7FA, 0x7FA), + (0xA71, 0xA71), + (0xAFB, 0xAFB), + (0xB54, 0xB55), + (0xE46, 0xE46), + (0xEC6, 0xEC6), + (0x180A, 0x180A), + (0x1843, 0x1843), + (0x1AA7, 0x1AA7), + (0x1C36, 0x1C36), + (0x1C7B, 0x1C7B), + (0x3005, 0x3005), + (0x3031, 0x3035), + (0x309D, 0x309E), + (0x30FC, 0x30FE), + (0xA015, 0xA015), + (0xA60C, 0xA60C), + (0xA9CF, 0xA9CF), + (0xA9E6, 0xA9E6), + (0xAA70, 0xAA70), + (0xAADD, 0xAADD), + (0xAAF3, 0xAAF4), + (0xFF70, 0xFF70), + (0x10781, 0x10782), + (0x10D4E, 0x10D4E), + (0x10D6A, 0x10D6A), + (0x10D6F, 0x10D6F), + (0x11237, 0x11237), + (0x1135D, 0x1135D), + (0x113D2, 0x113D3), + (0x115C6, 0x115C8), + (0x11A98, 0x11A98), + (0x11DD9, 0x11DD9), + (0x16B42, 0x16B43), + (0x16FE0, 0x16FE1), + (0x16FE3, 0x16FE3), + (0x16FF2, 0x16FF3), + (0x1E13C, 0x1E13D), + (0x1E5EF, 0x1E5EF), + (0x1E944, 0x1E946), +]; + +/// The code points with the binary property Grapheme_Base, as ranges. +pub static BINARY_GRAPHEME_BASE: &[(u32, u32)] = &[ + (0x20, 0x7E), + (0xA0, 0xAC), + (0xAE, 0x2FF), + (0x370, 0x377), + (0x37A, 0x37F), + (0x384, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x3A1), + (0x3A3, 0x482), + (0x48A, 0x52F), + (0x531, 0x556), + (0x558, 0x58F), + (0x5BE, 0x5BE), + (0x5C0, 0x5C0), + (0x5C3, 0x5C3), + (0x5C6, 0x5C6), + (0x5D0, 0x5EA), + (0x5EF, 0x5F4), + (0x606, 0x60F), + (0x61B, 0x61B), + (0x61D, 0x64A), + (0x660, 0x66F), + (0x671, 0x6D5), + (0x6DE, 0x6DE), + (0x6E5, 0x6E6), + (0x6E9, 0x6E9), + (0x6EE, 0x70D), + (0x710, 0x710), + (0x712, 0x72F), + (0x74D, 0x7A5), + (0x7B1, 0x7B1), + (0x7C0, 0x7EA), + (0x7F4, 0x7FA), + (0x7FE, 0x815), + (0x81A, 0x81A), + (0x824, 0x824), + (0x828, 0x828), + (0x830, 0x83E), + (0x840, 0x858), + (0x85E, 0x85E), + (0x860, 0x86A), + (0x870, 0x88F), + (0x8A0, 0x8C9), + (0x903, 0x939), + (0x93B, 0x93B), + (0x93D, 0x940), + (0x949, 0x94C), + (0x94E, 0x950), + (0x958, 0x961), + (0x964, 0x980), + (0x982, 0x983), + (0x985, 0x98C), + (0x98F, 0x990), + (0x993, 0x9A8), + (0x9AA, 0x9B0), + (0x9B2, 0x9B2), + (0x9B6, 0x9B9), + (0x9BD, 0x9BD), + (0x9BF, 0x9C0), + (0x9C7, 0x9C8), + (0x9CB, 0x9CC), + (0x9CE, 0x9CE), + (0x9DC, 0x9DD), + (0x9DF, 0x9E1), + (0x9E6, 0x9FD), + (0xA03, 0xA03), + (0xA05, 0xA0A), + (0xA0F, 0xA10), + (0xA13, 0xA28), + (0xA2A, 0xA30), + (0xA32, 0xA33), + (0xA35, 0xA36), + (0xA38, 0xA39), + (0xA3E, 0xA40), + (0xA59, 0xA5C), + (0xA5E, 0xA5E), + (0xA66, 0xA6F), + (0xA72, 0xA74), + (0xA76, 0xA76), + (0xA83, 0xA83), + (0xA85, 0xA8D), + (0xA8F, 0xA91), + (0xA93, 0xAA8), + (0xAAA, 0xAB0), + (0xAB2, 0xAB3), + (0xAB5, 0xAB9), + (0xABD, 0xAC0), + (0xAC9, 0xAC9), + (0xACB, 0xACC), + (0xAD0, 0xAD0), + (0xAE0, 0xAE1), + (0xAE6, 0xAF1), + (0xAF9, 0xAF9), + (0xB02, 0xB03), + (0xB05, 0xB0C), + (0xB0F, 0xB10), + (0xB13, 0xB28), + (0xB2A, 0xB30), + (0xB32, 0xB33), + (0xB35, 0xB39), + (0xB3D, 0xB3D), + (0xB40, 0xB40), + (0xB47, 0xB48), + (0xB4B, 0xB4C), + (0xB5C, 0xB5D), + (0xB5F, 0xB61), + (0xB66, 0xB77), + (0xB83, 0xB83), + (0xB85, 0xB8A), + (0xB8E, 0xB90), + (0xB92, 0xB95), + (0xB99, 0xB9A), + (0xB9C, 0xB9C), + (0xB9E, 0xB9F), + (0xBA3, 0xBA4), + (0xBA8, 0xBAA), + (0xBAE, 0xBB9), + (0xBBF, 0xBBF), + (0xBC1, 0xBC2), + (0xBC6, 0xBC8), + (0xBCA, 0xBCC), + (0xBD0, 0xBD0), + (0xBE6, 0xBFA), + (0xC01, 0xC03), + (0xC05, 0xC0C), + (0xC0E, 0xC10), + (0xC12, 0xC28), + (0xC2A, 0xC39), + (0xC3D, 0xC3D), + (0xC41, 0xC44), + (0xC58, 0xC5A), + (0xC5C, 0xC5D), + (0xC60, 0xC61), + (0xC66, 0xC6F), + (0xC77, 0xC80), + (0xC82, 0xC8C), + (0xC8E, 0xC90), + (0xC92, 0xCA8), + (0xCAA, 0xCB3), + (0xCB5, 0xCB9), + (0xCBD, 0xCBE), + (0xCC1, 0xCC1), + (0xCC3, 0xCC4), + (0xCDC, 0xCDE), + (0xCE0, 0xCE1), + (0xCE6, 0xCEF), + (0xCF1, 0xCF3), + (0xD02, 0xD0C), + (0xD0E, 0xD10), + (0xD12, 0xD3A), + (0xD3D, 0xD3D), + (0xD3F, 0xD40), + (0xD46, 0xD48), + (0xD4A, 0xD4C), + (0xD4E, 0xD4F), + (0xD54, 0xD56), + (0xD58, 0xD61), + (0xD66, 0xD7F), + (0xD82, 0xD83), + (0xD85, 0xD96), + (0xD9A, 0xDB1), + (0xDB3, 0xDBB), + (0xDBD, 0xDBD), + (0xDC0, 0xDC6), + (0xDD0, 0xDD1), + (0xDD8, 0xDDE), + (0xDE6, 0xDEF), + (0xDF2, 0xDF4), + (0xE01, 0xE30), + (0xE32, 0xE33), + (0xE3F, 0xE46), + (0xE4F, 0xE5B), + (0xE81, 0xE82), + (0xE84, 0xE84), + (0xE86, 0xE8A), + (0xE8C, 0xEA3), + (0xEA5, 0xEA5), + (0xEA7, 0xEB0), + (0xEB2, 0xEB3), + (0xEBD, 0xEBD), + (0xEC0, 0xEC4), + (0xEC6, 0xEC6), + (0xED0, 0xED9), + (0xEDC, 0xEDF), + (0xF00, 0xF17), + (0xF1A, 0xF34), + (0xF36, 0xF36), + (0xF38, 0xF38), + (0xF3A, 0xF47), + (0xF49, 0xF6C), + (0xF7F, 0xF7F), + (0xF85, 0xF85), + (0xF88, 0xF8C), + (0xFBE, 0xFC5), + (0xFC7, 0xFCC), + (0xFCE, 0xFDA), + (0x1000, 0x102C), + (0x1031, 0x1031), + (0x1038, 0x1038), + (0x103B, 0x103C), + (0x103F, 0x1057), + (0x105A, 0x105D), + (0x1061, 0x1070), + (0x1075, 0x1081), + (0x1083, 0x1084), + (0x1087, 0x108C), + (0x108E, 0x109C), + (0x109E, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x10D0, 0x1248), + (0x124A, 0x124D), + (0x1250, 0x1256), + (0x1258, 0x1258), + (0x125A, 0x125D), + (0x1260, 0x1288), + (0x128A, 0x128D), + (0x1290, 0x12B0), + (0x12B2, 0x12B5), + (0x12B8, 0x12BE), + (0x12C0, 0x12C0), + (0x12C2, 0x12C5), + (0x12C8, 0x12D6), + (0x12D8, 0x1310), + (0x1312, 0x1315), + (0x1318, 0x135A), + (0x1360, 0x137C), + (0x1380, 0x1399), + (0x13A0, 0x13F5), + (0x13F8, 0x13FD), + (0x1400, 0x169C), + (0x16A0, 0x16F8), + (0x1700, 0x1711), + (0x171F, 0x1731), + (0x1735, 0x1736), + (0x1740, 0x1751), + (0x1760, 0x176C), + (0x176E, 0x1770), + (0x1780, 0x17B3), + (0x17B6, 0x17B6), + (0x17BE, 0x17C5), + (0x17C7, 0x17C8), + (0x17D4, 0x17DC), + (0x17E0, 0x17E9), + (0x17F0, 0x17F9), + (0x1800, 0x180A), + (0x1810, 0x1819), + (0x1820, 0x1878), + (0x1880, 0x1884), + (0x1887, 0x18A8), + (0x18AA, 0x18AA), + (0x18B0, 0x18F5), + (0x1900, 0x191E), + (0x1923, 0x1926), + (0x1929, 0x192B), + (0x1930, 0x1931), + (0x1933, 0x1938), + (0x1940, 0x1940), + (0x1944, 0x196D), + (0x1970, 0x1974), + (0x1980, 0x19AB), + (0x19B0, 0x19C9), + (0x19D0, 0x19DA), + (0x19DE, 0x1A16), + (0x1A19, 0x1A1A), + (0x1A1E, 0x1A55), + (0x1A57, 0x1A57), + (0x1A61, 0x1A61), + (0x1A63, 0x1A64), + (0x1A6D, 0x1A72), + (0x1A80, 0x1A89), + (0x1A90, 0x1A99), + (0x1AA0, 0x1AAD), + (0x1B04, 0x1B33), + (0x1B3E, 0x1B41), + (0x1B45, 0x1B4C), + (0x1B4E, 0x1B6A), + (0x1B74, 0x1B7F), + (0x1B82, 0x1BA1), + (0x1BA6, 0x1BA7), + (0x1BAE, 0x1BE5), + (0x1BE7, 0x1BE7), + (0x1BEA, 0x1BEC), + (0x1BEE, 0x1BEE), + (0x1BFC, 0x1C2B), + (0x1C34, 0x1C35), + (0x1C3B, 0x1C49), + (0x1C4D, 0x1C8A), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CC7), + (0x1CD3, 0x1CD3), + (0x1CE1, 0x1CE1), + (0x1CE9, 0x1CEC), + (0x1CEE, 0x1CF3), + (0x1CF5, 0x1CF7), + (0x1CFA, 0x1CFA), + (0x1D00, 0x1DBF), + (0x1E00, 0x1F15), + (0x1F18, 0x1F1D), + (0x1F20, 0x1F45), + (0x1F48, 0x1F4D), + (0x1F50, 0x1F57), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F7D), + (0x1F80, 0x1FB4), + (0x1FB6, 0x1FC4), + (0x1FC6, 0x1FD3), + (0x1FD6, 0x1FDB), + (0x1FDD, 0x1FEF), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FFE), + (0x2000, 0x200A), + (0x2010, 0x2027), + (0x202F, 0x205F), + (0x2070, 0x2071), + (0x2074, 0x20C4), + (0x2100, 0x218B), + (0x2190, 0x2429), + (0x2440, 0x244A), + (0x2460, 0x2B73), + (0x2B76, 0x2CEE), + (0x2CF2, 0x2CF3), + (0x2CF9, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0x2D30, 0x2D67), + (0x2D6F, 0x2D70), + (0x2D80, 0x2D96), + (0x2DA0, 0x2DA6), + (0x2DA8, 0x2DAE), + (0x2DB0, 0x2DB6), + (0x2DB8, 0x2DBE), + (0x2DC0, 0x2DC6), + (0x2DC8, 0x2DCE), + (0x2DD0, 0x2DD6), + (0x2DD8, 0x2DDE), + (0x2E00, 0x2E5D), + (0x2E60, 0x2E63), + (0x2E80, 0x2E99), + (0x2E9B, 0x2EF3), + (0x2F00, 0x2FD5), + (0x2FF0, 0x3029), + (0x3030, 0x303F), + (0x3041, 0x3096), + (0x309B, 0x30FF), + (0x3105, 0x312F), + (0x3131, 0x318E), + (0x3190, 0x31E5), + (0x31EF, 0x321E), + (0x3220, 0xA48C), + (0xA490, 0xA4C6), + (0xA4D0, 0xA62B), + (0xA640, 0xA66E), + (0xA673, 0xA673), + (0xA67E, 0xA69D), + (0xA6A0, 0xA6EF), + (0xA6F2, 0xA6F7), + (0xA700, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F1, 0xA801), + (0xA803, 0xA805), + (0xA807, 0xA80A), + (0xA80C, 0xA824), + (0xA827, 0xA82B), + (0xA830, 0xA839), + (0xA840, 0xA877), + (0xA880, 0xA8C3), + (0xA8CE, 0xA8D9), + (0xA8F2, 0xA8FE), + (0xA900, 0xA925), + (0xA92E, 0xA946), + (0xA952, 0xA952), + (0xA95F, 0xA97C), + (0xA983, 0xA9B2), + (0xA9B4, 0xA9B5), + (0xA9BA, 0xA9BB), + (0xA9BE, 0xA9BF), + (0xA9C1, 0xA9CD), + (0xA9CF, 0xA9D9), + (0xA9DE, 0xA9E4), + (0xA9E6, 0xA9FE), + (0xAA00, 0xAA28), + (0xAA2F, 0xAA30), + (0xAA33, 0xAA34), + (0xAA40, 0xAA42), + (0xAA44, 0xAA4B), + (0xAA4D, 0xAA4D), + (0xAA50, 0xAA59), + (0xAA5C, 0xAA7B), + (0xAA7D, 0xAAAF), + (0xAAB1, 0xAAB1), + (0xAAB5, 0xAAB6), + (0xAAB9, 0xAABD), + (0xAAC0, 0xAAC0), + (0xAAC2, 0xAAC2), + (0xAADB, 0xAAEB), + (0xAAEE, 0xAAF5), + (0xAB01, 0xAB06), + (0xAB09, 0xAB0E), + (0xAB11, 0xAB16), + (0xAB20, 0xAB26), + (0xAB28, 0xAB2E), + (0xAB30, 0xAB6D), + (0xAB70, 0xABE4), + (0xABE6, 0xABE7), + (0xABE9, 0xABEC), + (0xABF0, 0xABF9), + (0xAC00, 0xD7A3), + (0xD7B0, 0xD7C6), + (0xD7CB, 0xD7FB), + (0xF900, 0xFA6D), + (0xFA70, 0xFAD9), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFB1D, 0xFB1D), + (0xFB1F, 0xFB36), + (0xFB38, 0xFB3C), + (0xFB3E, 0xFB3E), + (0xFB40, 0xFB41), + (0xFB43, 0xFB44), + (0xFB46, 0xFDCF), + (0xFDF0, 0xFDFF), + (0xFE10, 0xFE19), + (0xFE30, 0xFE52), + (0xFE54, 0xFE66), + (0xFE68, 0xFE6B), + (0xFE70, 0xFE74), + (0xFE76, 0xFEFC), + (0xFF01, 0xFF9D), + (0xFFA0, 0xFFBE), + (0xFFC2, 0xFFC7), + (0xFFCA, 0xFFCF), + (0xFFD2, 0xFFD7), + (0xFFDA, 0xFFDC), + (0xFFE0, 0xFFE6), + (0xFFE8, 0xFFEE), + (0xFFFC, 0xFFFD), + (0x10000, 0x1000B), + (0x1000D, 0x10026), + (0x10028, 0x1003A), + (0x1003C, 0x1003D), + (0x1003F, 0x1004D), + (0x10050, 0x1005D), + (0x10080, 0x100FA), + (0x10100, 0x10102), + (0x10107, 0x10133), + (0x10137, 0x1018E), + (0x10190, 0x1019C), + (0x101A0, 0x101A0), + (0x101D0, 0x101FC), + (0x10280, 0x1029C), + (0x102A0, 0x102D0), + (0x102E1, 0x102FB), + (0x10300, 0x10323), + (0x1032D, 0x1034A), + (0x10350, 0x10375), + (0x10380, 0x1039D), + (0x1039F, 0x103C3), + (0x103C8, 0x103D5), + (0x10400, 0x1049D), + (0x104A0, 0x104A9), + (0x104B0, 0x104D3), + (0x104D8, 0x104FB), + (0x10500, 0x10527), + (0x10530, 0x10563), + (0x1056F, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x105C0, 0x105F3), + (0x10600, 0x10736), + (0x10740, 0x10755), + (0x10760, 0x10767), + (0x10780, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BF), + (0x10800, 0x10805), + (0x10808, 0x10808), + (0x1080A, 0x10835), + (0x10837, 0x10838), + (0x1083C, 0x1083C), + (0x1083F, 0x10855), + (0x10857, 0x1089E), + (0x108A7, 0x108AF), + (0x108E0, 0x108F2), + (0x108F4, 0x108F5), + (0x108FB, 0x1091B), + (0x1091F, 0x10939), + (0x1093F, 0x10959), + (0x10980, 0x109B7), + (0x109BC, 0x109CF), + (0x109D2, 0x10A00), + (0x10A10, 0x10A13), + (0x10A15, 0x10A17), + (0x10A19, 0x10A35), + (0x10A40, 0x10A48), + (0x10A50, 0x10A58), + (0x10A60, 0x10A9F), + (0x10AC0, 0x10AE4), + (0x10AEB, 0x10AF6), + (0x10B00, 0x10B35), + (0x10B39, 0x10B55), + (0x10B58, 0x10B72), + (0x10B78, 0x10B91), + (0x10B99, 0x10B9C), + (0x10BA9, 0x10BAF), + (0x10C00, 0x10C48), + (0x10C80, 0x10CB2), + (0x10CC0, 0x10CF2), + (0x10CFA, 0x10D23), + (0x10D30, 0x10D39), + (0x10D40, 0x10D65), + (0x10D6E, 0x10D85), + (0x10D8E, 0x10D8F), + (0x10E60, 0x10E7E), + (0x10E80, 0x10EA9), + (0x10EAD, 0x10EAD), + (0x10EB0, 0x10EB1), + (0x10EC2, 0x10EC7), + (0x10EC9, 0x10ECA), + (0x10ED0, 0x10EEE), + (0x10F00, 0x10F27), + (0x10F30, 0x10F45), + (0x10F51, 0x10F59), + (0x10F70, 0x10F81), + (0x10F86, 0x10F89), + (0x10FB0, 0x10FCB), + (0x10FE0, 0x10FF6), + (0x11000, 0x11000), + (0x11002, 0x11037), + (0x11047, 0x1104D), + (0x11052, 0x1106F), + (0x11071, 0x11072), + (0x11075, 0x11075), + (0x11082, 0x110B2), + (0x110B7, 0x110B8), + (0x110BB, 0x110BC), + (0x110BE, 0x110C1), + (0x110D0, 0x110E8), + (0x110F0, 0x110F9), + (0x11103, 0x11126), + (0x1112C, 0x1112C), + (0x11136, 0x11147), + (0x11150, 0x11172), + (0x11174, 0x11176), + (0x11182, 0x111B5), + (0x111BF, 0x111BF), + (0x111C1, 0x111C8), + (0x111CD, 0x111CE), + (0x111D0, 0x111DF), + (0x111E1, 0x111F4), + (0x11200, 0x11211), + (0x11213, 0x1122E), + (0x11232, 0x11233), + (0x11238, 0x1123D), + (0x1123F, 0x11240), + (0x11280, 0x11286), + (0x11288, 0x11288), + (0x1128A, 0x1128D), + (0x1128F, 0x1129D), + (0x1129F, 0x112A9), + (0x112B0, 0x112DE), + (0x112E0, 0x112E2), + (0x112F0, 0x112F9), + (0x11302, 0x11303), + (0x11305, 0x1130C), + (0x1130F, 0x11310), + (0x11313, 0x11328), + (0x1132A, 0x11330), + (0x11332, 0x11333), + (0x11335, 0x11339), + (0x1133D, 0x1133D), + (0x1133F, 0x1133F), + (0x11341, 0x11344), + (0x11347, 0x11348), + (0x1134B, 0x1134C), + (0x11350, 0x11350), + (0x1135D, 0x11363), + (0x11380, 0x11389), + (0x1138B, 0x1138B), + (0x1138E, 0x1138E), + (0x11390, 0x113B5), + (0x113B7, 0x113B7), + (0x113B9, 0x113BA), + (0x113CA, 0x113CA), + (0x113CC, 0x113CD), + (0x113D1, 0x113D1), + (0x113D3, 0x113D5), + (0x113D7, 0x113D8), + (0x11400, 0x11437), + (0x11440, 0x11441), + (0x11445, 0x11445), + (0x11447, 0x1145B), + (0x1145D, 0x1145D), + (0x1145F, 0x11461), + (0x11480, 0x114AF), + (0x114B1, 0x114B2), + (0x114B9, 0x114B9), + (0x114BB, 0x114BC), + (0x114BE, 0x114BE), + (0x114C1, 0x114C1), + (0x114C4, 0x114C7), + (0x114D0, 0x114D9), + (0x11580, 0x115AE), + (0x115B0, 0x115B1), + (0x115B8, 0x115BB), + (0x115BE, 0x115BE), + (0x115C1, 0x115DB), + (0x11600, 0x11632), + (0x1163B, 0x1163C), + (0x1163E, 0x1163E), + (0x11641, 0x11644), + (0x11650, 0x11659), + (0x11660, 0x1166C), + (0x11680, 0x116AA), + (0x116AC, 0x116AC), + (0x116AE, 0x116AF), + (0x116B8, 0x116B9), + (0x116C0, 0x116C9), + (0x116D0, 0x116E3), + (0x11700, 0x1171A), + (0x1171E, 0x1171E), + (0x11720, 0x11721), + (0x11726, 0x11726), + (0x11730, 0x11746), + (0x11800, 0x1182E), + (0x11838, 0x11838), + (0x1183B, 0x1183B), + (0x118A0, 0x118F2), + (0x118FF, 0x11906), + (0x11909, 0x11909), + (0x1190C, 0x11913), + (0x11915, 0x11916), + (0x11918, 0x1192F), + (0x11931, 0x11935), + (0x11937, 0x11938), + (0x1193F, 0x11942), + (0x11944, 0x11946), + (0x11950, 0x11959), + (0x119A0, 0x119A7), + (0x119AA, 0x119D3), + (0x119DC, 0x119DF), + (0x119E1, 0x119E4), + (0x11A00, 0x11A00), + (0x11A0B, 0x11A32), + (0x11A39, 0x11A3A), + (0x11A3F, 0x11A46), + (0x11A50, 0x11A50), + (0x11A57, 0x11A58), + (0x11A5C, 0x11A89), + (0x11A97, 0x11A97), + (0x11A9A, 0x11AA2), + (0x11AB0, 0x11AF8), + (0x11B00, 0x11B0A), + (0x11B61, 0x11B61), + (0x11B65, 0x11B65), + (0x11B67, 0x11B67), + (0x11BC0, 0x11BE1), + (0x11BF0, 0x11BF9), + (0x11C00, 0x11C08), + (0x11C0A, 0x11C2F), + (0x11C3E, 0x11C3E), + (0x11C40, 0x11C45), + (0x11C50, 0x11C6C), + (0x11C70, 0x11C8F), + (0x11CA9, 0x11CA9), + (0x11CB1, 0x11CB1), + (0x11CB4, 0x11CB4), + (0x11D00, 0x11D06), + (0x11D08, 0x11D09), + (0x11D0B, 0x11D30), + (0x11D46, 0x11D46), + (0x11D50, 0x11D59), + (0x11D60, 0x11D65), + (0x11D67, 0x11D68), + (0x11D6A, 0x11D8E), + (0x11D93, 0x11D94), + (0x11D96, 0x11D96), + (0x11D98, 0x11D98), + (0x11DA0, 0x11DA9), + (0x11DB0, 0x11DDB), + (0x11DE0, 0x11DE9), + (0x11DF1, 0x11DF1), + (0x11EE0, 0x11EF2), + (0x11EF5, 0x11EF8), + (0x11F02, 0x11F10), + (0x11F12, 0x11F35), + (0x11F3E, 0x11F3F), + (0x11F43, 0x11F59), + (0x11FB0, 0x11FB0), + (0x11FC0, 0x11FF1), + (0x11FFF, 0x12399), + (0x12400, 0x12543), + (0x12550, 0x12686), + (0x12F90, 0x12FF2), + (0x13000, 0x1342F), + (0x13441, 0x13446), + (0x13460, 0x143FA), + (0x14400, 0x14646), + (0x16100, 0x1611D), + (0x1612A, 0x1612C), + (0x16130, 0x16139), + (0x16800, 0x16A38), + (0x16A40, 0x16A5E), + (0x16A60, 0x16A69), + (0x16A6E, 0x16ABE), + (0x16AC0, 0x16AC9), + (0x16AD0, 0x16AED), + (0x16AF5, 0x16AF5), + (0x16B00, 0x16B2F), + (0x16B37, 0x16B45), + (0x16B50, 0x16B59), + (0x16B5B, 0x16B61), + (0x16B63, 0x16B77), + (0x16B7D, 0x16B8F), + (0x16D40, 0x16D79), + (0x16E40, 0x16E9A), + (0x16EA0, 0x16EB8), + (0x16EBB, 0x16ED3), + (0x16F00, 0x16F4A), + (0x16F50, 0x16F87), + (0x16F93, 0x16F9F), + (0x16FE0, 0x16FE3), + (0x16FF2, 0x16FF6), + (0x17000, 0x18CDA), + (0x18CFF, 0x18D20), + (0x18D80, 0x18DF2), + (0x18E00, 0x19191), + (0x191A0, 0x191D2), + (0x1AFF0, 0x1AFF3), + (0x1AFF5, 0x1AFFB), + (0x1AFFD, 0x1AFFE), + (0x1B000, 0x1B128), + (0x1B132, 0x1B132), + (0x1B150, 0x1B152), + (0x1B155, 0x1B155), + (0x1B164, 0x1B168), + (0x1B170, 0x1B2FB), + (0x1BC00, 0x1BC6A), + (0x1BC70, 0x1BC7C), + (0x1BC80, 0x1BC88), + (0x1BC90, 0x1BC99), + (0x1BC9C, 0x1BC9C), + (0x1BC9F, 0x1BC9F), + (0x1CC00, 0x1CCFC), + (0x1CD00, 0x1CEB3), + (0x1CEBA, 0x1CED0), + (0x1CED2, 0x1CED4), + (0x1CEDD, 0x1CEFD), + (0x1CF50, 0x1CFC3), + (0x1D000, 0x1D0F5), + (0x1D100, 0x1D126), + (0x1D129, 0x1D164), + (0x1D16A, 0x1D16C), + (0x1D183, 0x1D184), + (0x1D18C, 0x1D1A9), + (0x1D1AE, 0x1D241), + (0x1D245, 0x1D245), + (0x1D253, 0x1D25A), + (0x1D25D, 0x1D25E), + (0x1D260, 0x1D27F), + (0x1D2C0, 0x1D2D3), + (0x1D2E0, 0x1D2F3), + (0x1D300, 0x1D356), + (0x1D360, 0x1D378), + (0x1D400, 0x1D454), + (0x1D456, 0x1D49C), + (0x1D49E, 0x1D49F), + (0x1D4A2, 0x1D4A2), + (0x1D4A5, 0x1D4A6), + (0x1D4A9, 0x1D4AC), + (0x1D4AE, 0x1D4B9), + (0x1D4BB, 0x1D4BB), + (0x1D4BD, 0x1D4C3), + (0x1D4C5, 0x1D505), + (0x1D507, 0x1D50A), + (0x1D50D, 0x1D514), + (0x1D516, 0x1D51C), + (0x1D51E, 0x1D539), + (0x1D53B, 0x1D53E), + (0x1D540, 0x1D544), + (0x1D546, 0x1D546), + (0x1D54A, 0x1D550), + (0x1D552, 0x1D6A6), + (0x1D6A8, 0x1D7CB), + (0x1D7CE, 0x1D9FF), + (0x1DA37, 0x1DA3A), + (0x1DA6D, 0x1DA74), + (0x1DA76, 0x1DA83), + (0x1DA85, 0x1DA8B), + (0x1DB00, 0x1DB1C), + (0x1DF00, 0x1DF81), + (0x1DF90, 0x1DF96), + (0x1DFCD, 0x1DFFF), + (0x1E030, 0x1E06D), + (0x1E100, 0x1E12C), + (0x1E137, 0x1E13D), + (0x1E140, 0x1E149), + (0x1E14E, 0x1E14F), + (0x1E290, 0x1E2AD), + (0x1E2C0, 0x1E2EB), + (0x1E2F0, 0x1E2F9), + (0x1E2FF, 0x1E2FF), + (0x1E4D0, 0x1E4EB), + (0x1E4F0, 0x1E4F9), + (0x1E5D0, 0x1E5ED), + (0x1E5F0, 0x1E5FA), + (0x1E5FF, 0x1E5FF), + (0x1E6C0, 0x1E6DE), + (0x1E6E0, 0x1E6E2), + (0x1E6E4, 0x1E6E5), + (0x1E6E7, 0x1E6ED), + (0x1E6F0, 0x1E6F4), + (0x1E6FE, 0x1E6FF), + (0x1E7E0, 0x1E7E6), + (0x1E7E8, 0x1E7EB), + (0x1E7ED, 0x1E7EE), + (0x1E7F0, 0x1E7FE), + (0x1E800, 0x1E8C4), + (0x1E8C7, 0x1E8CF), + (0x1E900, 0x1E943), + (0x1E94B, 0x1E94B), + (0x1E950, 0x1E959), + (0x1E95E, 0x1E95F), + (0x1EC71, 0x1ECB4), + (0x1ED01, 0x1ED3D), + (0x1EE00, 0x1EE03), + (0x1EE05, 0x1EE1F), + (0x1EE21, 0x1EE22), + (0x1EE24, 0x1EE24), + (0x1EE27, 0x1EE27), + (0x1EE29, 0x1EE32), + (0x1EE34, 0x1EE37), + (0x1EE39, 0x1EE39), + (0x1EE3B, 0x1EE3B), + (0x1EE42, 0x1EE42), + (0x1EE47, 0x1EE47), + (0x1EE49, 0x1EE49), + (0x1EE4B, 0x1EE4B), + (0x1EE4D, 0x1EE4F), + (0x1EE51, 0x1EE52), + (0x1EE54, 0x1EE54), + (0x1EE57, 0x1EE57), + (0x1EE59, 0x1EE59), + (0x1EE5B, 0x1EE5B), + (0x1EE5D, 0x1EE5D), + (0x1EE5F, 0x1EE5F), + (0x1EE61, 0x1EE62), + (0x1EE64, 0x1EE64), + (0x1EE67, 0x1EE6A), + (0x1EE6C, 0x1EE72), + (0x1EE74, 0x1EE77), + (0x1EE79, 0x1EE7C), + (0x1EE7E, 0x1EE7E), + (0x1EE80, 0x1EE89), + (0x1EE8B, 0x1EE9B), + (0x1EEA1, 0x1EEA3), + (0x1EEA5, 0x1EEA9), + (0x1EEAB, 0x1EEBB), + (0x1EEF0, 0x1EEF1), + (0x1F000, 0x1F02B), + (0x1F030, 0x1F093), + (0x1F0A0, 0x1F0AE), + (0x1F0B1, 0x1F0BF), + (0x1F0C1, 0x1F0CF), + (0x1F0D1, 0x1F0F5), + (0x1F100, 0x1F1AE), + (0x1F1E6, 0x1F202), + (0x1F210, 0x1F23B), + (0x1F240, 0x1F248), + (0x1F250, 0x1F251), + (0x1F260, 0x1F265), + (0x1F300, 0x1F6D9), + (0x1F6DC, 0x1F6EC), + (0x1F6F0, 0x1F6FC), + (0x1F700, 0x1F7DB), + (0x1F7E0, 0x1F7EB), + (0x1F7F0, 0x1F80B), + (0x1F810, 0x1F847), + (0x1F850, 0x1F859), + (0x1F860, 0x1F887), + (0x1F890, 0x1F8AD), + (0x1F8B0, 0x1F8BB), + (0x1F8C0, 0x1F8C1), + (0x1F8D0, 0x1F8D8), + (0x1F900, 0x1FA57), + (0x1FA60, 0x1FA6D), + (0x1FA70, 0x1FA7C), + (0x1FA80, 0x1FAC6), + (0x1FAC8, 0x1FAC8), + (0x1FACC, 0x1FADD), + (0x1FADF, 0x1FAEB), + (0x1FAEF, 0x1FAFA), + (0x1FB00, 0x1FB92), + (0x1FB94, 0x1FBFA), + (0x20000, 0x2A6DF), + (0x2A700, 0x2B81E), + (0x2B820, 0x2CEAD), + (0x2CEB0, 0x2EBE0), + (0x2EBF0, 0x2EE5D), + (0x2F800, 0x2FA1D), + (0x30000, 0x3134A), + (0x31350, 0x33479), + (0x3D000, 0x3FC3F), +]; + +/// The code points with the binary property Grapheme_Extend, as ranges. +pub static BINARY_GRAPHEME_EXTEND: &[(u32, u32)] = &[ + (0x300, 0x36F), + (0x483, 0x489), + (0x591, 0x5BD), + (0x5BF, 0x5BF), + (0x5C1, 0x5C2), + (0x5C4, 0x5C5), + (0x5C7, 0x5C9), + (0x610, 0x61A), + (0x64B, 0x65F), + (0x670, 0x670), + (0x6D6, 0x6DC), + (0x6DF, 0x6E4), + (0x6E7, 0x6E8), + (0x6EA, 0x6ED), + (0x711, 0x711), + (0x730, 0x74A), + (0x7A6, 0x7B0), + (0x7EB, 0x7F3), + (0x7FD, 0x7FD), + (0x816, 0x819), + (0x81B, 0x823), + (0x825, 0x827), + (0x829, 0x82D), + (0x859, 0x85B), + (0x897, 0x89F), + (0x8CA, 0x8E1), + (0x8E3, 0x902), + (0x93A, 0x93A), + (0x93C, 0x93C), + (0x941, 0x948), + (0x94D, 0x94D), + (0x951, 0x957), + (0x962, 0x963), + (0x981, 0x981), + (0x9BC, 0x9BC), + (0x9BE, 0x9BE), + (0x9C1, 0x9C4), + (0x9CD, 0x9CD), + (0x9D7, 0x9D7), + (0x9E2, 0x9E3), + (0x9FE, 0x9FE), + (0xA01, 0xA02), + (0xA3C, 0xA3C), + (0xA41, 0xA42), + (0xA47, 0xA48), + (0xA4B, 0xA4D), + (0xA51, 0xA51), + (0xA70, 0xA71), + (0xA75, 0xA75), + (0xA81, 0xA82), + (0xABC, 0xABC), + (0xAC1, 0xAC5), + (0xAC7, 0xAC8), + (0xACD, 0xACD), + (0xAE2, 0xAE3), + (0xAFA, 0xAFF), + (0xB01, 0xB01), + (0xB3C, 0xB3C), + (0xB3E, 0xB3F), + (0xB41, 0xB44), + (0xB4D, 0xB4D), + (0xB53, 0xB57), + (0xB62, 0xB63), + (0xB82, 0xB82), + (0xBBE, 0xBBE), + (0xBC0, 0xBC0), + (0xBCD, 0xBCD), + (0xBD7, 0xBD7), + (0xC00, 0xC00), + (0xC04, 0xC04), + (0xC3C, 0xC3C), + (0xC3E, 0xC40), + (0xC46, 0xC48), + (0xC4A, 0xC4D), + (0xC55, 0xC56), + (0xC62, 0xC63), + (0xC81, 0xC81), + (0xCBC, 0xCBC), + (0xCBF, 0xCC0), + (0xCC2, 0xCC2), + (0xCC6, 0xCC8), + (0xCCA, 0xCCD), + (0xCD5, 0xCD6), + (0xCE2, 0xCE3), + (0xD00, 0xD01), + (0xD3B, 0xD3C), + (0xD3E, 0xD3E), + (0xD41, 0xD44), + (0xD4D, 0xD4D), + (0xD57, 0xD57), + (0xD62, 0xD63), + (0xD81, 0xD81), + (0xDCA, 0xDCA), + (0xDCF, 0xDCF), + (0xDD2, 0xDD4), + (0xDD6, 0xDD6), + (0xDDF, 0xDDF), + (0xE31, 0xE31), + (0xE34, 0xE3A), + (0xE47, 0xE4E), + (0xEB1, 0xEB1), + (0xEB4, 0xEBC), + (0xEC8, 0xECE), + (0xF18, 0xF19), + (0xF35, 0xF35), + (0xF37, 0xF37), + (0xF39, 0xF39), + (0xF71, 0xF7E), + (0xF80, 0xF84), + (0xF86, 0xF87), + (0xF8D, 0xF97), + (0xF99, 0xFBC), + (0xFC6, 0xFC6), + (0x102D, 0x1030), + (0x1032, 0x1037), + (0x1039, 0x103A), + (0x103D, 0x103E), + (0x1058, 0x1059), + (0x105E, 0x1060), + (0x1071, 0x1074), + (0x1082, 0x1082), + (0x1085, 0x1086), + (0x108D, 0x108D), + (0x109D, 0x109D), + (0x135D, 0x135F), + (0x1712, 0x1715), + (0x1732, 0x1734), + (0x1752, 0x1753), + (0x1772, 0x1773), + (0x17B4, 0x17B5), + (0x17B7, 0x17BD), + (0x17C6, 0x17C6), + (0x17C9, 0x17D3), + (0x17DD, 0x17DD), + (0x180B, 0x180D), + (0x180F, 0x180F), + (0x1885, 0x1886), + (0x18A9, 0x18A9), + (0x1920, 0x1922), + (0x1927, 0x1928), + (0x1932, 0x1932), + (0x1939, 0x193B), + (0x1A17, 0x1A18), + (0x1A1B, 0x1A1B), + (0x1A56, 0x1A56), + (0x1A58, 0x1A5E), + (0x1A60, 0x1A60), + (0x1A62, 0x1A62), + (0x1A65, 0x1A6C), + (0x1A73, 0x1A7C), + (0x1A7F, 0x1A7F), + (0x1AB0, 0x1AF0), + (0x1B00, 0x1B03), + (0x1B34, 0x1B3D), + (0x1B42, 0x1B44), + (0x1B6B, 0x1B73), + (0x1B80, 0x1B81), + (0x1BA2, 0x1BA5), + (0x1BA8, 0x1BAD), + (0x1BE6, 0x1BE6), + (0x1BE8, 0x1BE9), + (0x1BED, 0x1BED), + (0x1BEF, 0x1BF3), + (0x1C2C, 0x1C33), + (0x1C36, 0x1C37), + (0x1CD0, 0x1CD2), + (0x1CD4, 0x1CE0), + (0x1CE2, 0x1CE8), + (0x1CED, 0x1CED), + (0x1CF4, 0x1CF4), + (0x1CF8, 0x1CF9), + (0x1DC0, 0x1DFF), + (0x200C, 0x200C), + (0x20D0, 0x20F0), + (0x2CEF, 0x2CF1), + (0x2D7F, 0x2D7F), + (0x2DE0, 0x2DFF), + (0x302A, 0x302F), + (0x3099, 0x309A), + (0xA66F, 0xA672), + (0xA674, 0xA67D), + (0xA69E, 0xA69F), + (0xA6F0, 0xA6F1), + (0xA802, 0xA802), + (0xA806, 0xA806), + (0xA80B, 0xA80B), + (0xA825, 0xA826), + (0xA82C, 0xA82C), + (0xA8C4, 0xA8C5), + (0xA8E0, 0xA8F1), + (0xA8FF, 0xA8FF), + (0xA926, 0xA92D), + (0xA947, 0xA951), + (0xA953, 0xA953), + (0xA980, 0xA982), + (0xA9B3, 0xA9B3), + (0xA9B6, 0xA9B9), + (0xA9BC, 0xA9BD), + (0xA9C0, 0xA9C0), + (0xA9E5, 0xA9E5), + (0xAA29, 0xAA2E), + (0xAA31, 0xAA32), + (0xAA35, 0xAA36), + (0xAA43, 0xAA43), + (0xAA4C, 0xAA4C), + (0xAA7C, 0xAA7C), + (0xAAB0, 0xAAB0), + (0xAAB2, 0xAAB4), + (0xAAB7, 0xAAB8), + (0xAABE, 0xAABF), + (0xAAC1, 0xAAC1), + (0xAAEC, 0xAAED), + (0xAAF6, 0xAAF6), + (0xABE5, 0xABE5), + (0xABE8, 0xABE8), + (0xABED, 0xABED), + (0xFB1E, 0xFB1E), + (0xFE00, 0xFE0F), + (0xFE20, 0xFE2F), + (0xFF9E, 0xFF9F), + (0x101FD, 0x101FD), + (0x102E0, 0x102E0), + (0x10376, 0x1037A), + (0x10A01, 0x10A03), + (0x10A05, 0x10A06), + (0x10A0C, 0x10A0F), + (0x10A38, 0x10A3A), + (0x10A3F, 0x10A3F), + (0x10AE5, 0x10AE6), + (0x10D24, 0x10D27), + (0x10D69, 0x10D6D), + (0x10EAB, 0x10EAC), + (0x10ECB, 0x10ECF), + (0x10EF0, 0x10EFF), + (0x10F46, 0x10F50), + (0x10F82, 0x10F85), + (0x11001, 0x11001), + (0x11038, 0x11046), + (0x11070, 0x11070), + (0x11073, 0x11074), + (0x1107F, 0x11081), + (0x110B3, 0x110B6), + (0x110B9, 0x110BA), + (0x110C2, 0x110C2), + (0x11100, 0x11102), + (0x11127, 0x1112B), + (0x1112D, 0x11134), + (0x11173, 0x11173), + (0x11180, 0x11181), + (0x111B6, 0x111BE), + (0x111C0, 0x111C0), + (0x111C9, 0x111CC), + (0x111CF, 0x111CF), + (0x1122F, 0x11231), + (0x11234, 0x11237), + (0x1123E, 0x1123E), + (0x11241, 0x11241), + (0x112DF, 0x112DF), + (0x112E3, 0x112EA), + (0x11300, 0x11301), + (0x1133B, 0x1133C), + (0x1133E, 0x1133E), + (0x11340, 0x11340), + (0x1134D, 0x1134D), + (0x11357, 0x11357), + (0x11366, 0x1136C), + (0x11370, 0x11374), + (0x113B8, 0x113B8), + (0x113BB, 0x113C0), + (0x113C2, 0x113C2), + (0x113C5, 0x113C5), + (0x113C7, 0x113C9), + (0x113CE, 0x113D0), + (0x113D2, 0x113D2), + (0x113E1, 0x113E2), + (0x11438, 0x1143F), + (0x11442, 0x11444), + (0x11446, 0x11446), + (0x1145E, 0x1145E), + (0x114B0, 0x114B0), + (0x114B3, 0x114B8), + (0x114BA, 0x114BA), + (0x114BD, 0x114BD), + (0x114BF, 0x114C0), + (0x114C2, 0x114C3), + (0x115AF, 0x115AF), + (0x115B2, 0x115B5), + (0x115BC, 0x115BD), + (0x115BF, 0x115C0), + (0x115DC, 0x115DD), + (0x11633, 0x1163A), + (0x1163D, 0x1163D), + (0x1163F, 0x11640), + (0x116AB, 0x116AB), + (0x116AD, 0x116AD), + (0x116B0, 0x116B7), + (0x1171D, 0x1171D), + (0x1171F, 0x1171F), + (0x11722, 0x11725), + (0x11727, 0x1172B), + (0x1182F, 0x11837), + (0x11839, 0x1183A), + (0x11930, 0x11930), + (0x1193B, 0x1193E), + (0x11943, 0x11943), + (0x119D4, 0x119D7), + (0x119DA, 0x119DB), + (0x119E0, 0x119E0), + (0x11A01, 0x11A0A), + (0x11A33, 0x11A38), + (0x11A3B, 0x11A3E), + (0x11A47, 0x11A47), + (0x11A51, 0x11A56), + (0x11A59, 0x11A5B), + (0x11A8A, 0x11A96), + (0x11A98, 0x11A99), + (0x11B60, 0x11B60), + (0x11B62, 0x11B64), + (0x11B66, 0x11B66), + (0x11C30, 0x11C36), + (0x11C38, 0x11C3D), + (0x11C3F, 0x11C3F), + (0x11C92, 0x11CA7), + (0x11CAA, 0x11CB0), + (0x11CB2, 0x11CB3), + (0x11CB5, 0x11CB6), + (0x11D31, 0x11D36), + (0x11D3A, 0x11D3A), + (0x11D3C, 0x11D3D), + (0x11D3F, 0x11D45), + (0x11D47, 0x11D47), + (0x11D90, 0x11D91), + (0x11D95, 0x11D95), + (0x11D97, 0x11D97), + (0x11DF0, 0x11DF0), + (0x11EF3, 0x11EF4), + (0x11F00, 0x11F01), + (0x11F36, 0x11F3A), + (0x11F40, 0x11F42), + (0x11F5A, 0x11F5A), + (0x13440, 0x13440), + (0x13447, 0x13455), + (0x1611E, 0x16129), + (0x1612D, 0x1612F), + (0x16AF0, 0x16AF4), + (0x16B30, 0x16B36), + (0x16F4F, 0x16F4F), + (0x16F8F, 0x16F92), + (0x16FE4, 0x16FE4), + (0x16FF0, 0x16FF1), + (0x1BC9D, 0x1BC9E), + (0x1CF00, 0x1CF2D), + (0x1CF30, 0x1CF46), + (0x1D127, 0x1D128), + (0x1D165, 0x1D169), + (0x1D16D, 0x1D172), + (0x1D17B, 0x1D182), + (0x1D185, 0x1D18B), + (0x1D1AA, 0x1D1AD), + (0x1D242, 0x1D244), + (0x1D250, 0x1D252), + (0x1D25B, 0x1D25C), + (0x1D25F, 0x1D25F), + (0x1D280, 0x1D281), + (0x1DA00, 0x1DA36), + (0x1DA3B, 0x1DA6C), + (0x1DA75, 0x1DA75), + (0x1DA84, 0x1DA84), + (0x1DA9B, 0x1DA9F), + (0x1DAA1, 0x1DAAF), + (0x1E000, 0x1E006), + (0x1E008, 0x1E018), + (0x1E01B, 0x1E021), + (0x1E023, 0x1E024), + (0x1E026, 0x1E02A), + (0x1E08F, 0x1E08F), + (0x1E130, 0x1E136), + (0x1E2AE, 0x1E2AE), + (0x1E2EC, 0x1E2EF), + (0x1E4EC, 0x1E4EF), + (0x1E5EE, 0x1E5EF), + (0x1E6E3, 0x1E6E3), + (0x1E6E6, 0x1E6E6), + (0x1E6EE, 0x1E6EF), + (0x1E6F5, 0x1E6F5), + (0x1E8D0, 0x1E8D6), + (0x1E944, 0x1E94A), + (0xE0020, 0xE007F), + (0xE0100, 0xE01EF), +]; + +/// The code points with the binary property Hex_Digit, as ranges. +pub static BINARY_HEX_DIGIT: &[(u32, u32)] = &[ + (0x30, 0x39), + (0x41, 0x46), + (0x61, 0x66), + (0xFF10, 0xFF19), + (0xFF21, 0xFF26), + (0xFF41, 0xFF46), +]; + +/// The code points with the binary property IDS_Binary_Operator, as ranges. +pub static BINARY_IDS_BINARY_OPERATOR: &[(u32, u32)] = + &[(0x2FF0, 0x2FF1), (0x2FF4, 0x2FFD), (0x31EF, 0x31EF)]; + +/// The code points with the binary property IDS_Trinary_Operator, as ranges. +pub static BINARY_IDS_TRINARY_OPERATOR: &[(u32, u32)] = &[(0x2FF2, 0x2FF3)]; + +/// The code points with the binary property ID_Continue, as ranges. +pub static BINARY_ID_CONTINUE: &[(u32, u32)] = &[ + (0x30, 0x39), + (0x41, 0x5A), + (0x5F, 0x5F), + (0x61, 0x7A), + (0xAA, 0xAA), + (0xB5, 0xB5), + (0xB7, 0xB7), + (0xBA, 0xBA), + (0xC0, 0xD6), + (0xD8, 0xF6), + (0xF8, 0x2C1), + (0x2C6, 0x2D1), + (0x2E0, 0x2E4), + (0x2EC, 0x2EC), + (0x2EE, 0x2EE), + (0x300, 0x374), + (0x376, 0x377), + (0x37A, 0x37D), + (0x37F, 0x37F), + (0x386, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x3A1), + (0x3A3, 0x3F5), + (0x3F7, 0x481), + (0x483, 0x487), + (0x48A, 0x52F), + (0x531, 0x556), + (0x558, 0x559), + (0x560, 0x588), + (0x58B, 0x58C), + (0x591, 0x5BD), + (0x5BF, 0x5BF), + (0x5C1, 0x5C2), + (0x5C4, 0x5C5), + (0x5C7, 0x5C9), + (0x5D0, 0x5EA), + (0x5EF, 0x5F2), + (0x610, 0x61A), + (0x620, 0x669), + (0x66E, 0x6D3), + (0x6D5, 0x6DC), + (0x6DF, 0x6E8), + (0x6EA, 0x6FC), + (0x6FF, 0x6FF), + (0x710, 0x74A), + (0x74D, 0x7B1), + (0x7C0, 0x7F5), + (0x7FA, 0x7FA), + (0x7FD, 0x7FD), + (0x800, 0x82D), + (0x840, 0x85B), + (0x860, 0x86A), + (0x870, 0x887), + (0x889, 0x88F), + (0x897, 0x8E1), + (0x8E3, 0x963), + (0x966, 0x96F), + (0x971, 0x983), + (0x985, 0x98C), + (0x98F, 0x990), + (0x993, 0x9A8), + (0x9AA, 0x9B0), + (0x9B2, 0x9B2), + (0x9B6, 0x9B9), + (0x9BC, 0x9C4), + (0x9C7, 0x9C8), + (0x9CB, 0x9CE), + (0x9D7, 0x9D7), + (0x9DC, 0x9DD), + (0x9DF, 0x9E3), + (0x9E6, 0x9F1), + (0x9FC, 0x9FC), + (0x9FE, 0x9FE), + (0xA01, 0xA03), + (0xA05, 0xA0A), + (0xA0F, 0xA10), + (0xA13, 0xA28), + (0xA2A, 0xA30), + (0xA32, 0xA33), + (0xA35, 0xA36), + (0xA38, 0xA39), + (0xA3C, 0xA3C), + (0xA3E, 0xA42), + (0xA47, 0xA48), + (0xA4B, 0xA4D), + (0xA51, 0xA51), + (0xA59, 0xA5C), + (0xA5E, 0xA5E), + (0xA66, 0xA75), + (0xA81, 0xA83), + (0xA85, 0xA8D), + (0xA8F, 0xA91), + (0xA93, 0xAA8), + (0xAAA, 0xAB0), + (0xAB2, 0xAB3), + (0xAB5, 0xAB9), + (0xABC, 0xAC5), + (0xAC7, 0xAC9), + (0xACB, 0xACD), + (0xAD0, 0xAD0), + (0xAE0, 0xAE3), + (0xAE6, 0xAEF), + (0xAF9, 0xAFF), + (0xB01, 0xB03), + (0xB05, 0xB0C), + (0xB0F, 0xB10), + (0xB13, 0xB28), + (0xB2A, 0xB30), + (0xB32, 0xB33), + (0xB35, 0xB39), + (0xB3C, 0xB44), + (0xB47, 0xB48), + (0xB4B, 0xB4D), + (0xB53, 0xB57), + (0xB5C, 0xB5D), + (0xB5F, 0xB63), + (0xB66, 0xB6F), + (0xB71, 0xB71), + (0xB82, 0xB83), + (0xB85, 0xB8A), + (0xB8E, 0xB90), + (0xB92, 0xB95), + (0xB99, 0xB9A), + (0xB9C, 0xB9C), + (0xB9E, 0xB9F), + (0xBA3, 0xBA4), + (0xBA8, 0xBAA), + (0xBAE, 0xBB9), + (0xBBE, 0xBC2), + (0xBC6, 0xBC8), + (0xBCA, 0xBCD), + (0xBD0, 0xBD0), + (0xBD7, 0xBD7), + (0xBE6, 0xBEF), + (0xC00, 0xC0C), + (0xC0E, 0xC10), + (0xC12, 0xC28), + (0xC2A, 0xC39), + (0xC3C, 0xC44), + (0xC46, 0xC48), + (0xC4A, 0xC4D), + (0xC55, 0xC56), + (0xC58, 0xC5A), + (0xC5C, 0xC5D), + (0xC60, 0xC63), + (0xC66, 0xC6F), + (0xC80, 0xC83), + (0xC85, 0xC8C), + (0xC8E, 0xC90), + (0xC92, 0xCA8), + (0xCAA, 0xCB3), + (0xCB5, 0xCB9), + (0xCBC, 0xCC4), + (0xCC6, 0xCC8), + (0xCCA, 0xCCD), + (0xCD5, 0xCD6), + (0xCDC, 0xCDE), + (0xCE0, 0xCE3), + (0xCE6, 0xCEF), + (0xCF1, 0xCF3), + (0xD00, 0xD0C), + (0xD0E, 0xD10), + (0xD12, 0xD44), + (0xD46, 0xD48), + (0xD4A, 0xD4E), + (0xD54, 0xD57), + (0xD5F, 0xD63), + (0xD66, 0xD6F), + (0xD7A, 0xD7F), + (0xD81, 0xD83), + (0xD85, 0xD96), + (0xD9A, 0xDB1), + (0xDB3, 0xDBB), + (0xDBD, 0xDBD), + (0xDC0, 0xDC6), + (0xDCA, 0xDCA), + (0xDCF, 0xDD4), + (0xDD6, 0xDD6), + (0xDD8, 0xDDF), + (0xDE6, 0xDEF), + (0xDF2, 0xDF3), + (0xE01, 0xE3A), + (0xE40, 0xE4E), + (0xE50, 0xE59), + (0xE81, 0xE82), + (0xE84, 0xE84), + (0xE86, 0xE8A), + (0xE8C, 0xEA3), + (0xEA5, 0xEA5), + (0xEA7, 0xEBD), + (0xEC0, 0xEC4), + (0xEC6, 0xEC6), + (0xEC8, 0xECE), + (0xED0, 0xED9), + (0xEDC, 0xEDF), + (0xF00, 0xF00), + (0xF18, 0xF19), + (0xF20, 0xF29), + (0xF35, 0xF35), + (0xF37, 0xF37), + (0xF39, 0xF39), + (0xF3E, 0xF47), + (0xF49, 0xF6C), + (0xF71, 0xF84), + (0xF86, 0xF97), + (0xF99, 0xFBC), + (0xFC6, 0xFC6), + (0x1000, 0x1049), + (0x1050, 0x109D), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x10D0, 0x10FA), + (0x10FC, 0x1248), + (0x124A, 0x124D), + (0x1250, 0x1256), + (0x1258, 0x1258), + (0x125A, 0x125D), + (0x1260, 0x1288), + (0x128A, 0x128D), + (0x1290, 0x12B0), + (0x12B2, 0x12B5), + (0x12B8, 0x12BE), + (0x12C0, 0x12C0), + (0x12C2, 0x12C5), + (0x12C8, 0x12D6), + (0x12D8, 0x1310), + (0x1312, 0x1315), + (0x1318, 0x135A), + (0x135D, 0x135F), + (0x1369, 0x1371), + (0x1380, 0x138F), + (0x13A0, 0x13F5), + (0x13F8, 0x13FD), + (0x1401, 0x166C), + (0x166F, 0x167F), + (0x1681, 0x169A), + (0x16A0, 0x16EA), + (0x16EE, 0x16F8), + (0x1700, 0x1715), + (0x171F, 0x1734), + (0x1740, 0x1753), + (0x1760, 0x176C), + (0x176E, 0x1770), + (0x1772, 0x1773), + (0x1780, 0x17D3), + (0x17D7, 0x17D7), + (0x17DC, 0x17DD), + (0x17E0, 0x17E9), + (0x180B, 0x180D), + (0x180F, 0x1819), + (0x1820, 0x1878), + (0x1880, 0x18AA), + (0x18B0, 0x18F5), + (0x1900, 0x191E), + (0x1920, 0x192B), + (0x1930, 0x193B), + (0x1946, 0x196D), + (0x1970, 0x1974), + (0x1980, 0x19AB), + (0x19B0, 0x19C9), + (0x19D0, 0x19DA), + (0x1A00, 0x1A1B), + (0x1A20, 0x1A5E), + (0x1A60, 0x1A7C), + (0x1A7F, 0x1A89), + (0x1A90, 0x1A99), + (0x1AA7, 0x1AA7), + (0x1AB0, 0x1ABD), + (0x1ABF, 0x1AF0), + (0x1B00, 0x1B4C), + (0x1B50, 0x1B59), + (0x1B6B, 0x1B73), + (0x1B80, 0x1BF3), + (0x1C00, 0x1C37), + (0x1C40, 0x1C49), + (0x1C4D, 0x1C7D), + (0x1C80, 0x1C8A), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1CD0, 0x1CD2), + (0x1CD4, 0x1CFA), + (0x1D00, 0x1F15), + (0x1F18, 0x1F1D), + (0x1F20, 0x1F45), + (0x1F48, 0x1F4D), + (0x1F50, 0x1F57), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F7D), + (0x1F80, 0x1FB4), + (0x1FB6, 0x1FBC), + (0x1FBE, 0x1FBE), + (0x1FC2, 0x1FC4), + (0x1FC6, 0x1FCC), + (0x1FD0, 0x1FD3), + (0x1FD6, 0x1FDB), + (0x1FE0, 0x1FEC), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FFC), + (0x200C, 0x200D), + (0x203F, 0x2040), + (0x2054, 0x2054), + (0x2071, 0x2071), + (0x207F, 0x207F), + (0x208F, 0x209F), + (0x20D0, 0x20DC), + (0x20E1, 0x20E1), + (0x20E5, 0x20F0), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210A, 0x2113), + (0x2115, 0x2115), + (0x2118, 0x211D), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212A, 0x2139), + (0x213C, 0x213F), + (0x2145, 0x2149), + (0x214E, 0x214E), + (0x2160, 0x2188), + (0x2C00, 0x2CE4), + (0x2CEB, 0x2CF3), + (0x2D00, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0x2D30, 0x2D67), + (0x2D6F, 0x2D6F), + (0x2D7F, 0x2D96), + (0x2DA0, 0x2DA6), + (0x2DA8, 0x2DAE), + (0x2DB0, 0x2DB6), + (0x2DB8, 0x2DBE), + (0x2DC0, 0x2DC6), + (0x2DC8, 0x2DCE), + (0x2DD0, 0x2DD6), + (0x2DD8, 0x2DDE), + (0x2DE0, 0x2DFF), + (0x3005, 0x3007), + (0x3021, 0x302F), + (0x3031, 0x3035), + (0x3038, 0x303C), + (0x3041, 0x3096), + (0x3099, 0x309F), + (0x30A1, 0x30FF), + (0x3105, 0x312F), + (0x3131, 0x318E), + (0x31A0, 0x31BF), + (0x31F0, 0x31FF), + (0x3400, 0x4DBF), + (0x4E00, 0xA48C), + (0xA4D0, 0xA4FD), + (0xA500, 0xA60C), + (0xA610, 0xA62B), + (0xA640, 0xA66F), + (0xA674, 0xA67D), + (0xA67F, 0xA6F1), + (0xA717, 0xA71F), + (0xA722, 0xA788), + (0xA78B, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F1, 0xA827), + (0xA82C, 0xA82C), + (0xA840, 0xA873), + (0xA880, 0xA8C5), + (0xA8D0, 0xA8D9), + (0xA8E0, 0xA8F7), + (0xA8FB, 0xA8FB), + (0xA8FD, 0xA92D), + (0xA930, 0xA953), + (0xA960, 0xA97C), + (0xA980, 0xA9C0), + (0xA9CF, 0xA9D9), + (0xA9E0, 0xA9FE), + (0xAA00, 0xAA36), + (0xAA40, 0xAA4D), + (0xAA50, 0xAA59), + (0xAA60, 0xAA76), + (0xAA7A, 0xAAC2), + (0xAADB, 0xAADD), + (0xAAE0, 0xAAEF), + (0xAAF2, 0xAAF6), + (0xAB01, 0xAB06), + (0xAB09, 0xAB0E), + (0xAB11, 0xAB16), + (0xAB20, 0xAB26), + (0xAB28, 0xAB2E), + (0xAB30, 0xAB5A), + (0xAB5C, 0xAB69), + (0xAB6C, 0xAB6D), + (0xAB70, 0xABEA), + (0xABEC, 0xABED), + (0xABF0, 0xABF9), + (0xAC00, 0xD7A3), + (0xD7B0, 0xD7C6), + (0xD7CB, 0xD7FB), + (0xF900, 0xFA6D), + (0xFA70, 0xFAD9), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFB1D, 0xFB28), + (0xFB2A, 0xFB36), + (0xFB38, 0xFB3C), + (0xFB3E, 0xFB3E), + (0xFB40, 0xFB41), + (0xFB43, 0xFB44), + (0xFB46, 0xFBB1), + (0xFBD3, 0xFD3D), + (0xFD50, 0xFD8F), + (0xFD92, 0xFDC7), + (0xFDF0, 0xFDFB), + (0xFE00, 0xFE0F), + (0xFE20, 0xFE2F), + (0xFE33, 0xFE34), + (0xFE4D, 0xFE4F), + (0xFE70, 0xFE74), + (0xFE76, 0xFEFC), + (0xFF10, 0xFF19), + (0xFF21, 0xFF3A), + (0xFF3F, 0xFF3F), + (0xFF41, 0xFF5A), + (0xFF65, 0xFFBE), + (0xFFC2, 0xFFC7), + (0xFFCA, 0xFFCF), + (0xFFD2, 0xFFD7), + (0xFFDA, 0xFFDC), + (0x10000, 0x1000B), + (0x1000D, 0x10026), + (0x10028, 0x1003A), + (0x1003C, 0x1003D), + (0x1003F, 0x1004D), + (0x10050, 0x1005D), + (0x10080, 0x100FA), + (0x10140, 0x10174), + (0x101FD, 0x101FD), + (0x10280, 0x1029C), + (0x102A0, 0x102D0), + (0x102E0, 0x102E0), + (0x10300, 0x1031F), + (0x1032D, 0x1034A), + (0x10350, 0x1037A), + (0x10380, 0x1039D), + (0x103A0, 0x103C3), + (0x103C8, 0x103CF), + (0x103D1, 0x103D5), + (0x10400, 0x1049D), + (0x104A0, 0x104A9), + (0x104B0, 0x104D3), + (0x104D8, 0x104FB), + (0x10500, 0x10527), + (0x10530, 0x10563), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x105C0, 0x105F3), + (0x10600, 0x10736), + (0x10740, 0x10755), + (0x10760, 0x10767), + (0x10780, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BF), + (0x10800, 0x10805), + (0x10808, 0x10808), + (0x1080A, 0x10835), + (0x10837, 0x10838), + (0x1083C, 0x1083C), + (0x1083F, 0x10855), + (0x10860, 0x10876), + (0x10880, 0x1089E), + (0x108E0, 0x108F2), + (0x108F4, 0x108F5), + (0x10900, 0x10915), + (0x10920, 0x10939), + (0x10940, 0x10959), + (0x10980, 0x109B7), + (0x109BE, 0x109BF), + (0x10A00, 0x10A03), + (0x10A05, 0x10A06), + (0x10A0C, 0x10A13), + (0x10A15, 0x10A17), + (0x10A19, 0x10A35), + (0x10A38, 0x10A3A), + (0x10A3F, 0x10A3F), + (0x10A60, 0x10A7C), + (0x10A80, 0x10A9C), + (0x10AC0, 0x10AC7), + (0x10AC9, 0x10AE6), + (0x10B00, 0x10B35), + (0x10B40, 0x10B55), + (0x10B60, 0x10B72), + (0x10B80, 0x10B91), + (0x10C00, 0x10C48), + (0x10C80, 0x10CB2), + (0x10CC0, 0x10CF2), + (0x10D00, 0x10D27), + (0x10D30, 0x10D39), + (0x10D40, 0x10D65), + (0x10D69, 0x10D6D), + (0x10D6F, 0x10D85), + (0x10E80, 0x10EA9), + (0x10EAB, 0x10EAC), + (0x10EB0, 0x10EB1), + (0x10EC2, 0x10EC7), + (0x10ECB, 0x10ECF), + (0x10ED9, 0x10EEE), + (0x10EF0, 0x10F1C), + (0x10F27, 0x10F27), + (0x10F30, 0x10F50), + (0x10F70, 0x10F85), + (0x10FB0, 0x10FC4), + (0x10FE0, 0x10FF6), + (0x11000, 0x11046), + (0x11066, 0x11075), + (0x1107F, 0x110BA), + (0x110C2, 0x110C2), + (0x110D0, 0x110E8), + (0x110F0, 0x110F9), + (0x11100, 0x11134), + (0x11136, 0x1113F), + (0x11144, 0x11147), + (0x11150, 0x11173), + (0x11176, 0x11176), + (0x11180, 0x111C4), + (0x111C9, 0x111CC), + (0x111CE, 0x111DA), + (0x111DC, 0x111DC), + (0x11200, 0x11211), + (0x11213, 0x11237), + (0x1123E, 0x11241), + (0x11280, 0x11286), + (0x11288, 0x11288), + (0x1128A, 0x1128D), + (0x1128F, 0x1129D), + (0x1129F, 0x112A8), + (0x112B0, 0x112EA), + (0x112F0, 0x112F9), + (0x11300, 0x11303), + (0x11305, 0x1130C), + (0x1130F, 0x11310), + (0x11313, 0x11328), + (0x1132A, 0x11330), + (0x11332, 0x11333), + (0x11335, 0x11339), + (0x1133B, 0x11344), + (0x11347, 0x11348), + (0x1134B, 0x1134D), + (0x11350, 0x11350), + (0x11357, 0x11357), + (0x1135D, 0x11363), + (0x11366, 0x1136C), + (0x11370, 0x11374), + (0x11380, 0x11389), + (0x1138B, 0x1138B), + (0x1138E, 0x1138E), + (0x11390, 0x113B5), + (0x113B7, 0x113C0), + (0x113C2, 0x113C2), + (0x113C5, 0x113C5), + (0x113C7, 0x113CA), + (0x113CC, 0x113D3), + (0x113E1, 0x113E2), + (0x11400, 0x1144A), + (0x11450, 0x11459), + (0x1145E, 0x11461), + (0x11480, 0x114C5), + (0x114C7, 0x114C7), + (0x114D0, 0x114D9), + (0x11580, 0x115B5), + (0x115B8, 0x115C0), + (0x115D8, 0x115DD), + (0x11600, 0x11640), + (0x11644, 0x11644), + (0x11650, 0x11659), + (0x11680, 0x116B8), + (0x116C0, 0x116C9), + (0x116D0, 0x116E3), + (0x11700, 0x1171A), + (0x1171D, 0x1172B), + (0x11730, 0x11739), + (0x11740, 0x11746), + (0x11800, 0x1183A), + (0x118A0, 0x118E9), + (0x118FF, 0x11906), + (0x11909, 0x11909), + (0x1190C, 0x11913), + (0x11915, 0x11916), + (0x11918, 0x11935), + (0x11937, 0x11938), + (0x1193B, 0x11943), + (0x11950, 0x11959), + (0x119A0, 0x119A7), + (0x119AA, 0x119D7), + (0x119DA, 0x119E1), + (0x119E3, 0x119E4), + (0x11A00, 0x11A3E), + (0x11A47, 0x11A47), + (0x11A50, 0x11A99), + (0x11A9D, 0x11A9D), + (0x11AB0, 0x11AF8), + (0x11B0A, 0x11B0A), + (0x11B60, 0x11B67), + (0x11BC0, 0x11BE0), + (0x11BF0, 0x11BF9), + (0x11C00, 0x11C08), + (0x11C0A, 0x11C36), + (0x11C38, 0x11C40), + (0x11C50, 0x11C59), + (0x11C72, 0x11C8F), + (0x11C92, 0x11CA7), + (0x11CA9, 0x11CB6), + (0x11D00, 0x11D06), + (0x11D08, 0x11D09), + (0x11D0B, 0x11D36), + (0x11D3A, 0x11D3A), + (0x11D3C, 0x11D3D), + (0x11D3F, 0x11D47), + (0x11D50, 0x11D59), + (0x11D60, 0x11D65), + (0x11D67, 0x11D68), + (0x11D6A, 0x11D8E), + (0x11D90, 0x11D91), + (0x11D93, 0x11D98), + (0x11DA0, 0x11DA9), + (0x11DB0, 0x11DDB), + (0x11DE0, 0x11DE9), + (0x11DF0, 0x11DF1), + (0x11EE0, 0x11EF6), + (0x11F00, 0x11F10), + (0x11F12, 0x11F3A), + (0x11F3E, 0x11F42), + (0x11F50, 0x11F5A), + (0x11FB0, 0x11FB0), + (0x12000, 0x12399), + (0x12400, 0x1246F), + (0x12475, 0x12543), + (0x12550, 0x12686), + (0x12F90, 0x12FF0), + (0x13000, 0x1342F), + (0x13440, 0x13455), + (0x13460, 0x143FA), + (0x14400, 0x14646), + (0x16100, 0x16139), + (0x16800, 0x16A38), + (0x16A40, 0x16A5E), + (0x16A60, 0x16A69), + (0x16A70, 0x16ABE), + (0x16AC0, 0x16AC9), + (0x16AD0, 0x16AED), + (0x16AF0, 0x16AF4), + (0x16B00, 0x16B36), + (0x16B40, 0x16B43), + (0x16B50, 0x16B59), + (0x16B63, 0x16B77), + (0x16B7D, 0x16B8F), + (0x16D40, 0x16D6C), + (0x16D70, 0x16D79), + (0x16E40, 0x16E7F), + (0x16EA0, 0x16EB8), + (0x16EBB, 0x16ED3), + (0x16F00, 0x16F4A), + (0x16F4F, 0x16F87), + (0x16F8F, 0x16F9F), + (0x16FE0, 0x16FE1), + (0x16FE3, 0x16FE4), + (0x16FF0, 0x16FF6), + (0x17000, 0x18CDA), + (0x18CFF, 0x18D20), + (0x18D80, 0x18DF2), + (0x18E00, 0x19191), + (0x191A0, 0x191D2), + (0x1AFF0, 0x1AFF3), + (0x1AFF5, 0x1AFFB), + (0x1AFFD, 0x1AFFE), + (0x1B000, 0x1B128), + (0x1B132, 0x1B132), + (0x1B150, 0x1B152), + (0x1B155, 0x1B155), + (0x1B164, 0x1B168), + (0x1B170, 0x1B2FB), + (0x1BC00, 0x1BC6A), + (0x1BC70, 0x1BC7C), + (0x1BC80, 0x1BC88), + (0x1BC90, 0x1BC99), + (0x1BC9D, 0x1BC9E), + (0x1CCF0, 0x1CCF9), + (0x1CF00, 0x1CF2D), + (0x1CF30, 0x1CF46), + (0x1D127, 0x1D128), + (0x1D165, 0x1D169), + (0x1D16D, 0x1D172), + (0x1D17B, 0x1D182), + (0x1D185, 0x1D18B), + (0x1D1AA, 0x1D1AD), + (0x1D242, 0x1D244), + (0x1D250, 0x1D252), + (0x1D25B, 0x1D25C), + (0x1D25F, 0x1D25F), + (0x1D280, 0x1D281), + (0x1D400, 0x1D454), + (0x1D456, 0x1D49C), + (0x1D49E, 0x1D49F), + (0x1D4A2, 0x1D4A2), + (0x1D4A5, 0x1D4A6), + (0x1D4A9, 0x1D4AC), + (0x1D4AE, 0x1D4B9), + (0x1D4BB, 0x1D4BB), + (0x1D4BD, 0x1D4C3), + (0x1D4C5, 0x1D505), + (0x1D507, 0x1D50A), + (0x1D50D, 0x1D514), + (0x1D516, 0x1D51C), + (0x1D51E, 0x1D539), + (0x1D53B, 0x1D53E), + (0x1D540, 0x1D544), + (0x1D546, 0x1D546), + (0x1D54A, 0x1D550), + (0x1D552, 0x1D6A6), + (0x1D6A8, 0x1D6C0), + (0x1D6C2, 0x1D6DA), + (0x1D6DC, 0x1D6FA), + (0x1D6FC, 0x1D714), + (0x1D716, 0x1D734), + (0x1D736, 0x1D74E), + (0x1D750, 0x1D76E), + (0x1D770, 0x1D788), + (0x1D78A, 0x1D7A8), + (0x1D7AA, 0x1D7C2), + (0x1D7C4, 0x1D7CB), + (0x1D7CE, 0x1D7FF), + (0x1DA00, 0x1DA36), + (0x1DA3B, 0x1DA6C), + (0x1DA75, 0x1DA75), + (0x1DA84, 0x1DA84), + (0x1DA9B, 0x1DA9F), + (0x1DAA1, 0x1DAAF), + (0x1DF00, 0x1DF81), + (0x1DF90, 0x1DF96), + (0x1DFCD, 0x1E006), + (0x1E008, 0x1E018), + (0x1E01B, 0x1E021), + (0x1E023, 0x1E024), + (0x1E026, 0x1E02A), + (0x1E030, 0x1E06D), + (0x1E08F, 0x1E08F), + (0x1E100, 0x1E12C), + (0x1E130, 0x1E13D), + (0x1E140, 0x1E149), + (0x1E14E, 0x1E14E), + (0x1E290, 0x1E2AE), + (0x1E2C0, 0x1E2F9), + (0x1E4D0, 0x1E4F9), + (0x1E5D0, 0x1E5FA), + (0x1E6C0, 0x1E6DE), + (0x1E6E0, 0x1E6F5), + (0x1E6FE, 0x1E6FF), + (0x1E7E0, 0x1E7E6), + (0x1E7E8, 0x1E7EB), + (0x1E7ED, 0x1E7EE), + (0x1E7F0, 0x1E7FE), + (0x1E800, 0x1E8C4), + (0x1E8D0, 0x1E8D6), + (0x1E900, 0x1E94B), + (0x1E950, 0x1E959), + (0x1EE00, 0x1EE03), + (0x1EE05, 0x1EE1F), + (0x1EE21, 0x1EE22), + (0x1EE24, 0x1EE24), + (0x1EE27, 0x1EE27), + (0x1EE29, 0x1EE32), + (0x1EE34, 0x1EE37), + (0x1EE39, 0x1EE39), + (0x1EE3B, 0x1EE3B), + (0x1EE42, 0x1EE42), + (0x1EE47, 0x1EE47), + (0x1EE49, 0x1EE49), + (0x1EE4B, 0x1EE4B), + (0x1EE4D, 0x1EE4F), + (0x1EE51, 0x1EE52), + (0x1EE54, 0x1EE54), + (0x1EE57, 0x1EE57), + (0x1EE59, 0x1EE59), + (0x1EE5B, 0x1EE5B), + (0x1EE5D, 0x1EE5D), + (0x1EE5F, 0x1EE5F), + (0x1EE61, 0x1EE62), + (0x1EE64, 0x1EE64), + (0x1EE67, 0x1EE6A), + (0x1EE6C, 0x1EE72), + (0x1EE74, 0x1EE77), + (0x1EE79, 0x1EE7C), + (0x1EE7E, 0x1EE7E), + (0x1EE80, 0x1EE89), + (0x1EE8B, 0x1EE9B), + (0x1EEA1, 0x1EEA3), + (0x1EEA5, 0x1EEA9), + (0x1EEAB, 0x1EEBB), + (0x1FBF0, 0x1FBF9), + (0x20000, 0x2A6DF), + (0x2A700, 0x2B81E), + (0x2B820, 0x2CEAD), + (0x2CEB0, 0x2EBE0), + (0x2EBF0, 0x2EE5D), + (0x2F800, 0x2FA1D), + (0x30000, 0x3134A), + (0x31350, 0x33479), + (0x3D000, 0x3FC3F), + (0xE0100, 0xE01EF), +]; + +/// The code points with the binary property ID_Start, as ranges. +pub static BINARY_ID_START: &[(u32, u32)] = &[ + (0x41, 0x5A), + (0x61, 0x7A), + (0xAA, 0xAA), + (0xB5, 0xB5), + (0xBA, 0xBA), + (0xC0, 0xD6), + (0xD8, 0xF6), + (0xF8, 0x2C1), + (0x2C6, 0x2D1), + (0x2E0, 0x2E4), + (0x2EC, 0x2EC), + (0x2EE, 0x2EE), + (0x370, 0x374), + (0x376, 0x377), + (0x37A, 0x37D), + (0x37F, 0x37F), + (0x386, 0x386), + (0x388, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x3A1), + (0x3A3, 0x3F5), + (0x3F7, 0x481), + (0x48A, 0x52F), + (0x531, 0x556), + (0x558, 0x559), + (0x560, 0x588), + (0x58B, 0x58C), + (0x5D0, 0x5EA), + (0x5EF, 0x5F2), + (0x620, 0x64A), + (0x66E, 0x66F), + (0x671, 0x6D3), + (0x6D5, 0x6D5), + (0x6E5, 0x6E6), + (0x6EE, 0x6EF), + (0x6FA, 0x6FC), + (0x6FF, 0x6FF), + (0x710, 0x710), + (0x712, 0x72F), + (0x74D, 0x7A5), + (0x7B1, 0x7B1), + (0x7CA, 0x7EA), + (0x7F4, 0x7F5), + (0x7FA, 0x7FA), + (0x800, 0x815), + (0x81A, 0x81A), + (0x824, 0x824), + (0x828, 0x828), + (0x840, 0x858), + (0x860, 0x86A), + (0x870, 0x887), + (0x889, 0x88F), + (0x8A0, 0x8C9), + (0x904, 0x939), + (0x93D, 0x93D), + (0x950, 0x950), + (0x958, 0x961), + (0x971, 0x980), + (0x985, 0x98C), + (0x98F, 0x990), + (0x993, 0x9A8), + (0x9AA, 0x9B0), + (0x9B2, 0x9B2), + (0x9B6, 0x9B9), + (0x9BD, 0x9BD), + (0x9CE, 0x9CE), + (0x9DC, 0x9DD), + (0x9DF, 0x9E1), + (0x9F0, 0x9F1), + (0x9FC, 0x9FC), + (0xA05, 0xA0A), + (0xA0F, 0xA10), + (0xA13, 0xA28), + (0xA2A, 0xA30), + (0xA32, 0xA33), + (0xA35, 0xA36), + (0xA38, 0xA39), + (0xA59, 0xA5C), + (0xA5E, 0xA5E), + (0xA72, 0xA74), + (0xA85, 0xA8D), + (0xA8F, 0xA91), + (0xA93, 0xAA8), + (0xAAA, 0xAB0), + (0xAB2, 0xAB3), + (0xAB5, 0xAB9), + (0xABD, 0xABD), + (0xAD0, 0xAD0), + (0xAE0, 0xAE1), + (0xAF9, 0xAF9), + (0xB05, 0xB0C), + (0xB0F, 0xB10), + (0xB13, 0xB28), + (0xB2A, 0xB30), + (0xB32, 0xB33), + (0xB35, 0xB39), + (0xB3D, 0xB3D), + (0xB5C, 0xB5D), + (0xB5F, 0xB61), + (0xB71, 0xB71), + (0xB83, 0xB83), + (0xB85, 0xB8A), + (0xB8E, 0xB90), + (0xB92, 0xB95), + (0xB99, 0xB9A), + (0xB9C, 0xB9C), + (0xB9E, 0xB9F), + (0xBA3, 0xBA4), + (0xBA8, 0xBAA), + (0xBAE, 0xBB9), + (0xBD0, 0xBD0), + (0xC05, 0xC0C), + (0xC0E, 0xC10), + (0xC12, 0xC28), + (0xC2A, 0xC39), + (0xC3D, 0xC3D), + (0xC58, 0xC5A), + (0xC5C, 0xC5D), + (0xC60, 0xC61), + (0xC80, 0xC80), + (0xC85, 0xC8C), + (0xC8E, 0xC90), + (0xC92, 0xCA8), + (0xCAA, 0xCB3), + (0xCB5, 0xCB9), + (0xCBD, 0xCBD), + (0xCDC, 0xCDE), + (0xCE0, 0xCE1), + (0xCF1, 0xCF2), + (0xD04, 0xD0C), + (0xD0E, 0xD10), + (0xD12, 0xD3A), + (0xD3D, 0xD3D), + (0xD4E, 0xD4E), + (0xD54, 0xD56), + (0xD5F, 0xD61), + (0xD7A, 0xD7F), + (0xD85, 0xD96), + (0xD9A, 0xDB1), + (0xDB3, 0xDBB), + (0xDBD, 0xDBD), + (0xDC0, 0xDC6), + (0xE01, 0xE30), + (0xE32, 0xE33), + (0xE40, 0xE46), + (0xE81, 0xE82), + (0xE84, 0xE84), + (0xE86, 0xE8A), + (0xE8C, 0xEA3), + (0xEA5, 0xEA5), + (0xEA7, 0xEB0), + (0xEB2, 0xEB3), + (0xEBD, 0xEBD), + (0xEC0, 0xEC4), + (0xEC6, 0xEC6), + (0xEDC, 0xEDF), + (0xF00, 0xF00), + (0xF40, 0xF47), + (0xF49, 0xF6C), + (0xF88, 0xF8C), + (0x1000, 0x102A), + (0x103F, 0x103F), + (0x1050, 0x1055), + (0x105A, 0x105D), + (0x1061, 0x1061), + (0x1065, 0x1066), + (0x106E, 0x1070), + (0x1075, 0x1081), + (0x108E, 0x108E), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x10D0, 0x10FA), + (0x10FC, 0x1248), + (0x124A, 0x124D), + (0x1250, 0x1256), + (0x1258, 0x1258), + (0x125A, 0x125D), + (0x1260, 0x1288), + (0x128A, 0x128D), + (0x1290, 0x12B0), + (0x12B2, 0x12B5), + (0x12B8, 0x12BE), + (0x12C0, 0x12C0), + (0x12C2, 0x12C5), + (0x12C8, 0x12D6), + (0x12D8, 0x1310), + (0x1312, 0x1315), + (0x1318, 0x135A), + (0x1380, 0x138F), + (0x13A0, 0x13F5), + (0x13F8, 0x13FD), + (0x1401, 0x166C), + (0x166F, 0x167F), + (0x1681, 0x169A), + (0x16A0, 0x16EA), + (0x16EE, 0x16F8), + (0x1700, 0x1711), + (0x171F, 0x1731), + (0x1740, 0x1751), + (0x1760, 0x176C), + (0x176E, 0x1770), + (0x1780, 0x17B3), + (0x17D7, 0x17D7), + (0x17DC, 0x17DC), + (0x1820, 0x1878), + (0x1880, 0x18A8), + (0x18AA, 0x18AA), + (0x18B0, 0x18F5), + (0x1900, 0x191E), + (0x1950, 0x196D), + (0x1970, 0x1974), + (0x1980, 0x19AB), + (0x19B0, 0x19C9), + (0x1A00, 0x1A16), + (0x1A20, 0x1A54), + (0x1AA7, 0x1AA7), + (0x1B05, 0x1B33), + (0x1B45, 0x1B4C), + (0x1B83, 0x1BA0), + (0x1BAE, 0x1BAF), + (0x1BBA, 0x1BE5), + (0x1C00, 0x1C23), + (0x1C4D, 0x1C4F), + (0x1C5A, 0x1C7D), + (0x1C80, 0x1C8A), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1CE9, 0x1CEC), + (0x1CEE, 0x1CF3), + (0x1CF5, 0x1CF6), + (0x1CFA, 0x1CFA), + (0x1D00, 0x1DBF), + (0x1E00, 0x1F15), + (0x1F18, 0x1F1D), + (0x1F20, 0x1F45), + (0x1F48, 0x1F4D), + (0x1F50, 0x1F57), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F7D), + (0x1F80, 0x1FB4), + (0x1FB6, 0x1FBC), + (0x1FBE, 0x1FBE), + (0x1FC2, 0x1FC4), + (0x1FC6, 0x1FCC), + (0x1FD0, 0x1FD3), + (0x1FD6, 0x1FDB), + (0x1FE0, 0x1FEC), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FFC), + (0x2071, 0x2071), + (0x207F, 0x207F), + (0x208F, 0x209F), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210A, 0x2113), + (0x2115, 0x2115), + (0x2118, 0x211D), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212A, 0x2139), + (0x213C, 0x213F), + (0x2145, 0x2149), + (0x214E, 0x214E), + (0x2160, 0x2188), + (0x2C00, 0x2CE4), + (0x2CEB, 0x2CEE), + (0x2CF2, 0x2CF3), + (0x2D00, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0x2D30, 0x2D67), + (0x2D6F, 0x2D6F), + (0x2D80, 0x2D96), + (0x2DA0, 0x2DA6), + (0x2DA8, 0x2DAE), + (0x2DB0, 0x2DB6), + (0x2DB8, 0x2DBE), + (0x2DC0, 0x2DC6), + (0x2DC8, 0x2DCE), + (0x2DD0, 0x2DD6), + (0x2DD8, 0x2DDE), + (0x3005, 0x3007), + (0x3021, 0x3029), + (0x3031, 0x3035), + (0x3038, 0x303C), + (0x3041, 0x3096), + (0x309B, 0x309F), + (0x30A1, 0x30FA), + (0x30FC, 0x30FF), + (0x3105, 0x312F), + (0x3131, 0x318E), + (0x31A0, 0x31BF), + (0x31F0, 0x31FF), + (0x3400, 0x4DBF), + (0x4E00, 0xA48C), + (0xA4D0, 0xA4FD), + (0xA500, 0xA60C), + (0xA610, 0xA61F), + (0xA62A, 0xA62B), + (0xA640, 0xA66E), + (0xA67F, 0xA69D), + (0xA6A0, 0xA6EF), + (0xA717, 0xA71F), + (0xA722, 0xA788), + (0xA78B, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F1, 0xA801), + (0xA803, 0xA805), + (0xA807, 0xA80A), + (0xA80C, 0xA822), + (0xA840, 0xA873), + (0xA882, 0xA8B3), + (0xA8F2, 0xA8F7), + (0xA8FB, 0xA8FB), + (0xA8FD, 0xA8FE), + (0xA90A, 0xA925), + (0xA930, 0xA946), + (0xA960, 0xA97C), + (0xA984, 0xA9B2), + (0xA9CF, 0xA9CF), + (0xA9E0, 0xA9E4), + (0xA9E6, 0xA9EF), + (0xA9FA, 0xA9FE), + (0xAA00, 0xAA28), + (0xAA40, 0xAA42), + (0xAA44, 0xAA4B), + (0xAA60, 0xAA76), + (0xAA7A, 0xAA7A), + (0xAA7E, 0xAAAF), + (0xAAB1, 0xAAB1), + (0xAAB5, 0xAAB6), + (0xAAB9, 0xAABD), + (0xAAC0, 0xAAC0), + (0xAAC2, 0xAAC2), + (0xAADB, 0xAADD), + (0xAAE0, 0xAAEA), + (0xAAF2, 0xAAF4), + (0xAB01, 0xAB06), + (0xAB09, 0xAB0E), + (0xAB11, 0xAB16), + (0xAB20, 0xAB26), + (0xAB28, 0xAB2E), + (0xAB30, 0xAB5A), + (0xAB5C, 0xAB69), + (0xAB6C, 0xAB6D), + (0xAB70, 0xABE2), + (0xAC00, 0xD7A3), + (0xD7B0, 0xD7C6), + (0xD7CB, 0xD7FB), + (0xF900, 0xFA6D), + (0xFA70, 0xFAD9), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFB1D, 0xFB1D), + (0xFB1F, 0xFB28), + (0xFB2A, 0xFB36), + (0xFB38, 0xFB3C), + (0xFB3E, 0xFB3E), + (0xFB40, 0xFB41), + (0xFB43, 0xFB44), + (0xFB46, 0xFBB1), + (0xFBD3, 0xFD3D), + (0xFD50, 0xFD8F), + (0xFD92, 0xFDC7), + (0xFDF0, 0xFDFB), + (0xFE70, 0xFE74), + (0xFE76, 0xFEFC), + (0xFF21, 0xFF3A), + (0xFF41, 0xFF5A), + (0xFF66, 0xFFBE), + (0xFFC2, 0xFFC7), + (0xFFCA, 0xFFCF), + (0xFFD2, 0xFFD7), + (0xFFDA, 0xFFDC), + (0x10000, 0x1000B), + (0x1000D, 0x10026), + (0x10028, 0x1003A), + (0x1003C, 0x1003D), + (0x1003F, 0x1004D), + (0x10050, 0x1005D), + (0x10080, 0x100FA), + (0x10140, 0x10174), + (0x10280, 0x1029C), + (0x102A0, 0x102D0), + (0x10300, 0x1031F), + (0x1032D, 0x1034A), + (0x10350, 0x10375), + (0x10380, 0x1039D), + (0x103A0, 0x103C3), + (0x103C8, 0x103CF), + (0x103D1, 0x103D5), + (0x10400, 0x1049D), + (0x104B0, 0x104D3), + (0x104D8, 0x104FB), + (0x10500, 0x10527), + (0x10530, 0x10563), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x105C0, 0x105F3), + (0x10600, 0x10736), + (0x10740, 0x10755), + (0x10760, 0x10767), + (0x10780, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BF), + (0x10800, 0x10805), + (0x10808, 0x10808), + (0x1080A, 0x10835), + (0x10837, 0x10838), + (0x1083C, 0x1083C), + (0x1083F, 0x10855), + (0x10860, 0x10876), + (0x10880, 0x1089E), + (0x108E0, 0x108F2), + (0x108F4, 0x108F5), + (0x10900, 0x10915), + (0x10920, 0x10939), + (0x10940, 0x10959), + (0x10980, 0x109B7), + (0x109BE, 0x109BF), + (0x10A00, 0x10A00), + (0x10A10, 0x10A13), + (0x10A15, 0x10A17), + (0x10A19, 0x10A35), + (0x10A60, 0x10A7C), + (0x10A80, 0x10A9C), + (0x10AC0, 0x10AC7), + (0x10AC9, 0x10AE4), + (0x10B00, 0x10B35), + (0x10B40, 0x10B55), + (0x10B60, 0x10B72), + (0x10B80, 0x10B91), + (0x10C00, 0x10C48), + (0x10C80, 0x10CB2), + (0x10CC0, 0x10CF2), + (0x10D00, 0x10D23), + (0x10D4A, 0x10D65), + (0x10D6F, 0x10D85), + (0x10E80, 0x10EA9), + (0x10EB0, 0x10EB1), + (0x10EC2, 0x10EC7), + (0x10ED9, 0x10EEE), + (0x10F00, 0x10F1C), + (0x10F27, 0x10F27), + (0x10F30, 0x10F45), + (0x10F70, 0x10F81), + (0x10FB0, 0x10FC4), + (0x10FE0, 0x10FF6), + (0x11003, 0x11037), + (0x11071, 0x11072), + (0x11075, 0x11075), + (0x11083, 0x110AF), + (0x110D0, 0x110E8), + (0x11103, 0x11126), + (0x11144, 0x11144), + (0x11147, 0x11147), + (0x11150, 0x11172), + (0x11176, 0x11176), + (0x11183, 0x111B2), + (0x111C1, 0x111C4), + (0x111DA, 0x111DA), + (0x111DC, 0x111DC), + (0x11200, 0x11211), + (0x11213, 0x1122B), + (0x1123F, 0x11240), + (0x11280, 0x11286), + (0x11288, 0x11288), + (0x1128A, 0x1128D), + (0x1128F, 0x1129D), + (0x1129F, 0x112A8), + (0x112B0, 0x112DE), + (0x11305, 0x1130C), + (0x1130F, 0x11310), + (0x11313, 0x11328), + (0x1132A, 0x11330), + (0x11332, 0x11333), + (0x11335, 0x11339), + (0x1133D, 0x1133D), + (0x11350, 0x11350), + (0x1135D, 0x11361), + (0x11380, 0x11389), + (0x1138B, 0x1138B), + (0x1138E, 0x1138E), + (0x11390, 0x113B5), + (0x113B7, 0x113B7), + (0x113D1, 0x113D1), + (0x113D3, 0x113D3), + (0x11400, 0x11434), + (0x11447, 0x1144A), + (0x1145F, 0x11461), + (0x11480, 0x114AF), + (0x114C4, 0x114C5), + (0x114C7, 0x114C7), + (0x11580, 0x115AE), + (0x115D8, 0x115DB), + (0x11600, 0x1162F), + (0x11644, 0x11644), + (0x11680, 0x116AA), + (0x116B8, 0x116B8), + (0x11700, 0x1171A), + (0x11740, 0x11746), + (0x11800, 0x1182B), + (0x118A0, 0x118DF), + (0x118FF, 0x11906), + (0x11909, 0x11909), + (0x1190C, 0x11913), + (0x11915, 0x11916), + (0x11918, 0x1192F), + (0x1193F, 0x1193F), + (0x11941, 0x11941), + (0x119A0, 0x119A7), + (0x119AA, 0x119D0), + (0x119E1, 0x119E1), + (0x119E3, 0x119E3), + (0x11A00, 0x11A00), + (0x11A0B, 0x11A32), + (0x11A3A, 0x11A3A), + (0x11A50, 0x11A50), + (0x11A5C, 0x11A89), + (0x11A9D, 0x11A9D), + (0x11AB0, 0x11AF8), + (0x11B0A, 0x11B0A), + (0x11BC0, 0x11BE0), + (0x11C00, 0x11C08), + (0x11C0A, 0x11C2E), + (0x11C40, 0x11C40), + (0x11C72, 0x11C8F), + (0x11D00, 0x11D06), + (0x11D08, 0x11D09), + (0x11D0B, 0x11D30), + (0x11D46, 0x11D46), + (0x11D60, 0x11D65), + (0x11D67, 0x11D68), + (0x11D6A, 0x11D89), + (0x11D98, 0x11D98), + (0x11DB0, 0x11DDB), + (0x11DF1, 0x11DF1), + (0x11EE0, 0x11EF2), + (0x11F02, 0x11F02), + (0x11F04, 0x11F10), + (0x11F12, 0x11F33), + (0x11FB0, 0x11FB0), + (0x12000, 0x12399), + (0x12400, 0x1246F), + (0x12475, 0x12543), + (0x12550, 0x12686), + (0x12F90, 0x12FF0), + (0x13000, 0x1342F), + (0x13441, 0x13446), + (0x13460, 0x143FA), + (0x14400, 0x14646), + (0x16100, 0x1611D), + (0x16800, 0x16A38), + (0x16A40, 0x16A5E), + (0x16A70, 0x16ABE), + (0x16AD0, 0x16AED), + (0x16B00, 0x16B2F), + (0x16B40, 0x16B43), + (0x16B63, 0x16B77), + (0x16B7D, 0x16B8F), + (0x16D40, 0x16D6C), + (0x16E40, 0x16E7F), + (0x16EA0, 0x16EB8), + (0x16EBB, 0x16ED3), + (0x16F00, 0x16F4A), + (0x16F50, 0x16F50), + (0x16F93, 0x16F9F), + (0x16FE0, 0x16FE1), + (0x16FE3, 0x16FE3), + (0x16FF2, 0x16FF6), + (0x17000, 0x18CDA), + (0x18CFF, 0x18D20), + (0x18D80, 0x18DF2), + (0x18E00, 0x19191), + (0x191A0, 0x191D2), + (0x1AFF0, 0x1AFF3), + (0x1AFF5, 0x1AFFB), + (0x1AFFD, 0x1AFFE), + (0x1B000, 0x1B128), + (0x1B132, 0x1B132), + (0x1B150, 0x1B152), + (0x1B155, 0x1B155), + (0x1B164, 0x1B168), + (0x1B170, 0x1B2FB), + (0x1BC00, 0x1BC6A), + (0x1BC70, 0x1BC7C), + (0x1BC80, 0x1BC88), + (0x1BC90, 0x1BC99), + (0x1D400, 0x1D454), + (0x1D456, 0x1D49C), + (0x1D49E, 0x1D49F), + (0x1D4A2, 0x1D4A2), + (0x1D4A5, 0x1D4A6), + (0x1D4A9, 0x1D4AC), + (0x1D4AE, 0x1D4B9), + (0x1D4BB, 0x1D4BB), + (0x1D4BD, 0x1D4C3), + (0x1D4C5, 0x1D505), + (0x1D507, 0x1D50A), + (0x1D50D, 0x1D514), + (0x1D516, 0x1D51C), + (0x1D51E, 0x1D539), + (0x1D53B, 0x1D53E), + (0x1D540, 0x1D544), + (0x1D546, 0x1D546), + (0x1D54A, 0x1D550), + (0x1D552, 0x1D6A6), + (0x1D6A8, 0x1D6C0), + (0x1D6C2, 0x1D6DA), + (0x1D6DC, 0x1D6FA), + (0x1D6FC, 0x1D714), + (0x1D716, 0x1D734), + (0x1D736, 0x1D74E), + (0x1D750, 0x1D76E), + (0x1D770, 0x1D788), + (0x1D78A, 0x1D7A8), + (0x1D7AA, 0x1D7C2), + (0x1D7C4, 0x1D7CB), + (0x1DF00, 0x1DF81), + (0x1DF90, 0x1DF96), + (0x1DFCD, 0x1DFFF), + (0x1E030, 0x1E06D), + (0x1E100, 0x1E12C), + (0x1E137, 0x1E13D), + (0x1E14E, 0x1E14E), + (0x1E290, 0x1E2AD), + (0x1E2C0, 0x1E2EB), + (0x1E4D0, 0x1E4EB), + (0x1E5D0, 0x1E5ED), + (0x1E5F0, 0x1E5F0), + (0x1E6C0, 0x1E6DE), + (0x1E6E0, 0x1E6E2), + (0x1E6E4, 0x1E6E5), + (0x1E6E7, 0x1E6ED), + (0x1E6F0, 0x1E6F4), + (0x1E6FE, 0x1E6FF), + (0x1E7E0, 0x1E7E6), + (0x1E7E8, 0x1E7EB), + (0x1E7ED, 0x1E7EE), + (0x1E7F0, 0x1E7FE), + (0x1E800, 0x1E8C4), + (0x1E900, 0x1E943), + (0x1E94B, 0x1E94B), + (0x1EE00, 0x1EE03), + (0x1EE05, 0x1EE1F), + (0x1EE21, 0x1EE22), + (0x1EE24, 0x1EE24), + (0x1EE27, 0x1EE27), + (0x1EE29, 0x1EE32), + (0x1EE34, 0x1EE37), + (0x1EE39, 0x1EE39), + (0x1EE3B, 0x1EE3B), + (0x1EE42, 0x1EE42), + (0x1EE47, 0x1EE47), + (0x1EE49, 0x1EE49), + (0x1EE4B, 0x1EE4B), + (0x1EE4D, 0x1EE4F), + (0x1EE51, 0x1EE52), + (0x1EE54, 0x1EE54), + (0x1EE57, 0x1EE57), + (0x1EE59, 0x1EE59), + (0x1EE5B, 0x1EE5B), + (0x1EE5D, 0x1EE5D), + (0x1EE5F, 0x1EE5F), + (0x1EE61, 0x1EE62), + (0x1EE64, 0x1EE64), + (0x1EE67, 0x1EE6A), + (0x1EE6C, 0x1EE72), + (0x1EE74, 0x1EE77), + (0x1EE79, 0x1EE7C), + (0x1EE7E, 0x1EE7E), + (0x1EE80, 0x1EE89), + (0x1EE8B, 0x1EE9B), + (0x1EEA1, 0x1EEA3), + (0x1EEA5, 0x1EEA9), + (0x1EEAB, 0x1EEBB), + (0x20000, 0x2A6DF), + (0x2A700, 0x2B81E), + (0x2B820, 0x2CEAD), + (0x2CEB0, 0x2EBE0), + (0x2EBF0, 0x2EE5D), + (0x2F800, 0x2FA1D), + (0x30000, 0x3134A), + (0x31350, 0x33479), + (0x3D000, 0x3FC3F), +]; + +/// The code points with the binary property Ideographic, as ranges. +pub static BINARY_IDEOGRAPHIC: &[(u32, u32)] = &[ + (0x3006, 0x3007), + (0x3021, 0x3029), + (0x3038, 0x303A), + (0x3400, 0x4DBF), + (0x4E00, 0x9FFF), + (0xF900, 0xFA6D), + (0xFA70, 0xFAD9), + (0x16FE4, 0x16FE4), + (0x16FF2, 0x16FF6), + (0x17000, 0x18CDA), + (0x18CFF, 0x18D20), + (0x18D80, 0x18DF2), + (0x18E00, 0x19191), + (0x191A0, 0x191D2), + (0x1B170, 0x1B2FB), + (0x20000, 0x2A6DF), + (0x2A700, 0x2B81E), + (0x2B820, 0x2CEAD), + (0x2CEB0, 0x2EBE0), + (0x2EBF0, 0x2EE5D), + (0x2F800, 0x2FA1D), + (0x30000, 0x3134A), + (0x31350, 0x33479), + (0x3D000, 0x3FC3F), +]; + +/// The code points with the binary property Join_Control, as ranges. +pub static BINARY_JOIN_CONTROL: &[(u32, u32)] = &[(0x200C, 0x200D)]; + +/// The code points with the binary property Logical_Order_Exception, as ranges. +pub static BINARY_LOGICAL_ORDER_EXCEPTION: &[(u32, u32)] = &[ + (0xE40, 0xE44), + (0xEC0, 0xEC4), + (0x19B5, 0x19B7), + (0x19BA, 0x19BA), + (0xAAB5, 0xAAB6), + (0xAAB9, 0xAAB9), + (0xAABB, 0xAABC), +]; + +/// The code points with the binary property Lowercase, as ranges. +pub static BINARY_LOWERCASE: &[(u32, u32)] = &[ + (0x61, 0x7A), + (0xAA, 0xAA), + (0xB5, 0xB5), + (0xBA, 0xBA), + (0xDF, 0xF6), + (0xF8, 0xFF), + (0x101, 0x101), + (0x103, 0x103), + (0x105, 0x105), + (0x107, 0x107), + (0x109, 0x109), + (0x10B, 0x10B), + (0x10D, 0x10D), + (0x10F, 0x10F), + (0x111, 0x111), + (0x113, 0x113), + (0x115, 0x115), + (0x117, 0x117), + (0x119, 0x119), + (0x11B, 0x11B), + (0x11D, 0x11D), + (0x11F, 0x11F), + (0x121, 0x121), + (0x123, 0x123), + (0x125, 0x125), + (0x127, 0x127), + (0x129, 0x129), + (0x12B, 0x12B), + (0x12D, 0x12D), + (0x12F, 0x12F), + (0x131, 0x131), + (0x133, 0x133), + (0x135, 0x135), + (0x137, 0x138), + (0x13A, 0x13A), + (0x13C, 0x13C), + (0x13E, 0x13E), + (0x140, 0x140), + (0x142, 0x142), + (0x144, 0x144), + (0x146, 0x146), + (0x148, 0x149), + (0x14B, 0x14B), + (0x14D, 0x14D), + (0x14F, 0x14F), + (0x151, 0x151), + (0x153, 0x153), + (0x155, 0x155), + (0x157, 0x157), + (0x159, 0x159), + (0x15B, 0x15B), + (0x15D, 0x15D), + (0x15F, 0x15F), + (0x161, 0x161), + (0x163, 0x163), + (0x165, 0x165), + (0x167, 0x167), + (0x169, 0x169), + (0x16B, 0x16B), + (0x16D, 0x16D), + (0x16F, 0x16F), + (0x171, 0x171), + (0x173, 0x173), + (0x175, 0x175), + (0x177, 0x177), + (0x17A, 0x17A), + (0x17C, 0x17C), + (0x17E, 0x180), + (0x183, 0x183), + (0x185, 0x185), + (0x188, 0x188), + (0x18C, 0x18D), + (0x192, 0x192), + (0x195, 0x195), + (0x199, 0x19B), + (0x19E, 0x19E), + (0x1A1, 0x1A1), + (0x1A3, 0x1A3), + (0x1A5, 0x1A5), + (0x1A8, 0x1A8), + (0x1AA, 0x1AB), + (0x1AD, 0x1AD), + (0x1B0, 0x1B0), + (0x1B4, 0x1B4), + (0x1B6, 0x1B6), + (0x1B9, 0x1BA), + (0x1BD, 0x1BF), + (0x1C6, 0x1C6), + (0x1C9, 0x1C9), + (0x1CC, 0x1CC), + (0x1CE, 0x1CE), + (0x1D0, 0x1D0), + (0x1D2, 0x1D2), + (0x1D4, 0x1D4), + (0x1D6, 0x1D6), + (0x1D8, 0x1D8), + (0x1DA, 0x1DA), + (0x1DC, 0x1DD), + (0x1DF, 0x1DF), + (0x1E1, 0x1E1), + (0x1E3, 0x1E3), + (0x1E5, 0x1E5), + (0x1E7, 0x1E7), + (0x1E9, 0x1E9), + (0x1EB, 0x1EB), + (0x1ED, 0x1ED), + (0x1EF, 0x1F0), + (0x1F3, 0x1F3), + (0x1F5, 0x1F5), + (0x1F9, 0x1F9), + (0x1FB, 0x1FB), + (0x1FD, 0x1FD), + (0x1FF, 0x1FF), + (0x201, 0x201), + (0x203, 0x203), + (0x205, 0x205), + (0x207, 0x207), + (0x209, 0x209), + (0x20B, 0x20B), + (0x20D, 0x20D), + (0x20F, 0x20F), + (0x211, 0x211), + (0x213, 0x213), + (0x215, 0x215), + (0x217, 0x217), + (0x219, 0x219), + (0x21B, 0x21B), + (0x21D, 0x21D), + (0x21F, 0x21F), + (0x221, 0x221), + (0x223, 0x223), + (0x225, 0x225), + (0x227, 0x227), + (0x229, 0x229), + (0x22B, 0x22B), + (0x22D, 0x22D), + (0x22F, 0x22F), + (0x231, 0x231), + (0x233, 0x239), + (0x23C, 0x23C), + (0x23F, 0x240), + (0x242, 0x242), + (0x247, 0x247), + (0x249, 0x249), + (0x24B, 0x24B), + (0x24D, 0x24D), + (0x24F, 0x293), + (0x296, 0x2B8), + (0x2C0, 0x2C1), + (0x2E0, 0x2E4), + (0x345, 0x345), + (0x371, 0x371), + (0x373, 0x373), + (0x377, 0x377), + (0x37A, 0x37D), + (0x390, 0x390), + (0x3AC, 0x3CE), + (0x3D0, 0x3D1), + (0x3D5, 0x3D7), + (0x3D9, 0x3D9), + (0x3DB, 0x3DB), + (0x3DD, 0x3DD), + (0x3DF, 0x3DF), + (0x3E1, 0x3E1), + (0x3E3, 0x3E3), + (0x3E5, 0x3E5), + (0x3E7, 0x3E7), + (0x3E9, 0x3E9), + (0x3EB, 0x3EB), + (0x3ED, 0x3ED), + (0x3EF, 0x3F3), + (0x3F5, 0x3F5), + (0x3F8, 0x3F8), + (0x3FB, 0x3FC), + (0x430, 0x45F), + (0x461, 0x461), + (0x463, 0x463), + (0x465, 0x465), + (0x467, 0x467), + (0x469, 0x469), + (0x46B, 0x46B), + (0x46D, 0x46D), + (0x46F, 0x46F), + (0x471, 0x471), + (0x473, 0x473), + (0x475, 0x475), + (0x477, 0x477), + (0x479, 0x479), + (0x47B, 0x47B), + (0x47D, 0x47D), + (0x47F, 0x47F), + (0x481, 0x481), + (0x48B, 0x48B), + (0x48D, 0x48D), + (0x48F, 0x48F), + (0x491, 0x491), + (0x493, 0x493), + (0x495, 0x495), + (0x497, 0x497), + (0x499, 0x499), + (0x49B, 0x49B), + (0x49D, 0x49D), + (0x49F, 0x49F), + (0x4A1, 0x4A1), + (0x4A3, 0x4A3), + (0x4A5, 0x4A5), + (0x4A7, 0x4A7), + (0x4A9, 0x4A9), + (0x4AB, 0x4AB), + (0x4AD, 0x4AD), + (0x4AF, 0x4AF), + (0x4B1, 0x4B1), + (0x4B3, 0x4B3), + (0x4B5, 0x4B5), + (0x4B7, 0x4B7), + (0x4B9, 0x4B9), + (0x4BB, 0x4BB), + (0x4BD, 0x4BD), + (0x4BF, 0x4BF), + (0x4C2, 0x4C2), + (0x4C4, 0x4C4), + (0x4C6, 0x4C6), + (0x4C8, 0x4C8), + (0x4CA, 0x4CA), + (0x4CC, 0x4CC), + (0x4CE, 0x4CF), + (0x4D1, 0x4D1), + (0x4D3, 0x4D3), + (0x4D5, 0x4D5), + (0x4D7, 0x4D7), + (0x4D9, 0x4D9), + (0x4DB, 0x4DB), + (0x4DD, 0x4DD), + (0x4DF, 0x4DF), + (0x4E1, 0x4E1), + (0x4E3, 0x4E3), + (0x4E5, 0x4E5), + (0x4E7, 0x4E7), + (0x4E9, 0x4E9), + (0x4EB, 0x4EB), + (0x4ED, 0x4ED), + (0x4EF, 0x4EF), + (0x4F1, 0x4F1), + (0x4F3, 0x4F3), + (0x4F5, 0x4F5), + (0x4F7, 0x4F7), + (0x4F9, 0x4F9), + (0x4FB, 0x4FB), + (0x4FD, 0x4FD), + (0x4FF, 0x4FF), + (0x501, 0x501), + (0x503, 0x503), + (0x505, 0x505), + (0x507, 0x507), + (0x509, 0x509), + (0x50B, 0x50B), + (0x50D, 0x50D), + (0x50F, 0x50F), + (0x511, 0x511), + (0x513, 0x513), + (0x515, 0x515), + (0x517, 0x517), + (0x519, 0x519), + (0x51B, 0x51B), + (0x51D, 0x51D), + (0x51F, 0x51F), + (0x521, 0x521), + (0x523, 0x523), + (0x525, 0x525), + (0x527, 0x527), + (0x529, 0x529), + (0x52B, 0x52B), + (0x52D, 0x52D), + (0x52F, 0x52F), + (0x558, 0x558), + (0x560, 0x588), + (0x58B, 0x58C), + (0x10D0, 0x10FA), + (0x10FC, 0x10FF), + (0x13F8, 0x13FD), + (0x1C80, 0x1C88), + (0x1C8A, 0x1C8A), + (0x1D00, 0x1DBF), + (0x1E01, 0x1E01), + (0x1E03, 0x1E03), + (0x1E05, 0x1E05), + (0x1E07, 0x1E07), + (0x1E09, 0x1E09), + (0x1E0B, 0x1E0B), + (0x1E0D, 0x1E0D), + (0x1E0F, 0x1E0F), + (0x1E11, 0x1E11), + (0x1E13, 0x1E13), + (0x1E15, 0x1E15), + (0x1E17, 0x1E17), + (0x1E19, 0x1E19), + (0x1E1B, 0x1E1B), + (0x1E1D, 0x1E1D), + (0x1E1F, 0x1E1F), + (0x1E21, 0x1E21), + (0x1E23, 0x1E23), + (0x1E25, 0x1E25), + (0x1E27, 0x1E27), + (0x1E29, 0x1E29), + (0x1E2B, 0x1E2B), + (0x1E2D, 0x1E2D), + (0x1E2F, 0x1E2F), + (0x1E31, 0x1E31), + (0x1E33, 0x1E33), + (0x1E35, 0x1E35), + (0x1E37, 0x1E37), + (0x1E39, 0x1E39), + (0x1E3B, 0x1E3B), + (0x1E3D, 0x1E3D), + (0x1E3F, 0x1E3F), + (0x1E41, 0x1E41), + (0x1E43, 0x1E43), + (0x1E45, 0x1E45), + (0x1E47, 0x1E47), + (0x1E49, 0x1E49), + (0x1E4B, 0x1E4B), + (0x1E4D, 0x1E4D), + (0x1E4F, 0x1E4F), + (0x1E51, 0x1E51), + (0x1E53, 0x1E53), + (0x1E55, 0x1E55), + (0x1E57, 0x1E57), + (0x1E59, 0x1E59), + (0x1E5B, 0x1E5B), + (0x1E5D, 0x1E5D), + (0x1E5F, 0x1E5F), + (0x1E61, 0x1E61), + (0x1E63, 0x1E63), + (0x1E65, 0x1E65), + (0x1E67, 0x1E67), + (0x1E69, 0x1E69), + (0x1E6B, 0x1E6B), + (0x1E6D, 0x1E6D), + (0x1E6F, 0x1E6F), + (0x1E71, 0x1E71), + (0x1E73, 0x1E73), + (0x1E75, 0x1E75), + (0x1E77, 0x1E77), + (0x1E79, 0x1E79), + (0x1E7B, 0x1E7B), + (0x1E7D, 0x1E7D), + (0x1E7F, 0x1E7F), + (0x1E81, 0x1E81), + (0x1E83, 0x1E83), + (0x1E85, 0x1E85), + (0x1E87, 0x1E87), + (0x1E89, 0x1E89), + (0x1E8B, 0x1E8B), + (0x1E8D, 0x1E8D), + (0x1E8F, 0x1E8F), + (0x1E91, 0x1E91), + (0x1E93, 0x1E93), + (0x1E95, 0x1E9D), + (0x1E9F, 0x1E9F), + (0x1EA1, 0x1EA1), + (0x1EA3, 0x1EA3), + (0x1EA5, 0x1EA5), + (0x1EA7, 0x1EA7), + (0x1EA9, 0x1EA9), + (0x1EAB, 0x1EAB), + (0x1EAD, 0x1EAD), + (0x1EAF, 0x1EAF), + (0x1EB1, 0x1EB1), + (0x1EB3, 0x1EB3), + (0x1EB5, 0x1EB5), + (0x1EB7, 0x1EB7), + (0x1EB9, 0x1EB9), + (0x1EBB, 0x1EBB), + (0x1EBD, 0x1EBD), + (0x1EBF, 0x1EBF), + (0x1EC1, 0x1EC1), + (0x1EC3, 0x1EC3), + (0x1EC5, 0x1EC5), + (0x1EC7, 0x1EC7), + (0x1EC9, 0x1EC9), + (0x1ECB, 0x1ECB), + (0x1ECD, 0x1ECD), + (0x1ECF, 0x1ECF), + (0x1ED1, 0x1ED1), + (0x1ED3, 0x1ED3), + (0x1ED5, 0x1ED5), + (0x1ED7, 0x1ED7), + (0x1ED9, 0x1ED9), + (0x1EDB, 0x1EDB), + (0x1EDD, 0x1EDD), + (0x1EDF, 0x1EDF), + (0x1EE1, 0x1EE1), + (0x1EE3, 0x1EE3), + (0x1EE5, 0x1EE5), + (0x1EE7, 0x1EE7), + (0x1EE9, 0x1EE9), + (0x1EEB, 0x1EEB), + (0x1EED, 0x1EED), + (0x1EEF, 0x1EEF), + (0x1EF1, 0x1EF1), + (0x1EF3, 0x1EF3), + (0x1EF5, 0x1EF5), + (0x1EF7, 0x1EF7), + (0x1EF9, 0x1EF9), + (0x1EFB, 0x1EFB), + (0x1EFD, 0x1EFD), + (0x1EFF, 0x1F07), + (0x1F10, 0x1F15), + (0x1F20, 0x1F27), + (0x1F30, 0x1F37), + (0x1F40, 0x1F45), + (0x1F50, 0x1F57), + (0x1F60, 0x1F67), + (0x1F70, 0x1F7D), + (0x1F80, 0x1F87), + (0x1F90, 0x1F97), + (0x1FA0, 0x1FA7), + (0x1FB0, 0x1FB4), + (0x1FB6, 0x1FB7), + (0x1FBE, 0x1FBE), + (0x1FC2, 0x1FC4), + (0x1FC6, 0x1FC7), + (0x1FD0, 0x1FD3), + (0x1FD6, 0x1FD7), + (0x1FE0, 0x1FE7), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FF7), + (0x2071, 0x2071), + (0x207F, 0x207F), + (0x2090, 0x209F), + (0x210A, 0x210A), + (0x210E, 0x210F), + (0x2113, 0x2113), + (0x212F, 0x212F), + (0x2134, 0x2134), + (0x2139, 0x2139), + (0x213C, 0x213D), + (0x2146, 0x2149), + (0x214E, 0x214E), + (0x2170, 0x217F), + (0x2184, 0x2184), + (0x24D0, 0x24E9), + (0x2C30, 0x2C5F), + (0x2C61, 0x2C61), + (0x2C65, 0x2C66), + (0x2C68, 0x2C68), + (0x2C6A, 0x2C6A), + (0x2C6C, 0x2C6C), + (0x2C71, 0x2C71), + (0x2C73, 0x2C74), + (0x2C76, 0x2C7D), + (0x2C81, 0x2C81), + (0x2C83, 0x2C83), + (0x2C85, 0x2C85), + (0x2C87, 0x2C87), + (0x2C89, 0x2C89), + (0x2C8B, 0x2C8B), + (0x2C8D, 0x2C8D), + (0x2C8F, 0x2C8F), + (0x2C91, 0x2C91), + (0x2C93, 0x2C93), + (0x2C95, 0x2C95), + (0x2C97, 0x2C97), + (0x2C99, 0x2C99), + (0x2C9B, 0x2C9B), + (0x2C9D, 0x2C9D), + (0x2C9F, 0x2C9F), + (0x2CA1, 0x2CA1), + (0x2CA3, 0x2CA3), + (0x2CA5, 0x2CA5), + (0x2CA7, 0x2CA7), + (0x2CA9, 0x2CA9), + (0x2CAB, 0x2CAB), + (0x2CAD, 0x2CAD), + (0x2CAF, 0x2CAF), + (0x2CB1, 0x2CB1), + (0x2CB3, 0x2CB3), + (0x2CB5, 0x2CB5), + (0x2CB7, 0x2CB7), + (0x2CB9, 0x2CB9), + (0x2CBB, 0x2CBB), + (0x2CBD, 0x2CBD), + (0x2CBF, 0x2CBF), + (0x2CC1, 0x2CC1), + (0x2CC3, 0x2CC3), + (0x2CC5, 0x2CC5), + (0x2CC7, 0x2CC7), + (0x2CC9, 0x2CC9), + (0x2CCB, 0x2CCB), + (0x2CCD, 0x2CCD), + (0x2CCF, 0x2CCF), + (0x2CD1, 0x2CD1), + (0x2CD3, 0x2CD3), + (0x2CD5, 0x2CD5), + (0x2CD7, 0x2CD7), + (0x2CD9, 0x2CD9), + (0x2CDB, 0x2CDB), + (0x2CDD, 0x2CDD), + (0x2CDF, 0x2CDF), + (0x2CE1, 0x2CE1), + (0x2CE3, 0x2CE4), + (0x2CEC, 0x2CEC), + (0x2CEE, 0x2CEE), + (0x2CF3, 0x2CF3), + (0x2D00, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0xA641, 0xA641), + (0xA643, 0xA643), + (0xA645, 0xA645), + (0xA647, 0xA647), + (0xA649, 0xA649), + (0xA64B, 0xA64B), + (0xA64D, 0xA64D), + (0xA64F, 0xA64F), + (0xA651, 0xA651), + (0xA653, 0xA653), + (0xA655, 0xA655), + (0xA657, 0xA657), + (0xA659, 0xA659), + (0xA65B, 0xA65B), + (0xA65D, 0xA65D), + (0xA65F, 0xA65F), + (0xA661, 0xA661), + (0xA663, 0xA663), + (0xA665, 0xA665), + (0xA667, 0xA667), + (0xA669, 0xA669), + (0xA66B, 0xA66B), + (0xA66D, 0xA66D), + (0xA681, 0xA681), + (0xA683, 0xA683), + (0xA685, 0xA685), + (0xA687, 0xA687), + (0xA689, 0xA689), + (0xA68B, 0xA68B), + (0xA68D, 0xA68D), + (0xA68F, 0xA68F), + (0xA691, 0xA691), + (0xA693, 0xA693), + (0xA695, 0xA695), + (0xA697, 0xA697), + (0xA699, 0xA699), + (0xA69B, 0xA69D), + (0xA723, 0xA723), + (0xA725, 0xA725), + (0xA727, 0xA727), + (0xA729, 0xA729), + (0xA72B, 0xA72B), + (0xA72D, 0xA72D), + (0xA72F, 0xA731), + (0xA733, 0xA733), + (0xA735, 0xA735), + (0xA737, 0xA737), + (0xA739, 0xA739), + (0xA73B, 0xA73B), + (0xA73D, 0xA73D), + (0xA73F, 0xA73F), + (0xA741, 0xA741), + (0xA743, 0xA743), + (0xA745, 0xA745), + (0xA747, 0xA747), + (0xA749, 0xA749), + (0xA74B, 0xA74B), + (0xA74D, 0xA74D), + (0xA74F, 0xA74F), + (0xA751, 0xA751), + (0xA753, 0xA753), + (0xA755, 0xA755), + (0xA757, 0xA757), + (0xA759, 0xA759), + (0xA75B, 0xA75B), + (0xA75D, 0xA75D), + (0xA75F, 0xA75F), + (0xA761, 0xA761), + (0xA763, 0xA763), + (0xA765, 0xA765), + (0xA767, 0xA767), + (0xA769, 0xA769), + (0xA76B, 0xA76B), + (0xA76D, 0xA76D), + (0xA76F, 0xA778), + (0xA77A, 0xA77A), + (0xA77C, 0xA77C), + (0xA77F, 0xA77F), + (0xA781, 0xA781), + (0xA783, 0xA783), + (0xA785, 0xA785), + (0xA787, 0xA787), + (0xA78C, 0xA78C), + (0xA78E, 0xA78E), + (0xA791, 0xA791), + (0xA793, 0xA795), + (0xA797, 0xA797), + (0xA799, 0xA799), + (0xA79B, 0xA79B), + (0xA79D, 0xA79D), + (0xA79F, 0xA79F), + (0xA7A1, 0xA7A1), + (0xA7A3, 0xA7A3), + (0xA7A5, 0xA7A5), + (0xA7A7, 0xA7A7), + (0xA7A9, 0xA7A9), + (0xA7AF, 0xA7AF), + (0xA7B5, 0xA7B5), + (0xA7B7, 0xA7B7), + (0xA7B9, 0xA7B9), + (0xA7BB, 0xA7BB), + (0xA7BD, 0xA7BD), + (0xA7BF, 0xA7BF), + (0xA7C1, 0xA7C1), + (0xA7C3, 0xA7C3), + (0xA7C8, 0xA7C8), + (0xA7CA, 0xA7CA), + (0xA7CD, 0xA7CD), + (0xA7CF, 0xA7CF), + (0xA7D1, 0xA7D1), + (0xA7D3, 0xA7D3), + (0xA7D5, 0xA7D5), + (0xA7D7, 0xA7D7), + (0xA7D9, 0xA7D9), + (0xA7DB, 0xA7DB), + (0xA7F1, 0xA7F4), + (0xA7F6, 0xA7F6), + (0xA7F8, 0xA7FA), + (0xAB30, 0xAB5A), + (0xAB5C, 0xAB69), + (0xAB70, 0xABBF), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFF41, 0xFF5A), + (0x10428, 0x1044F), + (0x104D8, 0x104FB), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x10780, 0x10780), + (0x10783, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BF), + (0x10CC0, 0x10CF2), + (0x10D70, 0x10D85), + (0x118C0, 0x118DF), + (0x16E60, 0x16E7F), + (0x16EBB, 0x16ED3), + (0x1D41A, 0x1D433), + (0x1D44E, 0x1D454), + (0x1D456, 0x1D467), + (0x1D482, 0x1D49B), + (0x1D4B6, 0x1D4B9), + (0x1D4BB, 0x1D4BB), + (0x1D4BD, 0x1D4C3), + (0x1D4C5, 0x1D4CF), + (0x1D4EA, 0x1D503), + (0x1D51E, 0x1D537), + (0x1D552, 0x1D56B), + (0x1D586, 0x1D59F), + (0x1D5BA, 0x1D5D3), + (0x1D5EE, 0x1D607), + (0x1D622, 0x1D63B), + (0x1D656, 0x1D66F), + (0x1D68A, 0x1D6A6), + (0x1D6C2, 0x1D6DA), + (0x1D6DC, 0x1D6E1), + (0x1D6FC, 0x1D714), + (0x1D716, 0x1D71B), + (0x1D736, 0x1D74E), + (0x1D750, 0x1D755), + (0x1D770, 0x1D788), + (0x1D78A, 0x1D78F), + (0x1D7AA, 0x1D7C2), + (0x1D7C4, 0x1D7C9), + (0x1D7CB, 0x1D7CB), + (0x1DF00, 0x1DF09), + (0x1DF0B, 0x1DF3F), + (0x1DF41, 0x1DF47), + (0x1DF49, 0x1DF49), + (0x1DF4B, 0x1DF4C), + (0x1DF4E, 0x1DF50), + (0x1DF52, 0x1DF67), + (0x1DF69, 0x1DF69), + (0x1DF6B, 0x1DF6B), + (0x1DF6D, 0x1DF6D), + (0x1DF6F, 0x1DF71), + (0x1DF73, 0x1DF73), + (0x1DF75, 0x1DF75), + (0x1DF77, 0x1DF77), + (0x1DF79, 0x1DF79), + (0x1DF7B, 0x1DF7B), + (0x1DF7D, 0x1DF7D), + (0x1DF7F, 0x1DF7F), + (0x1DF90, 0x1DF96), + (0x1DFCD, 0x1DFFF), + (0x1E030, 0x1E06D), + (0x1E922, 0x1E943), +]; + +/// The code points with the binary property Math, as ranges. +pub static BINARY_MATH: &[(u32, u32)] = &[ + (0x2B, 0x2B), + (0x3C, 0x3E), + (0x5E, 0x5E), + (0x7C, 0x7C), + (0x7E, 0x7E), + (0xAC, 0xAC), + (0xB1, 0xB1), + (0xD7, 0xD7), + (0xF7, 0xF7), + (0x3D0, 0x3D2), + (0x3D5, 0x3D5), + (0x3F0, 0x3F1), + (0x3F4, 0x3F6), + (0x606, 0x608), + (0x2016, 0x2016), + (0x2032, 0x2034), + (0x2040, 0x2040), + (0x2044, 0x2044), + (0x2052, 0x2052), + (0x2061, 0x2064), + (0x207A, 0x207E), + (0x208A, 0x208E), + (0x20D0, 0x20DC), + (0x20E1, 0x20E1), + (0x20E5, 0x20E6), + (0x20EB, 0x20EF), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210A, 0x2113), + (0x2115, 0x2115), + (0x2118, 0x211D), + (0x2124, 0x2124), + (0x2128, 0x2129), + (0x212C, 0x212D), + (0x212F, 0x2131), + (0x2133, 0x2138), + (0x213C, 0x2149), + (0x214B, 0x214B), + (0x2190, 0x21A7), + (0x21A9, 0x21AE), + (0x21B0, 0x21B1), + (0x21B6, 0x21B7), + (0x21BC, 0x21DB), + (0x21DD, 0x21DD), + (0x21E4, 0x21E5), + (0x21F4, 0x22FF), + (0x2308, 0x230B), + (0x2320, 0x2321), + (0x237C, 0x237C), + (0x239B, 0x23B5), + (0x23B7, 0x23B7), + (0x23D0, 0x23D0), + (0x23DC, 0x23E2), + (0x25A0, 0x25A1), + (0x25AE, 0x25B7), + (0x25BC, 0x25C1), + (0x25C6, 0x25C7), + (0x25CA, 0x25CB), + (0x25CF, 0x25D3), + (0x25E2, 0x25E2), + (0x25E4, 0x25E4), + (0x25E7, 0x25EC), + (0x25F8, 0x25FF), + (0x2605, 0x2606), + (0x2640, 0x2640), + (0x2642, 0x2642), + (0x2660, 0x2663), + (0x266D, 0x266F), + (0x27C0, 0x27FF), + (0x2900, 0x2AFF), + (0x2B30, 0x2B44), + (0x2B47, 0x2B4C), + (0xFB29, 0xFB29), + (0xFE61, 0xFE66), + (0xFE68, 0xFE68), + (0xFF0B, 0xFF0B), + (0xFF1C, 0xFF1E), + (0xFF3C, 0xFF3C), + (0xFF3E, 0xFF3E), + (0xFF5C, 0xFF5C), + (0xFF5E, 0xFF5E), + (0xFFE2, 0xFFE2), + (0xFFE9, 0xFFEC), + (0x10D8E, 0x10D8F), + (0x1CEDD, 0x1CEDF), + (0x1CEF0, 0x1CEFD), + (0x1D400, 0x1D454), + (0x1D456, 0x1D49C), + (0x1D49E, 0x1D49F), + (0x1D4A2, 0x1D4A2), + (0x1D4A5, 0x1D4A6), + (0x1D4A9, 0x1D4AC), + (0x1D4AE, 0x1D4B9), + (0x1D4BB, 0x1D4BB), + (0x1D4BD, 0x1D4C3), + (0x1D4C5, 0x1D505), + (0x1D507, 0x1D50A), + (0x1D50D, 0x1D514), + (0x1D516, 0x1D51C), + (0x1D51E, 0x1D539), + (0x1D53B, 0x1D53E), + (0x1D540, 0x1D544), + (0x1D546, 0x1D546), + (0x1D54A, 0x1D550), + (0x1D552, 0x1D6A6), + (0x1D6A8, 0x1D7CB), + (0x1D7CE, 0x1D7FF), + (0x1DB00, 0x1DB1C), + (0x1EE00, 0x1EE03), + (0x1EE05, 0x1EE1F), + (0x1EE21, 0x1EE22), + (0x1EE24, 0x1EE24), + (0x1EE27, 0x1EE27), + (0x1EE29, 0x1EE32), + (0x1EE34, 0x1EE37), + (0x1EE39, 0x1EE39), + (0x1EE3B, 0x1EE3B), + (0x1EE42, 0x1EE42), + (0x1EE47, 0x1EE47), + (0x1EE49, 0x1EE49), + (0x1EE4B, 0x1EE4B), + (0x1EE4D, 0x1EE4F), + (0x1EE51, 0x1EE52), + (0x1EE54, 0x1EE54), + (0x1EE57, 0x1EE57), + (0x1EE59, 0x1EE59), + (0x1EE5B, 0x1EE5B), + (0x1EE5D, 0x1EE5D), + (0x1EE5F, 0x1EE5F), + (0x1EE61, 0x1EE62), + (0x1EE64, 0x1EE64), + (0x1EE67, 0x1EE6A), + (0x1EE6C, 0x1EE72), + (0x1EE74, 0x1EE77), + (0x1EE79, 0x1EE7C), + (0x1EE7E, 0x1EE7E), + (0x1EE80, 0x1EE89), + (0x1EE8B, 0x1EE9B), + (0x1EEA1, 0x1EEA3), + (0x1EEA5, 0x1EEA9), + (0x1EEAB, 0x1EEBB), + (0x1EEF0, 0x1EEF1), + (0x1F7DB, 0x1F7DB), + (0x1F7F1, 0x1F7FF), + (0x1F8D0, 0x1F8D8), +]; + +/// The code points with the binary property Noncharacter_Code_Point, as ranges. +pub static BINARY_NONCHARACTER_CODE_POINT: &[(u32, u32)] = &[ + (0xFDD0, 0xFDEF), + (0xFFFE, 0xFFFF), + (0x1FFFE, 0x1FFFF), + (0x2FFFE, 0x2FFFF), + (0x3FFFE, 0x3FFFF), + (0x4FFFE, 0x4FFFF), + (0x5FFFE, 0x5FFFF), + (0x6FFFE, 0x6FFFF), + (0x7FFFE, 0x7FFFF), + (0x8FFFE, 0x8FFFF), + (0x9FFFE, 0x9FFFF), + (0xAFFFE, 0xAFFFF), + (0xBFFFE, 0xBFFFF), + (0xCFFFE, 0xCFFFF), + (0xDFFFE, 0xDFFFF), + (0xEFFFE, 0xEFFFF), + (0xFFFFE, 0xFFFFF), + (0x10FFFE, 0x10FFFF), +]; + +/// The code points with the binary property Pattern_Syntax, as ranges. +pub static BINARY_PATTERN_SYNTAX: &[(u32, u32)] = &[ + (0x21, 0x2F), + (0x3A, 0x40), + (0x5B, 0x5E), + (0x60, 0x60), + (0x7B, 0x7E), + (0xA1, 0xA7), + (0xA9, 0xA9), + (0xAB, 0xAC), + (0xAE, 0xAE), + (0xB0, 0xB1), + (0xB6, 0xB6), + (0xBB, 0xBB), + (0xBF, 0xBF), + (0xD7, 0xD7), + (0xF7, 0xF7), + (0x2010, 0x2027), + (0x2030, 0x203E), + (0x2041, 0x2053), + (0x2055, 0x205E), + (0x2190, 0x245F), + (0x2500, 0x2775), + (0x2794, 0x2BFF), + (0x2E00, 0x2E7F), + (0x3001, 0x3003), + (0x3008, 0x3020), + (0x3030, 0x3030), + (0xFD3E, 0xFD3F), + (0xFE45, 0xFE46), +]; + +/// The code points with the binary property Pattern_White_Space, as ranges. +pub static BINARY_PATTERN_WHITE_SPACE: &[(u32, u32)] = &[ + (0x9, 0xD), + (0x20, 0x20), + (0x85, 0x85), + (0x200E, 0x200F), + (0x2028, 0x2029), +]; + +/// The code points with the binary property Quotation_Mark, as ranges. +pub static BINARY_QUOTATION_MARK: &[(u32, u32)] = &[ + (0x22, 0x22), + (0x27, 0x27), + (0xAB, 0xAB), + (0xBB, 0xBB), + (0x2018, 0x201F), + (0x2039, 0x203A), + (0x2E42, 0x2E42), + (0x300C, 0x300F), + (0x301D, 0x301F), + (0xFE41, 0xFE44), + (0xFF02, 0xFF02), + (0xFF07, 0xFF07), + (0xFF62, 0xFF63), +]; + +/// The code points with the binary property Radical, as ranges. +pub static BINARY_RADICAL: &[(u32, u32)] = &[(0x2E80, 0x2E99), (0x2E9B, 0x2EF3), (0x2F00, 0x2FD5)]; + +/// The code points with the binary property Regional_Indicator, as ranges. +pub static BINARY_REGIONAL_INDICATOR: &[(u32, u32)] = &[(0x1F1E6, 0x1F1FF)]; + +/// The code points with the binary property Sentence_Terminal, as ranges. +pub static BINARY_SENTENCE_TERMINAL: &[(u32, u32)] = &[ + (0x21, 0x21), + (0x2E, 0x2E), + (0x3F, 0x3F), + (0x589, 0x589), + (0x61D, 0x61F), + (0x6D4, 0x6D4), + (0x700, 0x702), + (0x7F9, 0x7F9), + (0x837, 0x837), + (0x839, 0x839), + (0x83D, 0x83E), + (0x964, 0x965), + (0x104A, 0x104B), + (0x1362, 0x1362), + (0x1367, 0x1368), + (0x166E, 0x166E), + (0x1735, 0x1736), + (0x17D4, 0x17D5), + (0x1803, 0x1803), + (0x1809, 0x1809), + (0x1944, 0x1945), + (0x1AA8, 0x1AAB), + (0x1B4E, 0x1B4F), + (0x1B5A, 0x1B5B), + (0x1B5E, 0x1B5F), + (0x1B7D, 0x1B7F), + (0x1C3B, 0x1C3C), + (0x1C7E, 0x1C7F), + (0x2024, 0x2024), + (0x203C, 0x203D), + (0x2047, 0x2049), + (0x2CF9, 0x2CFB), + (0x2E2E, 0x2E2E), + (0x2E3C, 0x2E3C), + (0x2E53, 0x2E54), + (0x2E60, 0x2E61), + (0x3002, 0x3002), + (0xA4FF, 0xA4FF), + (0xA60E, 0xA60F), + (0xA6F3, 0xA6F3), + (0xA6F7, 0xA6F7), + (0xA876, 0xA877), + (0xA8CE, 0xA8CF), + (0xA92F, 0xA92F), + (0xA9C8, 0xA9C9), + (0xAA5D, 0xAA5F), + (0xAAF0, 0xAAF1), + (0xABEB, 0xABEB), + (0xFE12, 0xFE12), + (0xFE15, 0xFE16), + (0xFE52, 0xFE52), + (0xFE56, 0xFE57), + (0xFF01, 0xFF01), + (0xFF0E, 0xFF0E), + (0xFF1F, 0xFF1F), + (0xFF61, 0xFF61), + (0x10A56, 0x10A57), + (0x10F55, 0x10F59), + (0x10F86, 0x10F89), + (0x11047, 0x11048), + (0x110BE, 0x110C1), + (0x11141, 0x11143), + (0x111C5, 0x111C6), + (0x111CD, 0x111CD), + (0x111DE, 0x111DF), + (0x11238, 0x11239), + (0x1123B, 0x1123C), + (0x112A9, 0x112A9), + (0x113D4, 0x113D5), + (0x1144B, 0x1144C), + (0x115C2, 0x115C3), + (0x115C9, 0x115D7), + (0x11641, 0x11642), + (0x1173C, 0x1173E), + (0x11944, 0x11944), + (0x11946, 0x11946), + (0x11A42, 0x11A43), + (0x11A9B, 0x11A9C), + (0x11C41, 0x11C42), + (0x11EF7, 0x11EF8), + (0x11F43, 0x11F44), + (0x16A6E, 0x16A6F), + (0x16AF5, 0x16AF5), + (0x16B37, 0x16B38), + (0x16B44, 0x16B44), + (0x16D6E, 0x16D6F), + (0x16E98, 0x16E98), + (0x1BC9F, 0x1BC9F), + (0x1DA88, 0x1DA88), +]; + +/// The code points with the binary property Soft_Dotted, as ranges. +pub static BINARY_SOFT_DOTTED: &[(u32, u32)] = &[ + (0x69, 0x6A), + (0x12F, 0x12F), + (0x249, 0x249), + (0x268, 0x268), + (0x29D, 0x29D), + (0x2B2, 0x2B2), + (0x3F3, 0x3F3), + (0x456, 0x456), + (0x458, 0x458), + (0x1D62, 0x1D62), + (0x1D96, 0x1D96), + (0x1DA4, 0x1DA4), + (0x1DA8, 0x1DA8), + (0x1E2D, 0x1E2D), + (0x1ECB, 0x1ECB), + (0x2071, 0x2071), + (0x2148, 0x2149), + (0x2C7C, 0x2C7C), + (0x1D422, 0x1D423), + (0x1D456, 0x1D457), + (0x1D48A, 0x1D48B), + (0x1D4BE, 0x1D4BF), + (0x1D4F2, 0x1D4F3), + (0x1D526, 0x1D527), + (0x1D55A, 0x1D55B), + (0x1D58E, 0x1D58F), + (0x1D5C2, 0x1D5C3), + (0x1D5F6, 0x1D5F7), + (0x1D62A, 0x1D62B), + (0x1D65E, 0x1D65F), + (0x1D692, 0x1D693), + (0x1DF1A, 0x1DF1A), + (0x1DF6F, 0x1DF71), + (0x1DFD9, 0x1DFD9), + (0x1E04C, 0x1E04D), + (0x1E068, 0x1E068), +]; + +/// The code points with the binary property Terminal_Punctuation, as ranges. +pub static BINARY_TERMINAL_PUNCTUATION: &[(u32, u32)] = &[ + (0x21, 0x21), + (0x2C, 0x2C), + (0x2E, 0x2E), + (0x3A, 0x3B), + (0x3F, 0x3F), + (0x37E, 0x37E), + (0x387, 0x387), + (0x589, 0x589), + (0x5C3, 0x5C3), + (0x60C, 0x60C), + (0x61B, 0x61B), + (0x61D, 0x61F), + (0x6D4, 0x6D4), + (0x700, 0x70A), + (0x70C, 0x70C), + (0x7F8, 0x7F9), + (0x830, 0x835), + (0x837, 0x83E), + (0x85E, 0x85E), + (0x964, 0x965), + (0xE5A, 0xE5B), + (0xF08, 0xF08), + (0xF0D, 0xF12), + (0x104A, 0x104B), + (0x1361, 0x1368), + (0x166E, 0x166E), + (0x16EB, 0x16ED), + (0x1735, 0x1736), + (0x17D4, 0x17D6), + (0x17DA, 0x17DA), + (0x1802, 0x1805), + (0x1808, 0x1809), + (0x1944, 0x1945), + (0x1AA8, 0x1AAB), + (0x1B4E, 0x1B4F), + (0x1B5A, 0x1B5B), + (0x1B5D, 0x1B5F), + (0x1B7D, 0x1B7F), + (0x1C3B, 0x1C3F), + (0x1C7E, 0x1C7F), + (0x2024, 0x2024), + (0x203C, 0x203D), + (0x2047, 0x2049), + (0x2CF9, 0x2CFB), + (0x2E2E, 0x2E2E), + (0x2E3C, 0x2E3C), + (0x2E41, 0x2E41), + (0x2E4C, 0x2E4C), + (0x2E4E, 0x2E4F), + (0x2E53, 0x2E54), + (0x2E60, 0x2E61), + (0x3001, 0x3002), + (0xA4FE, 0xA4FF), + (0xA60D, 0xA60F), + (0xA6F3, 0xA6F7), + (0xA876, 0xA877), + (0xA8CE, 0xA8CF), + (0xA92F, 0xA92F), + (0xA9C7, 0xA9C9), + (0xAA5D, 0xAA5F), + (0xAADF, 0xAADF), + (0xAAF0, 0xAAF1), + (0xABEB, 0xABEB), + (0xFE12, 0xFE12), + (0xFE15, 0xFE16), + (0xFE50, 0xFE52), + (0xFE54, 0xFE57), + (0xFF01, 0xFF01), + (0xFF0C, 0xFF0C), + (0xFF0E, 0xFF0E), + (0xFF1A, 0xFF1B), + (0xFF1F, 0xFF1F), + (0xFF61, 0xFF61), + (0xFF64, 0xFF64), + (0x1039F, 0x1039F), + (0x103D0, 0x103D0), + (0x10857, 0x10857), + (0x1091F, 0x1091F), + (0x10A56, 0x10A57), + (0x10AF0, 0x10AF5), + (0x10B3A, 0x10B3F), + (0x10B99, 0x10B9C), + (0x10F55, 0x10F59), + (0x10F86, 0x10F89), + (0x11047, 0x1104D), + (0x110BE, 0x110C1), + (0x11141, 0x11143), + (0x111C5, 0x111C6), + (0x111CD, 0x111CD), + (0x111DE, 0x111DF), + (0x11238, 0x1123C), + (0x112A9, 0x112A9), + (0x113D4, 0x113D5), + (0x1144B, 0x1144D), + (0x1145A, 0x1145B), + (0x115C2, 0x115C5), + (0x115C9, 0x115D7), + (0x11641, 0x11642), + (0x1173C, 0x1173E), + (0x11944, 0x11944), + (0x11946, 0x11946), + (0x11A42, 0x11A43), + (0x11A9B, 0x11A9C), + (0x11AA1, 0x11AA2), + (0x11C41, 0x11C43), + (0x11C71, 0x11C71), + (0x11EF7, 0x11EF8), + (0x11F43, 0x11F44), + (0x12470, 0x12474), + (0x16A6E, 0x16A6F), + (0x16AF5, 0x16AF5), + (0x16B37, 0x16B39), + (0x16B44, 0x16B44), + (0x16D6E, 0x16D6F), + (0x16E97, 0x16E98), + (0x1BC9F, 0x1BC9F), + (0x1DA87, 0x1DA8A), +]; + +/// The code points with the binary property Unified_Ideograph, as ranges. +pub static BINARY_UNIFIED_IDEOGRAPH: &[(u32, u32)] = &[ + (0x3400, 0x4DBF), + (0x4E00, 0x9FFF), + (0xFA0E, 0xFA0F), + (0xFA11, 0xFA11), + (0xFA13, 0xFA14), + (0xFA1F, 0xFA1F), + (0xFA21, 0xFA21), + (0xFA23, 0xFA24), + (0xFA27, 0xFA29), + (0x20000, 0x2A6DF), + (0x2A700, 0x2B81E), + (0x2B820, 0x2CEAD), + (0x2CEB0, 0x2EBE0), + (0x2EBF0, 0x2EE5D), + (0x30000, 0x3134A), + (0x31350, 0x33479), +]; + +/// The code points with the binary property Uppercase, as ranges. +pub static BINARY_UPPERCASE: &[(u32, u32)] = &[ + (0x41, 0x5A), + (0xC0, 0xD6), + (0xD8, 0xDE), + (0x100, 0x100), + (0x102, 0x102), + (0x104, 0x104), + (0x106, 0x106), + (0x108, 0x108), + (0x10A, 0x10A), + (0x10C, 0x10C), + (0x10E, 0x10E), + (0x110, 0x110), + (0x112, 0x112), + (0x114, 0x114), + (0x116, 0x116), + (0x118, 0x118), + (0x11A, 0x11A), + (0x11C, 0x11C), + (0x11E, 0x11E), + (0x120, 0x120), + (0x122, 0x122), + (0x124, 0x124), + (0x126, 0x126), + (0x128, 0x128), + (0x12A, 0x12A), + (0x12C, 0x12C), + (0x12E, 0x12E), + (0x130, 0x130), + (0x132, 0x132), + (0x134, 0x134), + (0x136, 0x136), + (0x139, 0x139), + (0x13B, 0x13B), + (0x13D, 0x13D), + (0x13F, 0x13F), + (0x141, 0x141), + (0x143, 0x143), + (0x145, 0x145), + (0x147, 0x147), + (0x14A, 0x14A), + (0x14C, 0x14C), + (0x14E, 0x14E), + (0x150, 0x150), + (0x152, 0x152), + (0x154, 0x154), + (0x156, 0x156), + (0x158, 0x158), + (0x15A, 0x15A), + (0x15C, 0x15C), + (0x15E, 0x15E), + (0x160, 0x160), + (0x162, 0x162), + (0x164, 0x164), + (0x166, 0x166), + (0x168, 0x168), + (0x16A, 0x16A), + (0x16C, 0x16C), + (0x16E, 0x16E), + (0x170, 0x170), + (0x172, 0x172), + (0x174, 0x174), + (0x176, 0x176), + (0x178, 0x179), + (0x17B, 0x17B), + (0x17D, 0x17D), + (0x181, 0x182), + (0x184, 0x184), + (0x186, 0x187), + (0x189, 0x18B), + (0x18E, 0x191), + (0x193, 0x194), + (0x196, 0x198), + (0x19C, 0x19D), + (0x19F, 0x1A0), + (0x1A2, 0x1A2), + (0x1A4, 0x1A4), + (0x1A6, 0x1A7), + (0x1A9, 0x1A9), + (0x1AC, 0x1AC), + (0x1AE, 0x1AF), + (0x1B1, 0x1B3), + (0x1B5, 0x1B5), + (0x1B7, 0x1B8), + (0x1BC, 0x1BC), + (0x1C4, 0x1C4), + (0x1C7, 0x1C7), + (0x1CA, 0x1CA), + (0x1CD, 0x1CD), + (0x1CF, 0x1CF), + (0x1D1, 0x1D1), + (0x1D3, 0x1D3), + (0x1D5, 0x1D5), + (0x1D7, 0x1D7), + (0x1D9, 0x1D9), + (0x1DB, 0x1DB), + (0x1DE, 0x1DE), + (0x1E0, 0x1E0), + (0x1E2, 0x1E2), + (0x1E4, 0x1E4), + (0x1E6, 0x1E6), + (0x1E8, 0x1E8), + (0x1EA, 0x1EA), + (0x1EC, 0x1EC), + (0x1EE, 0x1EE), + (0x1F1, 0x1F1), + (0x1F4, 0x1F4), + (0x1F6, 0x1F8), + (0x1FA, 0x1FA), + (0x1FC, 0x1FC), + (0x1FE, 0x1FE), + (0x200, 0x200), + (0x202, 0x202), + (0x204, 0x204), + (0x206, 0x206), + (0x208, 0x208), + (0x20A, 0x20A), + (0x20C, 0x20C), + (0x20E, 0x20E), + (0x210, 0x210), + (0x212, 0x212), + (0x214, 0x214), + (0x216, 0x216), + (0x218, 0x218), + (0x21A, 0x21A), + (0x21C, 0x21C), + (0x21E, 0x21E), + (0x220, 0x220), + (0x222, 0x222), + (0x224, 0x224), + (0x226, 0x226), + (0x228, 0x228), + (0x22A, 0x22A), + (0x22C, 0x22C), + (0x22E, 0x22E), + (0x230, 0x230), + (0x232, 0x232), + (0x23A, 0x23B), + (0x23D, 0x23E), + (0x241, 0x241), + (0x243, 0x246), + (0x248, 0x248), + (0x24A, 0x24A), + (0x24C, 0x24C), + (0x24E, 0x24E), + (0x370, 0x370), + (0x372, 0x372), + (0x376, 0x376), + (0x37F, 0x37F), + (0x386, 0x386), + (0x388, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x38F), + (0x391, 0x3A1), + (0x3A3, 0x3AB), + (0x3CF, 0x3CF), + (0x3D2, 0x3D4), + (0x3D8, 0x3D8), + (0x3DA, 0x3DA), + (0x3DC, 0x3DC), + (0x3DE, 0x3DE), + (0x3E0, 0x3E0), + (0x3E2, 0x3E2), + (0x3E4, 0x3E4), + (0x3E6, 0x3E6), + (0x3E8, 0x3E8), + (0x3EA, 0x3EA), + (0x3EC, 0x3EC), + (0x3EE, 0x3EE), + (0x3F4, 0x3F4), + (0x3F7, 0x3F7), + (0x3F9, 0x3FA), + (0x3FD, 0x42F), + (0x460, 0x460), + (0x462, 0x462), + (0x464, 0x464), + (0x466, 0x466), + (0x468, 0x468), + (0x46A, 0x46A), + (0x46C, 0x46C), + (0x46E, 0x46E), + (0x470, 0x470), + (0x472, 0x472), + (0x474, 0x474), + (0x476, 0x476), + (0x478, 0x478), + (0x47A, 0x47A), + (0x47C, 0x47C), + (0x47E, 0x47E), + (0x480, 0x480), + (0x48A, 0x48A), + (0x48C, 0x48C), + (0x48E, 0x48E), + (0x490, 0x490), + (0x492, 0x492), + (0x494, 0x494), + (0x496, 0x496), + (0x498, 0x498), + (0x49A, 0x49A), + (0x49C, 0x49C), + (0x49E, 0x49E), + (0x4A0, 0x4A0), + (0x4A2, 0x4A2), + (0x4A4, 0x4A4), + (0x4A6, 0x4A6), + (0x4A8, 0x4A8), + (0x4AA, 0x4AA), + (0x4AC, 0x4AC), + (0x4AE, 0x4AE), + (0x4B0, 0x4B0), + (0x4B2, 0x4B2), + (0x4B4, 0x4B4), + (0x4B6, 0x4B6), + (0x4B8, 0x4B8), + (0x4BA, 0x4BA), + (0x4BC, 0x4BC), + (0x4BE, 0x4BE), + (0x4C0, 0x4C1), + (0x4C3, 0x4C3), + (0x4C5, 0x4C5), + (0x4C7, 0x4C7), + (0x4C9, 0x4C9), + (0x4CB, 0x4CB), + (0x4CD, 0x4CD), + (0x4D0, 0x4D0), + (0x4D2, 0x4D2), + (0x4D4, 0x4D4), + (0x4D6, 0x4D6), + (0x4D8, 0x4D8), + (0x4DA, 0x4DA), + (0x4DC, 0x4DC), + (0x4DE, 0x4DE), + (0x4E0, 0x4E0), + (0x4E2, 0x4E2), + (0x4E4, 0x4E4), + (0x4E6, 0x4E6), + (0x4E8, 0x4E8), + (0x4EA, 0x4EA), + (0x4EC, 0x4EC), + (0x4EE, 0x4EE), + (0x4F0, 0x4F0), + (0x4F2, 0x4F2), + (0x4F4, 0x4F4), + (0x4F6, 0x4F6), + (0x4F8, 0x4F8), + (0x4FA, 0x4FA), + (0x4FC, 0x4FC), + (0x4FE, 0x4FE), + (0x500, 0x500), + (0x502, 0x502), + (0x504, 0x504), + (0x506, 0x506), + (0x508, 0x508), + (0x50A, 0x50A), + (0x50C, 0x50C), + (0x50E, 0x50E), + (0x510, 0x510), + (0x512, 0x512), + (0x514, 0x514), + (0x516, 0x516), + (0x518, 0x518), + (0x51A, 0x51A), + (0x51C, 0x51C), + (0x51E, 0x51E), + (0x520, 0x520), + (0x522, 0x522), + (0x524, 0x524), + (0x526, 0x526), + (0x528, 0x528), + (0x52A, 0x52A), + (0x52C, 0x52C), + (0x52E, 0x52E), + (0x531, 0x556), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x13A0, 0x13F5), + (0x1C89, 0x1C89), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1E00, 0x1E00), + (0x1E02, 0x1E02), + (0x1E04, 0x1E04), + (0x1E06, 0x1E06), + (0x1E08, 0x1E08), + (0x1E0A, 0x1E0A), + (0x1E0C, 0x1E0C), + (0x1E0E, 0x1E0E), + (0x1E10, 0x1E10), + (0x1E12, 0x1E12), + (0x1E14, 0x1E14), + (0x1E16, 0x1E16), + (0x1E18, 0x1E18), + (0x1E1A, 0x1E1A), + (0x1E1C, 0x1E1C), + (0x1E1E, 0x1E1E), + (0x1E20, 0x1E20), + (0x1E22, 0x1E22), + (0x1E24, 0x1E24), + (0x1E26, 0x1E26), + (0x1E28, 0x1E28), + (0x1E2A, 0x1E2A), + (0x1E2C, 0x1E2C), + (0x1E2E, 0x1E2E), + (0x1E30, 0x1E30), + (0x1E32, 0x1E32), + (0x1E34, 0x1E34), + (0x1E36, 0x1E36), + (0x1E38, 0x1E38), + (0x1E3A, 0x1E3A), + (0x1E3C, 0x1E3C), + (0x1E3E, 0x1E3E), + (0x1E40, 0x1E40), + (0x1E42, 0x1E42), + (0x1E44, 0x1E44), + (0x1E46, 0x1E46), + (0x1E48, 0x1E48), + (0x1E4A, 0x1E4A), + (0x1E4C, 0x1E4C), + (0x1E4E, 0x1E4E), + (0x1E50, 0x1E50), + (0x1E52, 0x1E52), + (0x1E54, 0x1E54), + (0x1E56, 0x1E56), + (0x1E58, 0x1E58), + (0x1E5A, 0x1E5A), + (0x1E5C, 0x1E5C), + (0x1E5E, 0x1E5E), + (0x1E60, 0x1E60), + (0x1E62, 0x1E62), + (0x1E64, 0x1E64), + (0x1E66, 0x1E66), + (0x1E68, 0x1E68), + (0x1E6A, 0x1E6A), + (0x1E6C, 0x1E6C), + (0x1E6E, 0x1E6E), + (0x1E70, 0x1E70), + (0x1E72, 0x1E72), + (0x1E74, 0x1E74), + (0x1E76, 0x1E76), + (0x1E78, 0x1E78), + (0x1E7A, 0x1E7A), + (0x1E7C, 0x1E7C), + (0x1E7E, 0x1E7E), + (0x1E80, 0x1E80), + (0x1E82, 0x1E82), + (0x1E84, 0x1E84), + (0x1E86, 0x1E86), + (0x1E88, 0x1E88), + (0x1E8A, 0x1E8A), + (0x1E8C, 0x1E8C), + (0x1E8E, 0x1E8E), + (0x1E90, 0x1E90), + (0x1E92, 0x1E92), + (0x1E94, 0x1E94), + (0x1E9E, 0x1E9E), + (0x1EA0, 0x1EA0), + (0x1EA2, 0x1EA2), + (0x1EA4, 0x1EA4), + (0x1EA6, 0x1EA6), + (0x1EA8, 0x1EA8), + (0x1EAA, 0x1EAA), + (0x1EAC, 0x1EAC), + (0x1EAE, 0x1EAE), + (0x1EB0, 0x1EB0), + (0x1EB2, 0x1EB2), + (0x1EB4, 0x1EB4), + (0x1EB6, 0x1EB6), + (0x1EB8, 0x1EB8), + (0x1EBA, 0x1EBA), + (0x1EBC, 0x1EBC), + (0x1EBE, 0x1EBE), + (0x1EC0, 0x1EC0), + (0x1EC2, 0x1EC2), + (0x1EC4, 0x1EC4), + (0x1EC6, 0x1EC6), + (0x1EC8, 0x1EC8), + (0x1ECA, 0x1ECA), + (0x1ECC, 0x1ECC), + (0x1ECE, 0x1ECE), + (0x1ED0, 0x1ED0), + (0x1ED2, 0x1ED2), + (0x1ED4, 0x1ED4), + (0x1ED6, 0x1ED6), + (0x1ED8, 0x1ED8), + (0x1EDA, 0x1EDA), + (0x1EDC, 0x1EDC), + (0x1EDE, 0x1EDE), + (0x1EE0, 0x1EE0), + (0x1EE2, 0x1EE2), + (0x1EE4, 0x1EE4), + (0x1EE6, 0x1EE6), + (0x1EE8, 0x1EE8), + (0x1EEA, 0x1EEA), + (0x1EEC, 0x1EEC), + (0x1EEE, 0x1EEE), + (0x1EF0, 0x1EF0), + (0x1EF2, 0x1EF2), + (0x1EF4, 0x1EF4), + (0x1EF6, 0x1EF6), + (0x1EF8, 0x1EF8), + (0x1EFA, 0x1EFA), + (0x1EFC, 0x1EFC), + (0x1EFE, 0x1EFE), + (0x1F08, 0x1F0F), + (0x1F18, 0x1F1D), + (0x1F28, 0x1F2F), + (0x1F38, 0x1F3F), + (0x1F48, 0x1F4D), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F5F), + (0x1F68, 0x1F6F), + (0x1FB8, 0x1FBB), + (0x1FC8, 0x1FCB), + (0x1FD8, 0x1FDB), + (0x1FE8, 0x1FEC), + (0x1FF8, 0x1FFB), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210B, 0x210D), + (0x2110, 0x2112), + (0x2115, 0x2115), + (0x2119, 0x211D), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212A, 0x212D), + (0x2130, 0x2133), + (0x213E, 0x213F), + (0x2145, 0x2145), + (0x2160, 0x216F), + (0x2183, 0x2183), + (0x24B6, 0x24CF), + (0x2C00, 0x2C2F), + (0x2C60, 0x2C60), + (0x2C62, 0x2C64), + (0x2C67, 0x2C67), + (0x2C69, 0x2C69), + (0x2C6B, 0x2C6B), + (0x2C6D, 0x2C70), + (0x2C72, 0x2C72), + (0x2C75, 0x2C75), + (0x2C7E, 0x2C80), + (0x2C82, 0x2C82), + (0x2C84, 0x2C84), + (0x2C86, 0x2C86), + (0x2C88, 0x2C88), + (0x2C8A, 0x2C8A), + (0x2C8C, 0x2C8C), + (0x2C8E, 0x2C8E), + (0x2C90, 0x2C90), + (0x2C92, 0x2C92), + (0x2C94, 0x2C94), + (0x2C96, 0x2C96), + (0x2C98, 0x2C98), + (0x2C9A, 0x2C9A), + (0x2C9C, 0x2C9C), + (0x2C9E, 0x2C9E), + (0x2CA0, 0x2CA0), + (0x2CA2, 0x2CA2), + (0x2CA4, 0x2CA4), + (0x2CA6, 0x2CA6), + (0x2CA8, 0x2CA8), + (0x2CAA, 0x2CAA), + (0x2CAC, 0x2CAC), + (0x2CAE, 0x2CAE), + (0x2CB0, 0x2CB0), + (0x2CB2, 0x2CB2), + (0x2CB4, 0x2CB4), + (0x2CB6, 0x2CB6), + (0x2CB8, 0x2CB8), + (0x2CBA, 0x2CBA), + (0x2CBC, 0x2CBC), + (0x2CBE, 0x2CBE), + (0x2CC0, 0x2CC0), + (0x2CC2, 0x2CC2), + (0x2CC4, 0x2CC4), + (0x2CC6, 0x2CC6), + (0x2CC8, 0x2CC8), + (0x2CCA, 0x2CCA), + (0x2CCC, 0x2CCC), + (0x2CCE, 0x2CCE), + (0x2CD0, 0x2CD0), + (0x2CD2, 0x2CD2), + (0x2CD4, 0x2CD4), + (0x2CD6, 0x2CD6), + (0x2CD8, 0x2CD8), + (0x2CDA, 0x2CDA), + (0x2CDC, 0x2CDC), + (0x2CDE, 0x2CDE), + (0x2CE0, 0x2CE0), + (0x2CE2, 0x2CE2), + (0x2CEB, 0x2CEB), + (0x2CED, 0x2CED), + (0x2CF2, 0x2CF2), + (0xA640, 0xA640), + (0xA642, 0xA642), + (0xA644, 0xA644), + (0xA646, 0xA646), + (0xA648, 0xA648), + (0xA64A, 0xA64A), + (0xA64C, 0xA64C), + (0xA64E, 0xA64E), + (0xA650, 0xA650), + (0xA652, 0xA652), + (0xA654, 0xA654), + (0xA656, 0xA656), + (0xA658, 0xA658), + (0xA65A, 0xA65A), + (0xA65C, 0xA65C), + (0xA65E, 0xA65E), + (0xA660, 0xA660), + (0xA662, 0xA662), + (0xA664, 0xA664), + (0xA666, 0xA666), + (0xA668, 0xA668), + (0xA66A, 0xA66A), + (0xA66C, 0xA66C), + (0xA680, 0xA680), + (0xA682, 0xA682), + (0xA684, 0xA684), + (0xA686, 0xA686), + (0xA688, 0xA688), + (0xA68A, 0xA68A), + (0xA68C, 0xA68C), + (0xA68E, 0xA68E), + (0xA690, 0xA690), + (0xA692, 0xA692), + (0xA694, 0xA694), + (0xA696, 0xA696), + (0xA698, 0xA698), + (0xA69A, 0xA69A), + (0xA722, 0xA722), + (0xA724, 0xA724), + (0xA726, 0xA726), + (0xA728, 0xA728), + (0xA72A, 0xA72A), + (0xA72C, 0xA72C), + (0xA72E, 0xA72E), + (0xA732, 0xA732), + (0xA734, 0xA734), + (0xA736, 0xA736), + (0xA738, 0xA738), + (0xA73A, 0xA73A), + (0xA73C, 0xA73C), + (0xA73E, 0xA73E), + (0xA740, 0xA740), + (0xA742, 0xA742), + (0xA744, 0xA744), + (0xA746, 0xA746), + (0xA748, 0xA748), + (0xA74A, 0xA74A), + (0xA74C, 0xA74C), + (0xA74E, 0xA74E), + (0xA750, 0xA750), + (0xA752, 0xA752), + (0xA754, 0xA754), + (0xA756, 0xA756), + (0xA758, 0xA758), + (0xA75A, 0xA75A), + (0xA75C, 0xA75C), + (0xA75E, 0xA75E), + (0xA760, 0xA760), + (0xA762, 0xA762), + (0xA764, 0xA764), + (0xA766, 0xA766), + (0xA768, 0xA768), + (0xA76A, 0xA76A), + (0xA76C, 0xA76C), + (0xA76E, 0xA76E), + (0xA779, 0xA779), + (0xA77B, 0xA77B), + (0xA77D, 0xA77E), + (0xA780, 0xA780), + (0xA782, 0xA782), + (0xA784, 0xA784), + (0xA786, 0xA786), + (0xA78B, 0xA78B), + (0xA78D, 0xA78D), + (0xA790, 0xA790), + (0xA792, 0xA792), + (0xA796, 0xA796), + (0xA798, 0xA798), + (0xA79A, 0xA79A), + (0xA79C, 0xA79C), + (0xA79E, 0xA79E), + (0xA7A0, 0xA7A0), + (0xA7A2, 0xA7A2), + (0xA7A4, 0xA7A4), + (0xA7A6, 0xA7A6), + (0xA7A8, 0xA7A8), + (0xA7AA, 0xA7AE), + (0xA7B0, 0xA7B4), + (0xA7B6, 0xA7B6), + (0xA7B8, 0xA7B8), + (0xA7BA, 0xA7BA), + (0xA7BC, 0xA7BC), + (0xA7BE, 0xA7BE), + (0xA7C0, 0xA7C0), + (0xA7C2, 0xA7C2), + (0xA7C4, 0xA7C7), + (0xA7C9, 0xA7C9), + (0xA7CB, 0xA7CC), + (0xA7CE, 0xA7CE), + (0xA7D0, 0xA7D0), + (0xA7D2, 0xA7D2), + (0xA7D4, 0xA7D4), + (0xA7D6, 0xA7D6), + (0xA7D8, 0xA7D8), + (0xA7DA, 0xA7DA), + (0xA7DC, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F5, 0xA7F5), + (0xAB6C, 0xAB6D), + (0xFF21, 0xFF3A), + (0x10400, 0x10427), + (0x104B0, 0x104D3), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10C80, 0x10CB2), + (0x10D50, 0x10D65), + (0x118A0, 0x118BF), + (0x16E40, 0x16E5F), + (0x16EA0, 0x16EB8), + (0x1D400, 0x1D419), + (0x1D434, 0x1D44D), + (0x1D468, 0x1D481), + (0x1D49C, 0x1D49C), + (0x1D49E, 0x1D49F), + (0x1D4A2, 0x1D4A2), + (0x1D4A5, 0x1D4A6), + (0x1D4A9, 0x1D4AC), + (0x1D4AE, 0x1D4B5), + (0x1D4D0, 0x1D4E9), + (0x1D504, 0x1D505), + (0x1D507, 0x1D50A), + (0x1D50D, 0x1D514), + (0x1D516, 0x1D51C), + (0x1D538, 0x1D539), + (0x1D53B, 0x1D53E), + (0x1D540, 0x1D544), + (0x1D546, 0x1D546), + (0x1D54A, 0x1D550), + (0x1D56C, 0x1D585), + (0x1D5A0, 0x1D5B9), + (0x1D5D4, 0x1D5ED), + (0x1D608, 0x1D621), + (0x1D63C, 0x1D655), + (0x1D670, 0x1D689), + (0x1D6A8, 0x1D6C0), + (0x1D6E2, 0x1D6FA), + (0x1D71C, 0x1D734), + (0x1D756, 0x1D76E), + (0x1D790, 0x1D7A8), + (0x1D7CA, 0x1D7CA), + (0x1DF40, 0x1DF40), + (0x1DF48, 0x1DF48), + (0x1DF4A, 0x1DF4A), + (0x1DF4D, 0x1DF4D), + (0x1DF51, 0x1DF51), + (0x1DF68, 0x1DF68), + (0x1DF6A, 0x1DF6A), + (0x1DF6C, 0x1DF6C), + (0x1DF6E, 0x1DF6E), + (0x1DF72, 0x1DF72), + (0x1DF74, 0x1DF74), + (0x1DF76, 0x1DF76), + (0x1DF78, 0x1DF78), + (0x1DF7A, 0x1DF7A), + (0x1DF7C, 0x1DF7C), + (0x1DF7E, 0x1DF7E), + (0x1E900, 0x1E921), + (0x1F130, 0x1F149), + (0x1F150, 0x1F169), + (0x1F170, 0x1F189), +]; + +/// The code points with the binary property Variation_Selector, as ranges. +pub static BINARY_VARIATION_SELECTOR: &[(u32, u32)] = &[ + (0x180B, 0x180D), + (0x180F, 0x180F), + (0xFE00, 0xFE0F), + (0xE0100, 0xE01EF), +]; + +/// The code points with the binary property White_Space, as ranges. +pub static BINARY_WHITE_SPACE: &[(u32, u32)] = &[ + (0x9, 0xD), + (0x20, 0x20), + (0x85, 0x85), + (0xA0, 0xA0), + (0x1680, 0x1680), + (0x2000, 0x200A), + (0x2028, 0x2029), + (0x202F, 0x202F), + (0x205F, 0x205F), + (0x3000, 0x3000), +]; + +/// The code points with the binary property XID_Continue, as ranges. +pub static BINARY_XID_CONTINUE: &[(u32, u32)] = &[ + (0x30, 0x39), + (0x41, 0x5A), + (0x5F, 0x5F), + (0x61, 0x7A), + (0xAA, 0xAA), + (0xB5, 0xB5), + (0xB7, 0xB7), + (0xBA, 0xBA), + (0xC0, 0xD6), + (0xD8, 0xF6), + (0xF8, 0x2C1), + (0x2C6, 0x2D1), + (0x2E0, 0x2E4), + (0x2EC, 0x2EC), + (0x2EE, 0x2EE), + (0x300, 0x374), + (0x376, 0x377), + (0x37B, 0x37D), + (0x37F, 0x37F), + (0x386, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x3A1), + (0x3A3, 0x3F5), + (0x3F7, 0x481), + (0x483, 0x487), + (0x48A, 0x52F), + (0x531, 0x556), + (0x558, 0x559), + (0x560, 0x588), + (0x58B, 0x58C), + (0x591, 0x5BD), + (0x5BF, 0x5BF), + (0x5C1, 0x5C2), + (0x5C4, 0x5C5), + (0x5C7, 0x5C9), + (0x5D0, 0x5EA), + (0x5EF, 0x5F2), + (0x610, 0x61A), + (0x620, 0x669), + (0x66E, 0x6D3), + (0x6D5, 0x6DC), + (0x6DF, 0x6E8), + (0x6EA, 0x6FC), + (0x6FF, 0x6FF), + (0x710, 0x74A), + (0x74D, 0x7B1), + (0x7C0, 0x7F5), + (0x7FA, 0x7FA), + (0x7FD, 0x7FD), + (0x800, 0x82D), + (0x840, 0x85B), + (0x860, 0x86A), + (0x870, 0x887), + (0x889, 0x88F), + (0x897, 0x8E1), + (0x8E3, 0x963), + (0x966, 0x96F), + (0x971, 0x983), + (0x985, 0x98C), + (0x98F, 0x990), + (0x993, 0x9A8), + (0x9AA, 0x9B0), + (0x9B2, 0x9B2), + (0x9B6, 0x9B9), + (0x9BC, 0x9C4), + (0x9C7, 0x9C8), + (0x9CB, 0x9CE), + (0x9D7, 0x9D7), + (0x9DC, 0x9DD), + (0x9DF, 0x9E3), + (0x9E6, 0x9F1), + (0x9FC, 0x9FC), + (0x9FE, 0x9FE), + (0xA01, 0xA03), + (0xA05, 0xA0A), + (0xA0F, 0xA10), + (0xA13, 0xA28), + (0xA2A, 0xA30), + (0xA32, 0xA33), + (0xA35, 0xA36), + (0xA38, 0xA39), + (0xA3C, 0xA3C), + (0xA3E, 0xA42), + (0xA47, 0xA48), + (0xA4B, 0xA4D), + (0xA51, 0xA51), + (0xA59, 0xA5C), + (0xA5E, 0xA5E), + (0xA66, 0xA75), + (0xA81, 0xA83), + (0xA85, 0xA8D), + (0xA8F, 0xA91), + (0xA93, 0xAA8), + (0xAAA, 0xAB0), + (0xAB2, 0xAB3), + (0xAB5, 0xAB9), + (0xABC, 0xAC5), + (0xAC7, 0xAC9), + (0xACB, 0xACD), + (0xAD0, 0xAD0), + (0xAE0, 0xAE3), + (0xAE6, 0xAEF), + (0xAF9, 0xAFF), + (0xB01, 0xB03), + (0xB05, 0xB0C), + (0xB0F, 0xB10), + (0xB13, 0xB28), + (0xB2A, 0xB30), + (0xB32, 0xB33), + (0xB35, 0xB39), + (0xB3C, 0xB44), + (0xB47, 0xB48), + (0xB4B, 0xB4D), + (0xB53, 0xB57), + (0xB5C, 0xB5D), + (0xB5F, 0xB63), + (0xB66, 0xB6F), + (0xB71, 0xB71), + (0xB82, 0xB83), + (0xB85, 0xB8A), + (0xB8E, 0xB90), + (0xB92, 0xB95), + (0xB99, 0xB9A), + (0xB9C, 0xB9C), + (0xB9E, 0xB9F), + (0xBA3, 0xBA4), + (0xBA8, 0xBAA), + (0xBAE, 0xBB9), + (0xBBE, 0xBC2), + (0xBC6, 0xBC8), + (0xBCA, 0xBCD), + (0xBD0, 0xBD0), + (0xBD7, 0xBD7), + (0xBE6, 0xBEF), + (0xC00, 0xC0C), + (0xC0E, 0xC10), + (0xC12, 0xC28), + (0xC2A, 0xC39), + (0xC3C, 0xC44), + (0xC46, 0xC48), + (0xC4A, 0xC4D), + (0xC55, 0xC56), + (0xC58, 0xC5A), + (0xC5C, 0xC5D), + (0xC60, 0xC63), + (0xC66, 0xC6F), + (0xC80, 0xC83), + (0xC85, 0xC8C), + (0xC8E, 0xC90), + (0xC92, 0xCA8), + (0xCAA, 0xCB3), + (0xCB5, 0xCB9), + (0xCBC, 0xCC4), + (0xCC6, 0xCC8), + (0xCCA, 0xCCD), + (0xCD5, 0xCD6), + (0xCDC, 0xCDE), + (0xCE0, 0xCE3), + (0xCE6, 0xCEF), + (0xCF1, 0xCF3), + (0xD00, 0xD0C), + (0xD0E, 0xD10), + (0xD12, 0xD44), + (0xD46, 0xD48), + (0xD4A, 0xD4E), + (0xD54, 0xD57), + (0xD5F, 0xD63), + (0xD66, 0xD6F), + (0xD7A, 0xD7F), + (0xD81, 0xD83), + (0xD85, 0xD96), + (0xD9A, 0xDB1), + (0xDB3, 0xDBB), + (0xDBD, 0xDBD), + (0xDC0, 0xDC6), + (0xDCA, 0xDCA), + (0xDCF, 0xDD4), + (0xDD6, 0xDD6), + (0xDD8, 0xDDF), + (0xDE6, 0xDEF), + (0xDF2, 0xDF3), + (0xE01, 0xE3A), + (0xE40, 0xE4E), + (0xE50, 0xE59), + (0xE81, 0xE82), + (0xE84, 0xE84), + (0xE86, 0xE8A), + (0xE8C, 0xEA3), + (0xEA5, 0xEA5), + (0xEA7, 0xEBD), + (0xEC0, 0xEC4), + (0xEC6, 0xEC6), + (0xEC8, 0xECE), + (0xED0, 0xED9), + (0xEDC, 0xEDF), + (0xF00, 0xF00), + (0xF18, 0xF19), + (0xF20, 0xF29), + (0xF35, 0xF35), + (0xF37, 0xF37), + (0xF39, 0xF39), + (0xF3E, 0xF47), + (0xF49, 0xF6C), + (0xF71, 0xF84), + (0xF86, 0xF97), + (0xF99, 0xFBC), + (0xFC6, 0xFC6), + (0x1000, 0x1049), + (0x1050, 0x109D), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x10D0, 0x10FA), + (0x10FC, 0x1248), + (0x124A, 0x124D), + (0x1250, 0x1256), + (0x1258, 0x1258), + (0x125A, 0x125D), + (0x1260, 0x1288), + (0x128A, 0x128D), + (0x1290, 0x12B0), + (0x12B2, 0x12B5), + (0x12B8, 0x12BE), + (0x12C0, 0x12C0), + (0x12C2, 0x12C5), + (0x12C8, 0x12D6), + (0x12D8, 0x1310), + (0x1312, 0x1315), + (0x1318, 0x135A), + (0x135D, 0x135F), + (0x1369, 0x1371), + (0x1380, 0x138F), + (0x13A0, 0x13F5), + (0x13F8, 0x13FD), + (0x1401, 0x166C), + (0x166F, 0x167F), + (0x1681, 0x169A), + (0x16A0, 0x16EA), + (0x16EE, 0x16F8), + (0x1700, 0x1715), + (0x171F, 0x1734), + (0x1740, 0x1753), + (0x1760, 0x176C), + (0x176E, 0x1770), + (0x1772, 0x1773), + (0x1780, 0x17D3), + (0x17D7, 0x17D7), + (0x17DC, 0x17DD), + (0x17E0, 0x17E9), + (0x180B, 0x180D), + (0x180F, 0x1819), + (0x1820, 0x1878), + (0x1880, 0x18AA), + (0x18B0, 0x18F5), + (0x1900, 0x191E), + (0x1920, 0x192B), + (0x1930, 0x193B), + (0x1946, 0x196D), + (0x1970, 0x1974), + (0x1980, 0x19AB), + (0x19B0, 0x19C9), + (0x19D0, 0x19DA), + (0x1A00, 0x1A1B), + (0x1A20, 0x1A5E), + (0x1A60, 0x1A7C), + (0x1A7F, 0x1A89), + (0x1A90, 0x1A99), + (0x1AA7, 0x1AA7), + (0x1AB0, 0x1ABD), + (0x1ABF, 0x1AF0), + (0x1B00, 0x1B4C), + (0x1B50, 0x1B59), + (0x1B6B, 0x1B73), + (0x1B80, 0x1BF3), + (0x1C00, 0x1C37), + (0x1C40, 0x1C49), + (0x1C4D, 0x1C7D), + (0x1C80, 0x1C8A), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1CD0, 0x1CD2), + (0x1CD4, 0x1CFA), + (0x1D00, 0x1F15), + (0x1F18, 0x1F1D), + (0x1F20, 0x1F45), + (0x1F48, 0x1F4D), + (0x1F50, 0x1F57), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F7D), + (0x1F80, 0x1FB4), + (0x1FB6, 0x1FBC), + (0x1FBE, 0x1FBE), + (0x1FC2, 0x1FC4), + (0x1FC6, 0x1FCC), + (0x1FD0, 0x1FD3), + (0x1FD6, 0x1FDB), + (0x1FE0, 0x1FEC), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FFC), + (0x200C, 0x200D), + (0x203F, 0x2040), + (0x2054, 0x2054), + (0x2071, 0x2071), + (0x207F, 0x207F), + (0x208F, 0x209F), + (0x20D0, 0x20DC), + (0x20E1, 0x20E1), + (0x20E5, 0x20F0), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210A, 0x2113), + (0x2115, 0x2115), + (0x2118, 0x211D), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212A, 0x2139), + (0x213C, 0x213F), + (0x2145, 0x2149), + (0x214E, 0x214E), + (0x2160, 0x2188), + (0x2C00, 0x2CE4), + (0x2CEB, 0x2CF3), + (0x2D00, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0x2D30, 0x2D67), + (0x2D6F, 0x2D6F), + (0x2D7F, 0x2D96), + (0x2DA0, 0x2DA6), + (0x2DA8, 0x2DAE), + (0x2DB0, 0x2DB6), + (0x2DB8, 0x2DBE), + (0x2DC0, 0x2DC6), + (0x2DC8, 0x2DCE), + (0x2DD0, 0x2DD6), + (0x2DD8, 0x2DDE), + (0x2DE0, 0x2DFF), + (0x3005, 0x3007), + (0x3021, 0x302F), + (0x3031, 0x3035), + (0x3038, 0x303C), + (0x3041, 0x3096), + (0x3099, 0x309A), + (0x309D, 0x309F), + (0x30A1, 0x30FF), + (0x3105, 0x312F), + (0x3131, 0x318E), + (0x31A0, 0x31BF), + (0x31F0, 0x31FF), + (0x3400, 0x4DBF), + (0x4E00, 0xA48C), + (0xA4D0, 0xA4FD), + (0xA500, 0xA60C), + (0xA610, 0xA62B), + (0xA640, 0xA66F), + (0xA674, 0xA67D), + (0xA67F, 0xA6F1), + (0xA717, 0xA71F), + (0xA722, 0xA788), + (0xA78B, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F1, 0xA827), + (0xA82C, 0xA82C), + (0xA840, 0xA873), + (0xA880, 0xA8C5), + (0xA8D0, 0xA8D9), + (0xA8E0, 0xA8F7), + (0xA8FB, 0xA8FB), + (0xA8FD, 0xA92D), + (0xA930, 0xA953), + (0xA960, 0xA97C), + (0xA980, 0xA9C0), + (0xA9CF, 0xA9D9), + (0xA9E0, 0xA9FE), + (0xAA00, 0xAA36), + (0xAA40, 0xAA4D), + (0xAA50, 0xAA59), + (0xAA60, 0xAA76), + (0xAA7A, 0xAAC2), + (0xAADB, 0xAADD), + (0xAAE0, 0xAAEF), + (0xAAF2, 0xAAF6), + (0xAB01, 0xAB06), + (0xAB09, 0xAB0E), + (0xAB11, 0xAB16), + (0xAB20, 0xAB26), + (0xAB28, 0xAB2E), + (0xAB30, 0xAB5A), + (0xAB5C, 0xAB69), + (0xAB6C, 0xAB6D), + (0xAB70, 0xABEA), + (0xABEC, 0xABED), + (0xABF0, 0xABF9), + (0xAC00, 0xD7A3), + (0xD7B0, 0xD7C6), + (0xD7CB, 0xD7FB), + (0xF900, 0xFA6D), + (0xFA70, 0xFAD9), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFB1D, 0xFB28), + (0xFB2A, 0xFB36), + (0xFB38, 0xFB3C), + (0xFB3E, 0xFB3E), + (0xFB40, 0xFB41), + (0xFB43, 0xFB44), + (0xFB46, 0xFBB1), + (0xFBD3, 0xFC5D), + (0xFC64, 0xFD3D), + (0xFD50, 0xFD8F), + (0xFD92, 0xFDC7), + (0xFDF0, 0xFDF9), + (0xFE00, 0xFE0F), + (0xFE20, 0xFE2F), + (0xFE33, 0xFE34), + (0xFE4D, 0xFE4F), + (0xFE71, 0xFE71), + (0xFE73, 0xFE73), + (0xFE77, 0xFE77), + (0xFE79, 0xFE79), + (0xFE7B, 0xFE7B), + (0xFE7D, 0xFE7D), + (0xFE7F, 0xFEFC), + (0xFF10, 0xFF19), + (0xFF21, 0xFF3A), + (0xFF3F, 0xFF3F), + (0xFF41, 0xFF5A), + (0xFF65, 0xFFBE), + (0xFFC2, 0xFFC7), + (0xFFCA, 0xFFCF), + (0xFFD2, 0xFFD7), + (0xFFDA, 0xFFDC), + (0x10000, 0x1000B), + (0x1000D, 0x10026), + (0x10028, 0x1003A), + (0x1003C, 0x1003D), + (0x1003F, 0x1004D), + (0x10050, 0x1005D), + (0x10080, 0x100FA), + (0x10140, 0x10174), + (0x101FD, 0x101FD), + (0x10280, 0x1029C), + (0x102A0, 0x102D0), + (0x102E0, 0x102E0), + (0x10300, 0x1031F), + (0x1032D, 0x1034A), + (0x10350, 0x1037A), + (0x10380, 0x1039D), + (0x103A0, 0x103C3), + (0x103C8, 0x103CF), + (0x103D1, 0x103D5), + (0x10400, 0x1049D), + (0x104A0, 0x104A9), + (0x104B0, 0x104D3), + (0x104D8, 0x104FB), + (0x10500, 0x10527), + (0x10530, 0x10563), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x105C0, 0x105F3), + (0x10600, 0x10736), + (0x10740, 0x10755), + (0x10760, 0x10767), + (0x10780, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BF), + (0x10800, 0x10805), + (0x10808, 0x10808), + (0x1080A, 0x10835), + (0x10837, 0x10838), + (0x1083C, 0x1083C), + (0x1083F, 0x10855), + (0x10860, 0x10876), + (0x10880, 0x1089E), + (0x108E0, 0x108F2), + (0x108F4, 0x108F5), + (0x10900, 0x10915), + (0x10920, 0x10939), + (0x10940, 0x10959), + (0x10980, 0x109B7), + (0x109BE, 0x109BF), + (0x10A00, 0x10A03), + (0x10A05, 0x10A06), + (0x10A0C, 0x10A13), + (0x10A15, 0x10A17), + (0x10A19, 0x10A35), + (0x10A38, 0x10A3A), + (0x10A3F, 0x10A3F), + (0x10A60, 0x10A7C), + (0x10A80, 0x10A9C), + (0x10AC0, 0x10AC7), + (0x10AC9, 0x10AE6), + (0x10B00, 0x10B35), + (0x10B40, 0x10B55), + (0x10B60, 0x10B72), + (0x10B80, 0x10B91), + (0x10C00, 0x10C48), + (0x10C80, 0x10CB2), + (0x10CC0, 0x10CF2), + (0x10D00, 0x10D27), + (0x10D30, 0x10D39), + (0x10D40, 0x10D65), + (0x10D69, 0x10D6D), + (0x10D6F, 0x10D85), + (0x10E80, 0x10EA9), + (0x10EAB, 0x10EAC), + (0x10EB0, 0x10EB1), + (0x10EC2, 0x10EC7), + (0x10ECB, 0x10ECF), + (0x10ED9, 0x10EEE), + (0x10EF0, 0x10F1C), + (0x10F27, 0x10F27), + (0x10F30, 0x10F50), + (0x10F70, 0x10F85), + (0x10FB0, 0x10FC4), + (0x10FE0, 0x10FF6), + (0x11000, 0x11046), + (0x11066, 0x11075), + (0x1107F, 0x110BA), + (0x110C2, 0x110C2), + (0x110D0, 0x110E8), + (0x110F0, 0x110F9), + (0x11100, 0x11134), + (0x11136, 0x1113F), + (0x11144, 0x11147), + (0x11150, 0x11173), + (0x11176, 0x11176), + (0x11180, 0x111C4), + (0x111C9, 0x111CC), + (0x111CE, 0x111DA), + (0x111DC, 0x111DC), + (0x11200, 0x11211), + (0x11213, 0x11237), + (0x1123E, 0x11241), + (0x11280, 0x11286), + (0x11288, 0x11288), + (0x1128A, 0x1128D), + (0x1128F, 0x1129D), + (0x1129F, 0x112A8), + (0x112B0, 0x112EA), + (0x112F0, 0x112F9), + (0x11300, 0x11303), + (0x11305, 0x1130C), + (0x1130F, 0x11310), + (0x11313, 0x11328), + (0x1132A, 0x11330), + (0x11332, 0x11333), + (0x11335, 0x11339), + (0x1133B, 0x11344), + (0x11347, 0x11348), + (0x1134B, 0x1134D), + (0x11350, 0x11350), + (0x11357, 0x11357), + (0x1135D, 0x11363), + (0x11366, 0x1136C), + (0x11370, 0x11374), + (0x11380, 0x11389), + (0x1138B, 0x1138B), + (0x1138E, 0x1138E), + (0x11390, 0x113B5), + (0x113B7, 0x113C0), + (0x113C2, 0x113C2), + (0x113C5, 0x113C5), + (0x113C7, 0x113CA), + (0x113CC, 0x113D3), + (0x113E1, 0x113E2), + (0x11400, 0x1144A), + (0x11450, 0x11459), + (0x1145E, 0x11461), + (0x11480, 0x114C5), + (0x114C7, 0x114C7), + (0x114D0, 0x114D9), + (0x11580, 0x115B5), + (0x115B8, 0x115C0), + (0x115D8, 0x115DD), + (0x11600, 0x11640), + (0x11644, 0x11644), + (0x11650, 0x11659), + (0x11680, 0x116B8), + (0x116C0, 0x116C9), + (0x116D0, 0x116E3), + (0x11700, 0x1171A), + (0x1171D, 0x1172B), + (0x11730, 0x11739), + (0x11740, 0x11746), + (0x11800, 0x1183A), + (0x118A0, 0x118E9), + (0x118FF, 0x11906), + (0x11909, 0x11909), + (0x1190C, 0x11913), + (0x11915, 0x11916), + (0x11918, 0x11935), + (0x11937, 0x11938), + (0x1193B, 0x11943), + (0x11950, 0x11959), + (0x119A0, 0x119A7), + (0x119AA, 0x119D7), + (0x119DA, 0x119E1), + (0x119E3, 0x119E4), + (0x11A00, 0x11A3E), + (0x11A47, 0x11A47), + (0x11A50, 0x11A99), + (0x11A9D, 0x11A9D), + (0x11AB0, 0x11AF8), + (0x11B0A, 0x11B0A), + (0x11B60, 0x11B67), + (0x11BC0, 0x11BE0), + (0x11BF0, 0x11BF9), + (0x11C00, 0x11C08), + (0x11C0A, 0x11C36), + (0x11C38, 0x11C40), + (0x11C50, 0x11C59), + (0x11C72, 0x11C8F), + (0x11C92, 0x11CA7), + (0x11CA9, 0x11CB6), + (0x11D00, 0x11D06), + (0x11D08, 0x11D09), + (0x11D0B, 0x11D36), + (0x11D3A, 0x11D3A), + (0x11D3C, 0x11D3D), + (0x11D3F, 0x11D47), + (0x11D50, 0x11D59), + (0x11D60, 0x11D65), + (0x11D67, 0x11D68), + (0x11D6A, 0x11D8E), + (0x11D90, 0x11D91), + (0x11D93, 0x11D98), + (0x11DA0, 0x11DA9), + (0x11DB0, 0x11DDB), + (0x11DE0, 0x11DE9), + (0x11DF0, 0x11DF1), + (0x11EE0, 0x11EF6), + (0x11F00, 0x11F10), + (0x11F12, 0x11F3A), + (0x11F3E, 0x11F42), + (0x11F50, 0x11F5A), + (0x11FB0, 0x11FB0), + (0x12000, 0x12399), + (0x12400, 0x1246F), + (0x12475, 0x12543), + (0x12550, 0x12686), + (0x12F90, 0x12FF0), + (0x13000, 0x1342F), + (0x13440, 0x13455), + (0x13460, 0x143FA), + (0x14400, 0x14646), + (0x16100, 0x16139), + (0x16800, 0x16A38), + (0x16A40, 0x16A5E), + (0x16A60, 0x16A69), + (0x16A70, 0x16ABE), + (0x16AC0, 0x16AC9), + (0x16AD0, 0x16AED), + (0x16AF0, 0x16AF4), + (0x16B00, 0x16B36), + (0x16B40, 0x16B43), + (0x16B50, 0x16B59), + (0x16B63, 0x16B77), + (0x16B7D, 0x16B8F), + (0x16D40, 0x16D6C), + (0x16D70, 0x16D79), + (0x16E40, 0x16E7F), + (0x16EA0, 0x16EB8), + (0x16EBB, 0x16ED3), + (0x16F00, 0x16F4A), + (0x16F4F, 0x16F87), + (0x16F8F, 0x16F9F), + (0x16FE0, 0x16FE1), + (0x16FE3, 0x16FE4), + (0x16FF0, 0x16FF6), + (0x17000, 0x18CDA), + (0x18CFF, 0x18D20), + (0x18D80, 0x18DF2), + (0x18E00, 0x19191), + (0x191A0, 0x191D2), + (0x1AFF0, 0x1AFF3), + (0x1AFF5, 0x1AFFB), + (0x1AFFD, 0x1AFFE), + (0x1B000, 0x1B128), + (0x1B132, 0x1B132), + (0x1B150, 0x1B152), + (0x1B155, 0x1B155), + (0x1B164, 0x1B168), + (0x1B170, 0x1B2FB), + (0x1BC00, 0x1BC6A), + (0x1BC70, 0x1BC7C), + (0x1BC80, 0x1BC88), + (0x1BC90, 0x1BC99), + (0x1BC9D, 0x1BC9E), + (0x1CCF0, 0x1CCF9), + (0x1CF00, 0x1CF2D), + (0x1CF30, 0x1CF46), + (0x1D127, 0x1D128), + (0x1D165, 0x1D169), + (0x1D16D, 0x1D172), + (0x1D17B, 0x1D182), + (0x1D185, 0x1D18B), + (0x1D1AA, 0x1D1AD), + (0x1D242, 0x1D244), + (0x1D250, 0x1D252), + (0x1D25B, 0x1D25C), + (0x1D25F, 0x1D25F), + (0x1D280, 0x1D281), + (0x1D400, 0x1D454), + (0x1D456, 0x1D49C), + (0x1D49E, 0x1D49F), + (0x1D4A2, 0x1D4A2), + (0x1D4A5, 0x1D4A6), + (0x1D4A9, 0x1D4AC), + (0x1D4AE, 0x1D4B9), + (0x1D4BB, 0x1D4BB), + (0x1D4BD, 0x1D4C3), + (0x1D4C5, 0x1D505), + (0x1D507, 0x1D50A), + (0x1D50D, 0x1D514), + (0x1D516, 0x1D51C), + (0x1D51E, 0x1D539), + (0x1D53B, 0x1D53E), + (0x1D540, 0x1D544), + (0x1D546, 0x1D546), + (0x1D54A, 0x1D550), + (0x1D552, 0x1D6A6), + (0x1D6A8, 0x1D6C0), + (0x1D6C2, 0x1D6DA), + (0x1D6DC, 0x1D6FA), + (0x1D6FC, 0x1D714), + (0x1D716, 0x1D734), + (0x1D736, 0x1D74E), + (0x1D750, 0x1D76E), + (0x1D770, 0x1D788), + (0x1D78A, 0x1D7A8), + (0x1D7AA, 0x1D7C2), + (0x1D7C4, 0x1D7CB), + (0x1D7CE, 0x1D7FF), + (0x1DA00, 0x1DA36), + (0x1DA3B, 0x1DA6C), + (0x1DA75, 0x1DA75), + (0x1DA84, 0x1DA84), + (0x1DA9B, 0x1DA9F), + (0x1DAA1, 0x1DAAF), + (0x1DF00, 0x1DF81), + (0x1DF90, 0x1DF96), + (0x1DFCD, 0x1E006), + (0x1E008, 0x1E018), + (0x1E01B, 0x1E021), + (0x1E023, 0x1E024), + (0x1E026, 0x1E02A), + (0x1E030, 0x1E06D), + (0x1E08F, 0x1E08F), + (0x1E100, 0x1E12C), + (0x1E130, 0x1E13D), + (0x1E140, 0x1E149), + (0x1E14E, 0x1E14E), + (0x1E290, 0x1E2AE), + (0x1E2C0, 0x1E2F9), + (0x1E4D0, 0x1E4F9), + (0x1E5D0, 0x1E5FA), + (0x1E6C0, 0x1E6DE), + (0x1E6E0, 0x1E6F5), + (0x1E6FE, 0x1E6FF), + (0x1E7E0, 0x1E7E6), + (0x1E7E8, 0x1E7EB), + (0x1E7ED, 0x1E7EE), + (0x1E7F0, 0x1E7FE), + (0x1E800, 0x1E8C4), + (0x1E8D0, 0x1E8D6), + (0x1E900, 0x1E94B), + (0x1E950, 0x1E959), + (0x1EE00, 0x1EE03), + (0x1EE05, 0x1EE1F), + (0x1EE21, 0x1EE22), + (0x1EE24, 0x1EE24), + (0x1EE27, 0x1EE27), + (0x1EE29, 0x1EE32), + (0x1EE34, 0x1EE37), + (0x1EE39, 0x1EE39), + (0x1EE3B, 0x1EE3B), + (0x1EE42, 0x1EE42), + (0x1EE47, 0x1EE47), + (0x1EE49, 0x1EE49), + (0x1EE4B, 0x1EE4B), + (0x1EE4D, 0x1EE4F), + (0x1EE51, 0x1EE52), + (0x1EE54, 0x1EE54), + (0x1EE57, 0x1EE57), + (0x1EE59, 0x1EE59), + (0x1EE5B, 0x1EE5B), + (0x1EE5D, 0x1EE5D), + (0x1EE5F, 0x1EE5F), + (0x1EE61, 0x1EE62), + (0x1EE64, 0x1EE64), + (0x1EE67, 0x1EE6A), + (0x1EE6C, 0x1EE72), + (0x1EE74, 0x1EE77), + (0x1EE79, 0x1EE7C), + (0x1EE7E, 0x1EE7E), + (0x1EE80, 0x1EE89), + (0x1EE8B, 0x1EE9B), + (0x1EEA1, 0x1EEA3), + (0x1EEA5, 0x1EEA9), + (0x1EEAB, 0x1EEBB), + (0x1FBF0, 0x1FBF9), + (0x20000, 0x2A6DF), + (0x2A700, 0x2B81E), + (0x2B820, 0x2CEAD), + (0x2CEB0, 0x2EBE0), + (0x2EBF0, 0x2EE5D), + (0x2F800, 0x2FA1D), + (0x30000, 0x3134A), + (0x31350, 0x33479), + (0x3D000, 0x3FC3F), + (0xE0100, 0xE01EF), +]; + +/// The code points with the binary property XID_Start, as ranges. +pub static BINARY_XID_START: &[(u32, u32)] = &[ + (0x41, 0x5A), + (0x61, 0x7A), + (0xAA, 0xAA), + (0xB5, 0xB5), + (0xBA, 0xBA), + (0xC0, 0xD6), + (0xD8, 0xF6), + (0xF8, 0x2C1), + (0x2C6, 0x2D1), + (0x2E0, 0x2E4), + (0x2EC, 0x2EC), + (0x2EE, 0x2EE), + (0x370, 0x374), + (0x376, 0x377), + (0x37B, 0x37D), + (0x37F, 0x37F), + (0x386, 0x386), + (0x388, 0x38A), + (0x38C, 0x38C), + (0x38E, 0x3A1), + (0x3A3, 0x3F5), + (0x3F7, 0x481), + (0x48A, 0x52F), + (0x531, 0x556), + (0x558, 0x559), + (0x560, 0x588), + (0x58B, 0x58C), + (0x5D0, 0x5EA), + (0x5EF, 0x5F2), + (0x620, 0x64A), + (0x66E, 0x66F), + (0x671, 0x6D3), + (0x6D5, 0x6D5), + (0x6E5, 0x6E6), + (0x6EE, 0x6EF), + (0x6FA, 0x6FC), + (0x6FF, 0x6FF), + (0x710, 0x710), + (0x712, 0x72F), + (0x74D, 0x7A5), + (0x7B1, 0x7B1), + (0x7CA, 0x7EA), + (0x7F4, 0x7F5), + (0x7FA, 0x7FA), + (0x800, 0x815), + (0x81A, 0x81A), + (0x824, 0x824), + (0x828, 0x828), + (0x840, 0x858), + (0x860, 0x86A), + (0x870, 0x887), + (0x889, 0x88F), + (0x8A0, 0x8C9), + (0x904, 0x939), + (0x93D, 0x93D), + (0x950, 0x950), + (0x958, 0x961), + (0x971, 0x980), + (0x985, 0x98C), + (0x98F, 0x990), + (0x993, 0x9A8), + (0x9AA, 0x9B0), + (0x9B2, 0x9B2), + (0x9B6, 0x9B9), + (0x9BD, 0x9BD), + (0x9CE, 0x9CE), + (0x9DC, 0x9DD), + (0x9DF, 0x9E1), + (0x9F0, 0x9F1), + (0x9FC, 0x9FC), + (0xA05, 0xA0A), + (0xA0F, 0xA10), + (0xA13, 0xA28), + (0xA2A, 0xA30), + (0xA32, 0xA33), + (0xA35, 0xA36), + (0xA38, 0xA39), + (0xA59, 0xA5C), + (0xA5E, 0xA5E), + (0xA72, 0xA74), + (0xA85, 0xA8D), + (0xA8F, 0xA91), + (0xA93, 0xAA8), + (0xAAA, 0xAB0), + (0xAB2, 0xAB3), + (0xAB5, 0xAB9), + (0xABD, 0xABD), + (0xAD0, 0xAD0), + (0xAE0, 0xAE1), + (0xAF9, 0xAF9), + (0xB05, 0xB0C), + (0xB0F, 0xB10), + (0xB13, 0xB28), + (0xB2A, 0xB30), + (0xB32, 0xB33), + (0xB35, 0xB39), + (0xB3D, 0xB3D), + (0xB5C, 0xB5D), + (0xB5F, 0xB61), + (0xB71, 0xB71), + (0xB83, 0xB83), + (0xB85, 0xB8A), + (0xB8E, 0xB90), + (0xB92, 0xB95), + (0xB99, 0xB9A), + (0xB9C, 0xB9C), + (0xB9E, 0xB9F), + (0xBA3, 0xBA4), + (0xBA8, 0xBAA), + (0xBAE, 0xBB9), + (0xBD0, 0xBD0), + (0xC05, 0xC0C), + (0xC0E, 0xC10), + (0xC12, 0xC28), + (0xC2A, 0xC39), + (0xC3D, 0xC3D), + (0xC58, 0xC5A), + (0xC5C, 0xC5D), + (0xC60, 0xC61), + (0xC80, 0xC80), + (0xC85, 0xC8C), + (0xC8E, 0xC90), + (0xC92, 0xCA8), + (0xCAA, 0xCB3), + (0xCB5, 0xCB9), + (0xCBD, 0xCBD), + (0xCDC, 0xCDE), + (0xCE0, 0xCE1), + (0xCF1, 0xCF2), + (0xD04, 0xD0C), + (0xD0E, 0xD10), + (0xD12, 0xD3A), + (0xD3D, 0xD3D), + (0xD4E, 0xD4E), + (0xD54, 0xD56), + (0xD5F, 0xD61), + (0xD7A, 0xD7F), + (0xD85, 0xD96), + (0xD9A, 0xDB1), + (0xDB3, 0xDBB), + (0xDBD, 0xDBD), + (0xDC0, 0xDC6), + (0xE01, 0xE30), + (0xE32, 0xE32), + (0xE40, 0xE46), + (0xE81, 0xE82), + (0xE84, 0xE84), + (0xE86, 0xE8A), + (0xE8C, 0xEA3), + (0xEA5, 0xEA5), + (0xEA7, 0xEB0), + (0xEB2, 0xEB2), + (0xEBD, 0xEBD), + (0xEC0, 0xEC4), + (0xEC6, 0xEC6), + (0xEDC, 0xEDF), + (0xF00, 0xF00), + (0xF40, 0xF47), + (0xF49, 0xF6C), + (0xF88, 0xF8C), + (0x1000, 0x102A), + (0x103F, 0x103F), + (0x1050, 0x1055), + (0x105A, 0x105D), + (0x1061, 0x1061), + (0x1065, 0x1066), + (0x106E, 0x1070), + (0x1075, 0x1081), + (0x108E, 0x108E), + (0x10A0, 0x10C5), + (0x10C7, 0x10C7), + (0x10CD, 0x10CD), + (0x10D0, 0x10FA), + (0x10FC, 0x1248), + (0x124A, 0x124D), + (0x1250, 0x1256), + (0x1258, 0x1258), + (0x125A, 0x125D), + (0x1260, 0x1288), + (0x128A, 0x128D), + (0x1290, 0x12B0), + (0x12B2, 0x12B5), + (0x12B8, 0x12BE), + (0x12C0, 0x12C0), + (0x12C2, 0x12C5), + (0x12C8, 0x12D6), + (0x12D8, 0x1310), + (0x1312, 0x1315), + (0x1318, 0x135A), + (0x1380, 0x138F), + (0x13A0, 0x13F5), + (0x13F8, 0x13FD), + (0x1401, 0x166C), + (0x166F, 0x167F), + (0x1681, 0x169A), + (0x16A0, 0x16EA), + (0x16EE, 0x16F8), + (0x1700, 0x1711), + (0x171F, 0x1731), + (0x1740, 0x1751), + (0x1760, 0x176C), + (0x176E, 0x1770), + (0x1780, 0x17B3), + (0x17D7, 0x17D7), + (0x17DC, 0x17DC), + (0x1820, 0x1878), + (0x1880, 0x18A8), + (0x18AA, 0x18AA), + (0x18B0, 0x18F5), + (0x1900, 0x191E), + (0x1950, 0x196D), + (0x1970, 0x1974), + (0x1980, 0x19AB), + (0x19B0, 0x19C9), + (0x1A00, 0x1A16), + (0x1A20, 0x1A54), + (0x1AA7, 0x1AA7), + (0x1B05, 0x1B33), + (0x1B45, 0x1B4C), + (0x1B83, 0x1BA0), + (0x1BAE, 0x1BAF), + (0x1BBA, 0x1BE5), + (0x1C00, 0x1C23), + (0x1C4D, 0x1C4F), + (0x1C5A, 0x1C7D), + (0x1C80, 0x1C8A), + (0x1C90, 0x1CBA), + (0x1CBD, 0x1CBF), + (0x1CE9, 0x1CEC), + (0x1CEE, 0x1CF3), + (0x1CF5, 0x1CF6), + (0x1CFA, 0x1CFA), + (0x1D00, 0x1DBF), + (0x1E00, 0x1F15), + (0x1F18, 0x1F1D), + (0x1F20, 0x1F45), + (0x1F48, 0x1F4D), + (0x1F50, 0x1F57), + (0x1F59, 0x1F59), + (0x1F5B, 0x1F5B), + (0x1F5D, 0x1F5D), + (0x1F5F, 0x1F7D), + (0x1F80, 0x1FB4), + (0x1FB6, 0x1FBC), + (0x1FBE, 0x1FBE), + (0x1FC2, 0x1FC4), + (0x1FC6, 0x1FCC), + (0x1FD0, 0x1FD3), + (0x1FD6, 0x1FDB), + (0x1FE0, 0x1FEC), + (0x1FF2, 0x1FF4), + (0x1FF6, 0x1FFC), + (0x2071, 0x2071), + (0x207F, 0x207F), + (0x208F, 0x209F), + (0x2102, 0x2102), + (0x2107, 0x2107), + (0x210A, 0x2113), + (0x2115, 0x2115), + (0x2118, 0x211D), + (0x2124, 0x2124), + (0x2126, 0x2126), + (0x2128, 0x2128), + (0x212A, 0x2139), + (0x213C, 0x213F), + (0x2145, 0x2149), + (0x214E, 0x214E), + (0x2160, 0x2188), + (0x2C00, 0x2CE4), + (0x2CEB, 0x2CEE), + (0x2CF2, 0x2CF3), + (0x2D00, 0x2D25), + (0x2D27, 0x2D27), + (0x2D2D, 0x2D2D), + (0x2D30, 0x2D67), + (0x2D6F, 0x2D6F), + (0x2D80, 0x2D96), + (0x2DA0, 0x2DA6), + (0x2DA8, 0x2DAE), + (0x2DB0, 0x2DB6), + (0x2DB8, 0x2DBE), + (0x2DC0, 0x2DC6), + (0x2DC8, 0x2DCE), + (0x2DD0, 0x2DD6), + (0x2DD8, 0x2DDE), + (0x3005, 0x3007), + (0x3021, 0x3029), + (0x3031, 0x3035), + (0x3038, 0x303C), + (0x3041, 0x3096), + (0x309D, 0x309F), + (0x30A1, 0x30FA), + (0x30FC, 0x30FF), + (0x3105, 0x312F), + (0x3131, 0x318E), + (0x31A0, 0x31BF), + (0x31F0, 0x31FF), + (0x3400, 0x4DBF), + (0x4E00, 0xA48C), + (0xA4D0, 0xA4FD), + (0xA500, 0xA60C), + (0xA610, 0xA61F), + (0xA62A, 0xA62B), + (0xA640, 0xA66E), + (0xA67F, 0xA69D), + (0xA6A0, 0xA6EF), + (0xA717, 0xA71F), + (0xA722, 0xA788), + (0xA78B, 0xA7DD), + (0xA7E2, 0xA7E2), + (0xA7F1, 0xA801), + (0xA803, 0xA805), + (0xA807, 0xA80A), + (0xA80C, 0xA822), + (0xA840, 0xA873), + (0xA882, 0xA8B3), + (0xA8F2, 0xA8F7), + (0xA8FB, 0xA8FB), + (0xA8FD, 0xA8FE), + (0xA90A, 0xA925), + (0xA930, 0xA946), + (0xA960, 0xA97C), + (0xA984, 0xA9B2), + (0xA9CF, 0xA9CF), + (0xA9E0, 0xA9E4), + (0xA9E6, 0xA9EF), + (0xA9FA, 0xA9FE), + (0xAA00, 0xAA28), + (0xAA40, 0xAA42), + (0xAA44, 0xAA4B), + (0xAA60, 0xAA76), + (0xAA7A, 0xAA7A), + (0xAA7E, 0xAAAF), + (0xAAB1, 0xAAB1), + (0xAAB5, 0xAAB6), + (0xAAB9, 0xAABD), + (0xAAC0, 0xAAC0), + (0xAAC2, 0xAAC2), + (0xAADB, 0xAADD), + (0xAAE0, 0xAAEA), + (0xAAF2, 0xAAF4), + (0xAB01, 0xAB06), + (0xAB09, 0xAB0E), + (0xAB11, 0xAB16), + (0xAB20, 0xAB26), + (0xAB28, 0xAB2E), + (0xAB30, 0xAB5A), + (0xAB5C, 0xAB69), + (0xAB6C, 0xAB6D), + (0xAB70, 0xABE2), + (0xAC00, 0xD7A3), + (0xD7B0, 0xD7C6), + (0xD7CB, 0xD7FB), + (0xF900, 0xFA6D), + (0xFA70, 0xFAD9), + (0xFB00, 0xFB06), + (0xFB13, 0xFB17), + (0xFB1D, 0xFB1D), + (0xFB1F, 0xFB28), + (0xFB2A, 0xFB36), + (0xFB38, 0xFB3C), + (0xFB3E, 0xFB3E), + (0xFB40, 0xFB41), + (0xFB43, 0xFB44), + (0xFB46, 0xFBB1), + (0xFBD3, 0xFC5D), + (0xFC64, 0xFD3D), + (0xFD50, 0xFD8F), + (0xFD92, 0xFDC7), + (0xFDF0, 0xFDF9), + (0xFE71, 0xFE71), + (0xFE73, 0xFE73), + (0xFE77, 0xFE77), + (0xFE79, 0xFE79), + (0xFE7B, 0xFE7B), + (0xFE7D, 0xFE7D), + (0xFE7F, 0xFEFC), + (0xFF21, 0xFF3A), + (0xFF41, 0xFF5A), + (0xFF66, 0xFF9D), + (0xFFA0, 0xFFBE), + (0xFFC2, 0xFFC7), + (0xFFCA, 0xFFCF), + (0xFFD2, 0xFFD7), + (0xFFDA, 0xFFDC), + (0x10000, 0x1000B), + (0x1000D, 0x10026), + (0x10028, 0x1003A), + (0x1003C, 0x1003D), + (0x1003F, 0x1004D), + (0x10050, 0x1005D), + (0x10080, 0x100FA), + (0x10140, 0x10174), + (0x10280, 0x1029C), + (0x102A0, 0x102D0), + (0x10300, 0x1031F), + (0x1032D, 0x1034A), + (0x10350, 0x10375), + (0x10380, 0x1039D), + (0x103A0, 0x103C3), + (0x103C8, 0x103CF), + (0x103D1, 0x103D5), + (0x10400, 0x1049D), + (0x104B0, 0x104D3), + (0x104D8, 0x104FB), + (0x10500, 0x10527), + (0x10530, 0x10563), + (0x10570, 0x1057A), + (0x1057C, 0x1058A), + (0x1058C, 0x10592), + (0x10594, 0x10595), + (0x10597, 0x105A1), + (0x105A3, 0x105B1), + (0x105B3, 0x105B9), + (0x105BB, 0x105BC), + (0x105C0, 0x105F3), + (0x10600, 0x10736), + (0x10740, 0x10755), + (0x10760, 0x10767), + (0x10780, 0x10785), + (0x10787, 0x107B0), + (0x107B2, 0x107BF), + (0x10800, 0x10805), + (0x10808, 0x10808), + (0x1080A, 0x10835), + (0x10837, 0x10838), + (0x1083C, 0x1083C), + (0x1083F, 0x10855), + (0x10860, 0x10876), + (0x10880, 0x1089E), + (0x108E0, 0x108F2), + (0x108F4, 0x108F5), + (0x10900, 0x10915), + (0x10920, 0x10939), + (0x10940, 0x10959), + (0x10980, 0x109B7), + (0x109BE, 0x109BF), + (0x10A00, 0x10A00), + (0x10A10, 0x10A13), + (0x10A15, 0x10A17), + (0x10A19, 0x10A35), + (0x10A60, 0x10A7C), + (0x10A80, 0x10A9C), + (0x10AC0, 0x10AC7), + (0x10AC9, 0x10AE4), + (0x10B00, 0x10B35), + (0x10B40, 0x10B55), + (0x10B60, 0x10B72), + (0x10B80, 0x10B91), + (0x10C00, 0x10C48), + (0x10C80, 0x10CB2), + (0x10CC0, 0x10CF2), + (0x10D00, 0x10D23), + (0x10D4A, 0x10D65), + (0x10D6F, 0x10D85), + (0x10E80, 0x10EA9), + (0x10EB0, 0x10EB1), + (0x10EC2, 0x10EC7), + (0x10ED9, 0x10EEE), + (0x10F00, 0x10F1C), + (0x10F27, 0x10F27), + (0x10F30, 0x10F45), + (0x10F70, 0x10F81), + (0x10FB0, 0x10FC4), + (0x10FE0, 0x10FF6), + (0x11003, 0x11037), + (0x11071, 0x11072), + (0x11075, 0x11075), + (0x11083, 0x110AF), + (0x110D0, 0x110E8), + (0x11103, 0x11126), + (0x11144, 0x11144), + (0x11147, 0x11147), + (0x11150, 0x11172), + (0x11176, 0x11176), + (0x11183, 0x111B2), + (0x111C1, 0x111C4), + (0x111DA, 0x111DA), + (0x111DC, 0x111DC), + (0x11200, 0x11211), + (0x11213, 0x1122B), + (0x1123F, 0x11240), + (0x11280, 0x11286), + (0x11288, 0x11288), + (0x1128A, 0x1128D), + (0x1128F, 0x1129D), + (0x1129F, 0x112A8), + (0x112B0, 0x112DE), + (0x11305, 0x1130C), + (0x1130F, 0x11310), + (0x11313, 0x11328), + (0x1132A, 0x11330), + (0x11332, 0x11333), + (0x11335, 0x11339), + (0x1133D, 0x1133D), + (0x11350, 0x11350), + (0x1135D, 0x11361), + (0x11380, 0x11389), + (0x1138B, 0x1138B), + (0x1138E, 0x1138E), + (0x11390, 0x113B5), + (0x113B7, 0x113B7), + (0x113D1, 0x113D1), + (0x113D3, 0x113D3), + (0x11400, 0x11434), + (0x11447, 0x1144A), + (0x1145F, 0x11461), + (0x11480, 0x114AF), + (0x114C4, 0x114C5), + (0x114C7, 0x114C7), + (0x11580, 0x115AE), + (0x115D8, 0x115DB), + (0x11600, 0x1162F), + (0x11644, 0x11644), + (0x11680, 0x116AA), + (0x116B8, 0x116B8), + (0x11700, 0x1171A), + (0x11740, 0x11746), + (0x11800, 0x1182B), + (0x118A0, 0x118DF), + (0x118FF, 0x11906), + (0x11909, 0x11909), + (0x1190C, 0x11913), + (0x11915, 0x11916), + (0x11918, 0x1192F), + (0x1193F, 0x1193F), + (0x11941, 0x11941), + (0x119A0, 0x119A7), + (0x119AA, 0x119D0), + (0x119E1, 0x119E1), + (0x119E3, 0x119E3), + (0x11A00, 0x11A00), + (0x11A0B, 0x11A32), + (0x11A3A, 0x11A3A), + (0x11A50, 0x11A50), + (0x11A5C, 0x11A89), + (0x11A9D, 0x11A9D), + (0x11AB0, 0x11AF8), + (0x11B0A, 0x11B0A), + (0x11BC0, 0x11BE0), + (0x11C00, 0x11C08), + (0x11C0A, 0x11C2E), + (0x11C40, 0x11C40), + (0x11C72, 0x11C8F), + (0x11D00, 0x11D06), + (0x11D08, 0x11D09), + (0x11D0B, 0x11D30), + (0x11D46, 0x11D46), + (0x11D60, 0x11D65), + (0x11D67, 0x11D68), + (0x11D6A, 0x11D89), + (0x11D98, 0x11D98), + (0x11DB0, 0x11DDB), + (0x11DF1, 0x11DF1), + (0x11EE0, 0x11EF2), + (0x11F02, 0x11F02), + (0x11F04, 0x11F10), + (0x11F12, 0x11F33), + (0x11FB0, 0x11FB0), + (0x12000, 0x12399), + (0x12400, 0x1246F), + (0x12475, 0x12543), + (0x12550, 0x12686), + (0x12F90, 0x12FF0), + (0x13000, 0x1342F), + (0x13441, 0x13446), + (0x13460, 0x143FA), + (0x14400, 0x14646), + (0x16100, 0x1611D), + (0x16800, 0x16A38), + (0x16A40, 0x16A5E), + (0x16A70, 0x16ABE), + (0x16AD0, 0x16AED), + (0x16B00, 0x16B2F), + (0x16B40, 0x16B43), + (0x16B63, 0x16B77), + (0x16B7D, 0x16B8F), + (0x16D40, 0x16D6C), + (0x16E40, 0x16E7F), + (0x16EA0, 0x16EB8), + (0x16EBB, 0x16ED3), + (0x16F00, 0x16F4A), + (0x16F50, 0x16F50), + (0x16F93, 0x16F9F), + (0x16FE0, 0x16FE1), + (0x16FE3, 0x16FE3), + (0x16FF2, 0x16FF6), + (0x17000, 0x18CDA), + (0x18CFF, 0x18D20), + (0x18D80, 0x18DF2), + (0x18E00, 0x19191), + (0x191A0, 0x191D2), + (0x1AFF0, 0x1AFF3), + (0x1AFF5, 0x1AFFB), + (0x1AFFD, 0x1AFFE), + (0x1B000, 0x1B128), + (0x1B132, 0x1B132), + (0x1B150, 0x1B152), + (0x1B155, 0x1B155), + (0x1B164, 0x1B168), + (0x1B170, 0x1B2FB), + (0x1BC00, 0x1BC6A), + (0x1BC70, 0x1BC7C), + (0x1BC80, 0x1BC88), + (0x1BC90, 0x1BC99), + (0x1D400, 0x1D454), + (0x1D456, 0x1D49C), + (0x1D49E, 0x1D49F), + (0x1D4A2, 0x1D4A2), + (0x1D4A5, 0x1D4A6), + (0x1D4A9, 0x1D4AC), + (0x1D4AE, 0x1D4B9), + (0x1D4BB, 0x1D4BB), + (0x1D4BD, 0x1D4C3), + (0x1D4C5, 0x1D505), + (0x1D507, 0x1D50A), + (0x1D50D, 0x1D514), + (0x1D516, 0x1D51C), + (0x1D51E, 0x1D539), + (0x1D53B, 0x1D53E), + (0x1D540, 0x1D544), + (0x1D546, 0x1D546), + (0x1D54A, 0x1D550), + (0x1D552, 0x1D6A6), + (0x1D6A8, 0x1D6C0), + (0x1D6C2, 0x1D6DA), + (0x1D6DC, 0x1D6FA), + (0x1D6FC, 0x1D714), + (0x1D716, 0x1D734), + (0x1D736, 0x1D74E), + (0x1D750, 0x1D76E), + (0x1D770, 0x1D788), + (0x1D78A, 0x1D7A8), + (0x1D7AA, 0x1D7C2), + (0x1D7C4, 0x1D7CB), + (0x1DF00, 0x1DF81), + (0x1DF90, 0x1DF96), + (0x1DFCD, 0x1DFFF), + (0x1E030, 0x1E06D), + (0x1E100, 0x1E12C), + (0x1E137, 0x1E13D), + (0x1E14E, 0x1E14E), + (0x1E290, 0x1E2AD), + (0x1E2C0, 0x1E2EB), + (0x1E4D0, 0x1E4EB), + (0x1E5D0, 0x1E5ED), + (0x1E5F0, 0x1E5F0), + (0x1E6C0, 0x1E6DE), + (0x1E6E0, 0x1E6E2), + (0x1E6E4, 0x1E6E5), + (0x1E6E7, 0x1E6ED), + (0x1E6F0, 0x1E6F4), + (0x1E6FE, 0x1E6FF), + (0x1E7E0, 0x1E7E6), + (0x1E7E8, 0x1E7EB), + (0x1E7ED, 0x1E7EE), + (0x1E7F0, 0x1E7FE), + (0x1E800, 0x1E8C4), + (0x1E900, 0x1E943), + (0x1E94B, 0x1E94B), + (0x1EE00, 0x1EE03), + (0x1EE05, 0x1EE1F), + (0x1EE21, 0x1EE22), + (0x1EE24, 0x1EE24), + (0x1EE27, 0x1EE27), + (0x1EE29, 0x1EE32), + (0x1EE34, 0x1EE37), + (0x1EE39, 0x1EE39), + (0x1EE3B, 0x1EE3B), + (0x1EE42, 0x1EE42), + (0x1EE47, 0x1EE47), + (0x1EE49, 0x1EE49), + (0x1EE4B, 0x1EE4B), + (0x1EE4D, 0x1EE4F), + (0x1EE51, 0x1EE52), + (0x1EE54, 0x1EE54), + (0x1EE57, 0x1EE57), + (0x1EE59, 0x1EE59), + (0x1EE5B, 0x1EE5B), + (0x1EE5D, 0x1EE5D), + (0x1EE5F, 0x1EE5F), + (0x1EE61, 0x1EE62), + (0x1EE64, 0x1EE64), + (0x1EE67, 0x1EE6A), + (0x1EE6C, 0x1EE72), + (0x1EE74, 0x1EE77), + (0x1EE79, 0x1EE7C), + (0x1EE7E, 0x1EE7E), + (0x1EE80, 0x1EE89), + (0x1EE8B, 0x1EE9B), + (0x1EEA1, 0x1EEA3), + (0x1EEA5, 0x1EEA9), + (0x1EEAB, 0x1EEBB), + (0x20000, 0x2A6DF), + (0x2A700, 0x2B81E), + (0x2B820, 0x2CEAD), + (0x2CEB0, 0x2EBE0), + (0x2EBF0, 0x2EE5D), + (0x2F800, 0x2FA1D), + (0x30000, 0x3134A), + (0x31350, 0x33479), + (0x3D000, 0x3FC3F), +]; + +/// The binary properties of ECMA-262's list that need a table, by canonical name (`Any`, `ASCII` and `Assigned` need none). +pub static BINARY: &[(&str, &[(u32, u32)])] = &[ + ("ASCII_Hex_Digit", BINARY_ASCII_HEX_DIGIT), + ("Alphabetic", BINARY_ALPHABETIC), + ("Bidi_Control", BINARY_BIDI_CONTROL), + ("Bidi_Mirrored", BINARY_BIDI_MIRRORED), + ("Case_Ignorable", BINARY_CASE_IGNORABLE), + ("Cased", BINARY_CASED), + ("Changes_When_Casefolded", BINARY_CHANGES_WHEN_CASEFOLDED), + ("Changes_When_Casemapped", BINARY_CHANGES_WHEN_CASEMAPPED), + ("Changes_When_Lowercased", BINARY_CHANGES_WHEN_LOWERCASED), + ( + "Changes_When_NFKC_Casefolded", + BINARY_CHANGES_WHEN_NFKC_CASEFOLDED, + ), + ("Changes_When_Titlecased", BINARY_CHANGES_WHEN_TITLECASED), + ("Changes_When_Uppercased", BINARY_CHANGES_WHEN_UPPERCASED), + ("Dash", BINARY_DASH), + ( + "Default_Ignorable_Code_Point", + BINARY_DEFAULT_IGNORABLE_CODE_POINT, + ), + ("Deprecated", BINARY_DEPRECATED), + ("Diacritic", BINARY_DIACRITIC), + ("Emoji", BINARY_EMOJI), + ("Emoji_Component", BINARY_EMOJI_COMPONENT), + ("Emoji_Modifier", BINARY_EMOJI_MODIFIER), + ("Emoji_Modifier_Base", BINARY_EMOJI_MODIFIER_BASE), + ("Emoji_Presentation", BINARY_EMOJI_PRESENTATION), + ("Extended_Pictographic", BINARY_EXTENDED_PICTOGRAPHIC), + ("Extender", BINARY_EXTENDER), + ("Grapheme_Base", BINARY_GRAPHEME_BASE), + ("Grapheme_Extend", BINARY_GRAPHEME_EXTEND), + ("Hex_Digit", BINARY_HEX_DIGIT), + ("IDS_Binary_Operator", BINARY_IDS_BINARY_OPERATOR), + ("IDS_Trinary_Operator", BINARY_IDS_TRINARY_OPERATOR), + ("ID_Continue", BINARY_ID_CONTINUE), + ("ID_Start", BINARY_ID_START), + ("Ideographic", BINARY_IDEOGRAPHIC), + ("Join_Control", BINARY_JOIN_CONTROL), + ("Logical_Order_Exception", BINARY_LOGICAL_ORDER_EXCEPTION), + ("Lowercase", BINARY_LOWERCASE), + ("Math", BINARY_MATH), + ("Noncharacter_Code_Point", BINARY_NONCHARACTER_CODE_POINT), + ("Pattern_Syntax", BINARY_PATTERN_SYNTAX), + ("Pattern_White_Space", BINARY_PATTERN_WHITE_SPACE), + ("Quotation_Mark", BINARY_QUOTATION_MARK), + ("Radical", BINARY_RADICAL), + ("Regional_Indicator", BINARY_REGIONAL_INDICATOR), + ("Sentence_Terminal", BINARY_SENTENCE_TERMINAL), + ("Soft_Dotted", BINARY_SOFT_DOTTED), + ("Terminal_Punctuation", BINARY_TERMINAL_PUNCTUATION), + ("Unified_Ideograph", BINARY_UNIFIED_IDEOGRAPH), + ("Uppercase", BINARY_UPPERCASE), + ("Variation_Selector", BINARY_VARIATION_SELECTOR), + ("White_Space", BINARY_WHITE_SPACE), + ("XID_Continue", BINARY_XID_CONTINUE), + ("XID_Start", BINARY_XID_START), +]; diff --git a/crates/clazel-js-regexp/src/unicode.rs b/crates/clazel-js-regexp/src/unicode.rs new file mode 100644 index 00000000..47db4bff --- /dev/null +++ b/crates/clazel-js-regexp/src/unicode.rs @@ -0,0 +1,241 @@ +//! The Unicode data the matcher reads: case canonicalization (ECMA-262 +//! §22.2.2.7.3† `Canonicalize`), the equivalence classes it induces, and the +//! property sets of `\p{..}` (§22.2.2.9†, UnicodePropertyValueExpression). +//! +//! The tables are in [`crate::tables`], generated from the vendored UCD. Every +//! lookup is a bisection written here, with a loop that provably ends +//! (`lo` grows or `hi` shrinks on every pass), so that Kani can check it. + +use crate::tables; + +/// Finds `key` in a table of pairs sorted by their first element. +fn find_pair(table: &[(u32, u32)], key: u32) -> Option { + let mut lo = 0usize; + let mut hi = table.len(); + while lo < hi { + let mid = lo.saturating_add(hi.saturating_sub(lo) / 2); + let &(k, v) = table.get(mid)?; + if k == key { + return Some(v); + } + if k < key { + lo = mid.saturating_add(1); + } else { + hi = mid; + } + } + None +} + +/// The index of the first element of `table` (sorted by first element) whose +/// first element is at least `key`. +fn lower_bound(table: &[(u32, u32)], key: u32) -> usize { + let mut lo = 0usize; + let mut hi = table.len(); + while lo < hi { + let mid = lo.saturating_add(hi.saturating_sub(lo) / 2); + match table.get(mid) { + Some(&(k, _)) if k < key => lo = mid.saturating_add(1), + _ => hi = mid, + } + } + lo +} + +/// The range of `ranges` (sorted, disjoint) that holds `c`, as its index. +fn range_index(ranges: &[T], first: impl Fn(T) -> u32, c: u32) -> Option { + // The last range whose first element is at most `c`. + let mut lo = 0usize; + let mut hi = ranges.len(); + while lo < hi { + let mid = lo.saturating_add(hi.saturating_sub(lo) / 2); + match ranges.get(mid) { + Some(&r) if first(r) <= c => lo = mid.saturating_add(1), + _ => hi = mid, + } + } + lo.checked_sub(1) +} + +/// Whether `c` is in one of `ranges` (first, last), sorted and disjoint. +#[must_use] +pub fn in_ranges(ranges: &[(u32, u32)], c: u32) -> bool { + range_index(ranges, |r| r.0, c) + .and_then(|i| ranges.get(i)) + .is_some_and(|&(_, last)| c <= last) +} + +/// Simple Case Folding of `c` (`CaseFolding.txt`, statuses `C` and `S`): what +/// `Canonicalize` returns with `u` or `v` (§22.2.2.7.3† step 2.a). +#[must_use] +pub fn simple_fold(c: u32) -> u32 { + find_pair(tables::SIMPLE_FOLD, c).unwrap_or(c) +} + +/// `Canonicalize` without `u` or `v` of the code unit `c` +/// (§22.2.2.7.3† steps 3 to 7): `toUppercase` of it if that is one code unit, +/// unless that would turn a non-ASCII code unit into an ASCII one. +#[must_use] +pub fn canonicalize_unit(c: u32) -> u32 { + find_pair(tables::UPPER, c).unwrap_or(c) +} + +/// `Canonicalize(rer, c)` (§22.2.2.7.3†) for an expression with `i`: +/// [`simple_fold`] with `unicode` (`u` or `v`), else [`canonicalize_unit`]. +#[must_use] +pub fn canonicalize(c: u32, unicode: bool) -> u32 { + if unicode { + simple_fold(c) + } else { + canonicalize_unit(c) + } +} + +/// Puts into `out` every `a` with `canonicalize(a, unicode) == cc`: the +/// characters CharacterSetMatcher (§22.2.2.7.1† step 3) and the +/// backreference matcher treat as equal to one another. +pub fn equivalents(cc: u32, unicode: bool, out: &mut Vec) { + out.clear(); + if canonicalize(cc, unicode) == cc { + out.push(cc); + } + let inverse = if unicode { + tables::SIMPLE_FOLD_INVERSE + } else { + tables::UPPER_INVERSE + }; + let mut i = lower_bound(inverse, cc); + while let Some(&(k, v)) = inverse.get(i) { + if k != cc { + break; + } + out.push(v); + i = i.saturating_add(1); + } +} + +/// The index into [`tables::CATEGORY_NAMES`] of the general category of `c`. +#[must_use] +pub fn general_category(c: u32) -> u8 { + range_index(tables::GENERAL_CATEGORY, |r| r.0, c) + .and_then(|i| tables::GENERAL_CATEGORY.get(i)) + .map_or(CN, |&(_, last, cat)| if c <= last { cat } else { CN }) +} + +/// The index of `Cn` in [`tables::CATEGORY_NAMES`]. +const CN: u8 = 29; + +/// The bit of a category for a mask of categories. +fn bit(abbr: &str) -> u32 { + tables::CATEGORY_NAMES + .iter() + .position(|n| *n == abbr) + .and_then(|i| u32::try_from(i).ok()) + .and_then(|i| 1u32.checked_shl(i)) + .unwrap_or(0) +} + +fn mask(abbrs: &[&str]) -> u32 { + abbrs.iter().fold(0, |m, a| m | bit(a)) +} + +/// A set of code points named by `\p{..}`. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Prop { + /// The code points whose general category is in the mask (a bit per index + /// of [`tables::CATEGORY_NAMES`]). + Category(u32), + /// A binary property's ranges. + Ranges(&'static [(u32, u32)]), + /// `Any`. + Any, + /// `ASCII`. + Ascii, + /// `Assigned`: every category but `Cn`. + Assigned, +} + +impl Prop { + /// Whether `c` has the property. + #[must_use] + pub fn contains(&self, c: u32) -> bool { + match *self { + Prop::Category(m) => 1u32 + .checked_shl(u32::from(general_category(c))) + .is_some_and(|b| m & b != 0), + Prop::Ranges(r) => in_ranges(r, c), + Prop::Any => c <= 0x10FFFF, + Prop::Ascii => c < 0x80, + Prop::Assigned => general_category(c) != CN, + } + } +} + +/// The mask of the general categories a `General_Category` value (a long name, +/// a short name or an alias, as in `PropertyValueAliases.txt`) stands for: +/// a group such as `L` is the union of its members. +#[must_use] +pub fn category_mask(value: &str) -> Option { + Some(match value { + "Lu" | "Uppercase_Letter" => mask(&["Lu"]), + "Ll" | "Lowercase_Letter" => mask(&["Ll"]), + "Lt" | "Titlecase_Letter" => mask(&["Lt"]), + "LC" | "Cased_Letter" => mask(&["Lu", "Ll", "Lt"]), + "Lm" | "Modifier_Letter" => mask(&["Lm"]), + "Lo" | "Other_Letter" => mask(&["Lo"]), + "L" | "Letter" => mask(&["Lu", "Ll", "Lt", "Lm", "Lo"]), + "Mn" | "Nonspacing_Mark" => mask(&["Mn"]), + "Mc" | "Spacing_Mark" => mask(&["Mc"]), + "Me" | "Enclosing_Mark" => mask(&["Me"]), + "M" | "Mark" | "Combining_Mark" => mask(&["Mn", "Mc", "Me"]), + "Nd" | "Decimal_Number" | "digit" => mask(&["Nd"]), + "Nl" | "Letter_Number" => mask(&["Nl"]), + "No" | "Other_Number" => mask(&["No"]), + "N" | "Number" => mask(&["Nd", "Nl", "No"]), + "Pc" | "Connector_Punctuation" => mask(&["Pc"]), + "Pd" | "Dash_Punctuation" => mask(&["Pd"]), + "Ps" | "Open_Punctuation" => mask(&["Ps"]), + "Pe" | "Close_Punctuation" => mask(&["Pe"]), + "Pi" | "Initial_Punctuation" => mask(&["Pi"]), + "Pf" | "Final_Punctuation" => mask(&["Pf"]), + "Po" | "Other_Punctuation" => mask(&["Po"]), + "P" | "Punctuation" | "punct" => mask(&["Pc", "Pd", "Ps", "Pe", "Pi", "Pf", "Po"]), + "Sm" | "Math_Symbol" => mask(&["Sm"]), + "Sc" | "Currency_Symbol" => mask(&["Sc"]), + "Sk" | "Modifier_Symbol" => mask(&["Sk"]), + "So" | "Other_Symbol" => mask(&["So"]), + "S" | "Symbol" => mask(&["Sm", "Sc", "Sk", "So"]), + "Zs" | "Space_Separator" => mask(&["Zs"]), + "Zl" | "Line_Separator" => mask(&["Zl"]), + "Zp" | "Paragraph_Separator" => mask(&["Zp"]), + "Z" | "Separator" => mask(&["Zs", "Zl", "Zp"]), + "Cc" | "Control" | "cntrl" => mask(&["Cc"]), + "Cf" | "Format" => mask(&["Cf"]), + "Cs" | "Surrogate" => mask(&["Cs"]), + "Co" | "Private_Use" => mask(&["Co"]), + "Cn" | "Unassigned" => mask(&["Cn"]), + "C" | "Other" => mask(&["Cc", "Cf", "Cs", "Co", "Cn"]), + _ => return None, + }) +} + +/// The set a binary property name (canonical or alias, exactly as written) +/// stands for: `Any`, `ASCII` and `Assigned` are the standard's; the others +/// come from [`tables::BINARY`]. +#[must_use] +pub fn binary_property(name: &str) -> Option { + match name { + "Any" => return Some(Prop::Any), + "ASCII" => return Some(Prop::Ascii), + "Assigned" => return Some(Prop::Assigned), + _ => {} + } + let canonical = crate::props::BINARY_PROPERTIES + .iter() + .find(|(full, alias)| *full == name.as_bytes() || *alias == name.as_bytes()) + .map(|(full, _)| *full)?; + tables::BINARY + .iter() + .find(|(n, _)| n.as_bytes() == canonical) + .map(|&(_, r)| Prop::Ranges(r)) +} diff --git a/crates/clazel-js-regexp/src/vm.rs b/crates/clazel-js-regexp/src/vm.rs new file mode 100644 index 00000000..15786d55 --- /dev/null +++ b/crates/clazel-js-regexp/src/vm.rs @@ -0,0 +1,725 @@ +//! The matcher: a loop over a [`Program`]'s instructions and an explicit +//! backtrack stack of bounded size. ECMA-262 §22.2.2† (Pattern Semantics), +//! with `[[Input]]` the code units of the string (read as code points with `u` +//! or `v`). Section numbers marked † are from memory. +//! +//! # Modelling choices +//! +//! - **No recursion**, over the pattern or over the input: the standard's +//! closures became instructions ([`crate::compile`]) and a failure is a pop. +//! Every choice point is a stack entry, and so is every change to a +//! register (a capture, a loop counter) that a failure must undo. +//! - **A bounded stack, the one deviation.** The stack holds at most +//! [`Limits::max_stack`] entries; a match that needs more is +//! [`MatchError::StackOverflow`], where the standard has no limit. The +//! engine turns it into a `RangeError` (phase-7.md item 7.10). The `Vec` +//! grows by doubling, so its allocation can be up to twice that many +//! entries. The registers and the class scratch space depend only on the +//! pattern. +//! - **A step budget and an interrupt hook** (phase-7.md 7.0(g)): every +//! instruction, every entry popped and every character a greedy run +//! consumed is a step; past [`Limits::max_steps`] the match is +//! [`MatchError::StepLimit`], and every 4096 steps the hook is asked +//! whether to stop ([`MatchError::Interrupted`]). A catastrophic pattern +//! runs until one of these, or until the stack is full. +//! - **Indices** are code unit indices, in both modes. In `u`/`v` mode a match +//! that starts inside a surrogate pair starts at the pair's first unit +//! (RegExpBuiltinExec §22.2.7.2† step 12.a: the input index is that of the +//! character that contains the code unit `lastIndex`), and an unanchored +//! search advances by whole code points (AdvanceStringIndex §22.2.7.3†). +//! - **`lastIndex`, `g` and `y`** are the caller's: [`Program::exec`] takes a +//! start index and says whether to try only there (`y`) or to scan forward. +//! - **Lookaround** bodies are atomic (§22.2.2.3.2† Assertion: the body is +//! matched with a continuation that returns its state): when a positive +//! lookahead's body has matched, its choices are dropped, its captures kept. +//! A negative one that matches undoes everything its body did. + +use crate::program::{ClassOp, ClassProg, EscKind, Inst, One, OneKind, Program}; +use crate::stack::{BtStack, Entry}; +use crate::unicode::{canonicalize, equivalents}; + +/// The value of a register that holds no position. +const NONE: usize = usize::MAX; + +/// How many steps pass between asks of the interrupt hook. +const TICK: u64 = 4096; + +/// The matcher's resource limits. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Limits { + /// The most entries the backtrack stack may hold (16 to 24 bytes each). + pub max_stack: usize, + /// The most steps one [`Program::exec`] may take, or `None` for no limit. + pub max_steps: Option, +} + +impl Default for Limits { + /// A million stack entries (at most 24 MB, 48 with the `Vec`'s growth) and no + /// step limit. + fn default() -> Limits { + Limits { + max_stack: 1 << 20, + max_steps: None, + } + } +} + +/// Why a match was abandoned. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MatchError { + /// The backtrack stack reached [`Limits::max_stack`] entries. The engine + /// throws a `RangeError`. + StackOverflow, + /// [`Limits::max_steps`] steps were taken. + StepLimit, + /// The interrupt hook returned `true`. + Interrupted, + /// The program is malformed (an instruction or register that does not + /// exist). Not reachable from [`crate::compile`]'s output. + Corrupt, +} + +impl core::fmt::Display for MatchError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + MatchError::StackOverflow => write!(f, "regular expression backtrack stack is full"), + MatchError::StepLimit => write!(f, "regular expression step limit reached"), + MatchError::Interrupted => write!(f, "regular expression match interrupted"), + MatchError::Corrupt => write!(f, "malformed regular expression program"), + } + } +} + +/// A successful match: the whole match and each group's capture, as code unit +/// indices `(start, end)`, or `None` for a group that did not take part. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Match { + /// Index 0 is the whole match; index `n` is group `n`. + pub captures: Vec>, +} + +impl Match { + /// The capture of group `n` (0 for the whole match). + #[must_use] + pub fn get(&self, n: usize) -> Option<(usize, usize)> { + self.captures.get(n).copied().flatten() + } +} + +impl Program { + /// Matches the pattern against `input`, starting at code unit index + /// `start`. + /// + /// With `sticky` the match must start at `start` (the `y` flag); without, + /// the starting index advances until a match is found or the input ends + /// (RegExpBuiltinExec §22.2.7.2†, steps 12 and 13). The caller decides + /// `start` (`lastIndex`, or 0) and what to do with the result. + /// + /// `interrupt`, if given, is asked every 4096 steps whether to stop. + /// + /// # Errors + /// + /// [`MatchError`]: a limit of `limits` was reached, or the hook said stop. + pub fn exec( + &self, + input: &[u16], + start: usize, + sticky: bool, + limits: &Limits, + interrupt: Option<&mut dyn FnMut() -> bool>, + ) -> Result, MatchError> { + if start > input.len() { + return Ok(None); + } + let mut vm = Vm { + prog: self, + input, + regs: vec![NONE; self.regs], + stack: BtStack::new(limits.max_stack), + steps: 0, + max_steps: limits.max_steps.unwrap_or(u64::MAX), + next_tick: TICK, + hook: interrupt, + eq: Vec::new(), + bools: Vec::new(), + end: 0, + }; + let unicode = self.unicode; + let mut s = start; + // Inside a surrogate pair, the character that contains the unit is the + // pair. + if unicode + && s > 0 + && input.get(s).is_some_and(|u| (0xDC00..0xE000).contains(u)) + && s.checked_sub(1) + .and_then(|p| input.get(p)) + .is_some_and(|u| (0xD800..0xDC00).contains(u)) + { + s = s.saturating_sub(1); + } + loop { + if vm.run(s)? { + return Ok(Some(vm.take_match(s))); + } + if sticky || s >= input.len() { + return Ok(None); + } + // AdvanceStringIndex. + s = match read(input, unicode, s, false) { + Some((_, next)) => next, + None => return Ok(None), + }; + } + } +} + +struct Vm<'a, 'h> { + prog: &'a Program, + input: &'a [u16], + regs: Vec, + stack: BtStack, + steps: u64, + max_steps: u64, + next_tick: u64, + hook: Option<&'h mut dyn FnMut() -> bool>, + /// Scratch space for class matching. + eq: Vec, + bools: Vec, + /// Where the last successful run ended. + end: usize, +} + +/// A code point from a high and a low surrogate. +fn combine(high: u16, low: u16) -> u32 { + 0x10000u32 + .wrapping_add(u32::from(high.wrapping_sub(0xD800)).wrapping_mul(0x400)) + .wrapping_add(u32::from(low.wrapping_sub(0xDC00))) +} + +/// The character at `pos` (forward) or ending at `pos` (backward), and the +/// position past (before) it: a code unit, or with `unicode` a code point. +pub(crate) fn read(input: &[u16], unicode: bool, pos: usize, back: bool) -> Option<(u32, usize)> { + if back { + let p1 = pos.checked_sub(1)?; + let u = *input.get(p1)?; + if unicode + && (0xDC00..0xE000).contains(&u) + && let Some(p0) = p1.checked_sub(1) + && let Some(&h) = input.get(p0) + && (0xD800..0xDC00).contains(&h) + { + return Some((combine(h, u), p0)); + } + Some((u32::from(u), p1)) + } else { + let u = *input.get(pos)?; + let p1 = pos.saturating_add(1); + if unicode + && (0xD800..0xDC00).contains(&u) + && let Some(&l) = input.get(p1) + && (0xDC00..0xE000).contains(&l) + { + return Some((combine(u, l), p1.saturating_add(1))); + } + Some((u32::from(u), p1)) + } +} + +/// LineTerminator (§12.3†). +fn is_line_terminator(c: u32) -> bool { + matches!(c, 0x0A | 0x0D | 0x2028 | 0x2029) +} + +/// WhiteSpace and LineTerminator (§12.2†, §12.3†): what `\s` matches. +fn is_space(c: u32) -> bool { + matches!( + c, + 0x09 | 0x0A | 0x0B | 0x0C | 0x0D | 0x20 | 0xA0 | 0x1680 | 0x2000 + ..=0x200A | 0x2028 | 0x2029 | 0x202F | 0x205F | 0x3000 | 0xFEFF + ) +} + +/// WordCharacters (§22.2.2.9†): ASCII letters, digits and `_`, and with +/// `extras` (`u` or `v` with `i`) the two characters that fold to them. +fn is_word(c: u32, extras: bool) -> bool { + matches!(c, 0x30..=0x39 | 0x41..=0x5A | 0x61..=0x7A | 0x5F) + || (extras && matches!(c, 0x17F | 0x212A)) +} + +fn escape_has(kind: &EscKind, c: u32, extras: bool) -> bool { + match kind { + EscKind::Digit => (0x30..=0x39).contains(&c), + EscKind::Space => is_space(c), + EscKind::Word => is_word(c, extras), + EscKind::Prop(p) => p.contains(c), + } +} + +/// CharacterSetMatcher (§22.2.2.7.1†) for a class: whether the input +/// character `ch` is matched. Runs the class's postfix program on a stack of +/// booleans. +fn class_matches( + cls: &ClassProg, + unicode: bool, + ch: u32, + eq: &mut Vec, + st: &mut Vec, +) -> bool { + eq.clear(); + if cls.ic { + // Step 3: "there exists a member a of A such that Canonicalize(rer, a) + // is cc", with cc the canonical form of the input character. + equivalents(canonicalize(ch, unicode), unicode, eq); + } else { + eq.push(ch); + } + st.clear(); + for op in &cls.ops { + match op { + ClassOp::Char(c) => st.push(eq.contains(c)), + ClassOp::Range(lo, hi) => st.push(eq.iter().any(|a| lo <= a && a <= hi)), + ClassOp::Esc { kind, neg } => st.push( + eq.iter() + .any(|&a| escape_has(kind, a, cls.word_extras) != *neg), + ), + ClassOp::Not => { + let t = st.pop().unwrap_or(false); + st.push(!t); + } + ClassOp::Or(n) => { + let mut acc = false; + for _ in 0..*n { + acc |= st.pop().unwrap_or(false); + } + st.push(acc); + } + ClassOp::And(n) => { + let mut acc = true; + for _ in 0..*n { + acc &= st.pop().unwrap_or(false); + } + st.push(acc); + } + ClassOp::Sub(n) => { + // The operands were pushed in order, so the first is popped last. + let mut first = false; + let mut rest = false; + for i in 0..*n { + let v = st.pop().unwrap_or(false); + if i.saturating_add(1) == *n { + first = v; + } else { + rest |= v; + } + } + st.push(first && !rest); + } + } + } + let found = st.pop().unwrap_or(false); + found != cls.invert +} + +impl Vm<'_, '_> { + fn tick(&mut self, n: u64) -> Result<(), MatchError> { + self.steps = self.steps.saturating_add(n); + if self.steps > self.max_steps { + return Err(MatchError::StepLimit); + } + if self.steps >= self.next_tick { + self.next_tick = self.steps.saturating_add(TICK); + let stop = match self.hook { + Some(ref mut h) => h(), + None => false, + }; + if stop { + return Err(MatchError::Interrupted); + } + } + Ok(()) + } + + fn push(&mut self, e: Entry) -> Result<(), MatchError> { + self.stack.push(e).map_err(|_| MatchError::StackOverflow) + } + + fn reg(&self, r: u32) -> Result { + self.regs + .get(r as usize) + .copied() + .ok_or(MatchError::Corrupt) + } + + /// Writes a register, and pushes what undoes it. + fn set(&mut self, r: u32, v: usize) -> Result<(), MatchError> { + let slot = self.regs.get_mut(r as usize).ok_or(MatchError::Corrupt)?; + let old = *slot; + *slot = v; + self.push(Entry::Restore { reg: r, old }) + } + + fn restore(&mut self, r: u32, old: usize) { + if let Some(slot) = self.regs.get_mut(r as usize) { + *slot = old; + } + } + + /// Matches one character at `pos` (CharacterSetMatcher §22.2.2.7.1† and + /// the matchers for a character and for `.`), returning the new position. + fn step_one(&mut self, one: &One, pos: usize) -> Option { + let unicode = self.prog.unicode; + let (ch, np) = read(self.input, unicode, pos, one.back)?; + let ok = match &one.kind { + OneKind::Char { c, ic } => { + if *ic { + canonicalize(ch, unicode) == *c + } else { + ch == *c + } + } + OneKind::Dot { all } => *all || !is_line_terminator(ch), + OneKind::Class(id) => { + let cls = self.prog.classes.get(*id as usize)?; + class_matches(cls, unicode, ch, &mut self.eq, &mut self.bools) + } + }; + ok.then_some(np) + } + + /// BackreferenceMatcher (§22.2.2.7.2†) against the capture `s..e`: the + /// new position, or `None` if the text does not match. + fn backref(&self, s: usize, e: usize, pos: usize, ic: bool, back: bool) -> Option { + let unicode = self.prog.unicode; + let input = self.input; + if !ic && !unicode { + let len = e.checked_sub(s)?; + let target = if back { + pos.checked_sub(len)? + } else { + pos.checked_add(len)? + }; + let (from, to) = if back { (target, pos) } else { (pos, target) }; + let a = input.get(s..e)?; + let b = input.get(from..to)?; + return (a == b).then_some(target); + } + let canon = |c: u32| if ic { canonicalize(c, unicode) } else { c }; + let mut b = pos; + if back { + let mut a = e; + while a > s { + let (c1, na) = read(input, unicode, a, true)?; + let (c2, nb) = read(input, unicode, b, true)?; + if canon(c1) != canon(c2) { + return None; + } + a = na; + b = nb; + } + } else { + let mut a = s; + while a < e { + let (c1, na) = read(input, unicode, a, false)?; + let (c2, nb) = read(input, unicode, b, false)?; + if canon(c1) != canon(c2) { + return None; + } + a = na; + b = nb; + } + } + Some(b) + } + + /// The instruction `Run`: as many repetitions as match, up to `max`; fail + /// if fewer than `min`; leave one stack entry for the shorter runs. + fn run_loop( + &mut self, + one: &One, + min: usize, + max: usize, + pos: usize, + next_pc: usize, + ) -> Result, MatchError> { + let mut p = pos; + let mut limit = pos; + let mut count = 0usize; + while count < max { + match self.step_one(one, p) { + Some(np) => { + p = np; + count = count.saturating_add(1); + if count == min { + limit = p; + } + } + None => break, + } + } + self.tick(u64::try_from(count).unwrap_or(u64::MAX))?; + if count < min { + return Ok(None); + } + if p != limit { + let pc = u32::try_from(next_pc).map_err(|_| MatchError::Corrupt)?; + self.push(Entry::Run { + pc, + back: one.back, + cur: p, + limit, + })?; + } + Ok(Some((next_pc, p))) + } + + /// Pops the stack, undoing registers, to the nearest choice: the `pc` and + /// position to resume at, or `None` if there is none (the match failed). + fn backtrack(&mut self) -> Result, MatchError> { + let unicode = self.prog.unicode; + loop { + let Some(e) = self.stack.pop() else { + return Ok(None); + }; + self.tick(1)?; + match e { + Entry::Branch { pc, pos } => return Ok(Some((pc as usize, pos))), + Entry::Restore { reg, old } => self.restore(reg, old), + Entry::Run { + pc, + back, + cur, + limit, + } => { + // One character nearer to the limit, never past it. + let n = if back { + read(self.input, unicode, cur, false) + .map_or(limit, |(_, np)| np) + .min(limit) + } else { + read(self.input, unicode, cur, true) + .map_or(limit, |(_, np)| np) + .max(limit) + }; + if n != limit { + self.push(Entry::Run { + pc, + back, + cur: n, + limit, + })?; + } + return Ok(Some((pc as usize, n))); + } + Entry::LookMark { neg, pc, pos } => { + // The body of a lookaround failed: a negative one succeeds. + if neg { + return Ok(Some((pc as usize, pos))); + } + } + } + } + } + + /// A negative lookaround whose body matched: undo what the body did, down + /// to and including its mark. The caller then fails. + fn unwind_look(&mut self) -> Result<(), MatchError> { + loop { + let Some(e) = self.stack.pop() else { + return Err(MatchError::Corrupt); + }; + self.tick(1)?; + match e { + Entry::Restore { reg, old } => self.restore(reg, old), + Entry::LookMark { .. } => return Ok(()), + Entry::Branch { .. } | Entry::Run { .. } => {} + } + } + } + + /// Runs the program from the beginning at input position `start`: whether + /// it matched. On a match, the registers hold the captures and `end` the + /// end of the whole match. + fn run(&mut self, start: usize) -> Result { + let prog = self.prog; + self.regs.fill(NONE); + self.stack.clear(); + let input = self.input; + let mut pc = 0usize; + let mut pos = start; + loop { + self.tick(1)?; + let inst = prog.insts.get(pc).ok_or(MatchError::Corrupt)?; + let next = pc.saturating_add(1); + let step: Option<(usize, usize)> = match inst { + Inst::One(one) => self.step_one(one, pos).map(|np| (next, np)), + Inst::Run { one, min, max } => self.run_loop(one, *min, *max, pos, next)?, + Inst::LineStart { multiline } => { + // §22.2.2.6.1† Assertion, `^`. + let at_start = pos == 0 + || (*multiline + && pos + .checked_sub(1) + .and_then(|p| input.get(p)) + .is_some_and(|&u| is_line_terminator(u32::from(u)))); + at_start.then_some((next, pos)) + } + Inst::LineEnd { multiline } => { + // `$`. + let at_end = pos >= input.len() + || (*multiline + && input + .get(pos) + .is_some_and(|&u| is_line_terminator(u32::from(u)))); + at_end.then_some((next, pos)) + } + Inst::WordBoundary { neg, extras } => { + // `\b`, `\B`: IsWordChar(e - 1) and IsWordChar(e). + let before = pos + .checked_sub(1) + .and_then(|p| input.get(p)) + .is_some_and(|&u| is_word(u32::from(u), *extras)); + let after = input + .get(pos) + .is_some_and(|&u| is_word(u32::from(u), *extras)); + ((before != after) != *neg).then_some((next, pos)) + } + Inst::BackRef { id, ic, back } => { + let groups = prog.backrefs.get(*id as usize).ok_or(MatchError::Corrupt)?; + let mut cap = None; + for &g in groups { + let a = g.saturating_mul(2); + let s = self.reg(a)?; + if s != NONE { + cap = Some((s, self.reg(a.saturating_add(1))?)); + break; + } + } + match cap { + // "If r is undefined, return c(x)." + None => Some((next, pos)), + Some((s, e)) => self.backref(s, e, pos, *ic, *back).map(|np| (next, np)), + } + } + Inst::Split { first, second } => { + self.push(Entry::Branch { pc: *second, pos })?; + Some((*first as usize, pos)) + } + Inst::Jmp(t) => Some((*t as usize, pos)), + Inst::GroupOpen { reg } => { + self.set(*reg, pos)?; + Some((next, pos)) + } + Inst::GroupClose { cap, reg, back } => { + let s = self.reg(*reg)?; + let (a, b) = if *back { (pos, s) } else { (s, pos) }; + let r = cap.saturating_mul(2); + self.set(r, a)?; + self.set(r.saturating_add(1), b)?; + Some((next, pos)) + } + Inst::ResetCaps { first, last } => { + for i in *first..=*last { + let r = i.saturating_mul(2); + if self.reg(r)? != NONE { + self.set(r, NONE)?; + self.set(r.saturating_add(1), NONE)?; + } + } + Some((next, pos)) + } + Inst::CounterInit { reg } => { + self.set(*reg, 0)?; + Some((next, pos)) + } + Inst::SavePos { reg } => { + self.set(*reg, pos)?; + Some((next, pos)) + } + Inst::LoopHead { + counter, + min, + max, + greedy, + body, + exit, + } => { + let n = self.reg(*counter)?; + if n < *min { + Some((*body as usize, pos)) + } else if n >= *max { + Some((*exit as usize, pos)) + } else if *greedy { + self.push(Entry::Branch { pc: *exit, pos })?; + Some((*body as usize, pos)) + } else { + self.push(Entry::Branch { pc: *body, pos })?; + Some((*exit as usize, pos)) + } + } + Inst::LoopEnd { + counter, + pos_reg, + min, + head, + } => { + let n = self.reg(*counter)?; + let began = self.reg(*pos_reg)?; + if n >= *min && began == pos { + None + } else { + self.set(*counter, n.saturating_add(1))?; + Some((*head as usize, pos)) + } + } + Inst::LookStart { neg, end } => { + self.push(Entry::LookMark { + neg: *neg, + pc: *end, + pos, + })?; + Some((next, pos)) + } + Inst::LookEnd { neg } => { + if *neg { + self.unwind_look()?; + None + } else { + let (p, work) = self.stack.commit_look().ok_or(MatchError::Corrupt)?; + self.tick(u64::try_from(work).unwrap_or(u64::MAX))?; + Some((next, p)) + } + } + Inst::Match => { + self.end = pos; + return Ok(true); + } + }; + match step { + Some((p, q)) => { + pc = p; + pos = q; + } + None => match self.backtrack()? { + Some((p, q)) => { + pc = p; + pos = q; + } + None => return Ok(false), + }, + } + } + } + + fn take_match(&self, start: usize) -> Match { + let mut captures = Vec::new(); + captures.push(Some((start, self.end))); + let n = self.prog.capture_count; + for i in 1..=n { + let a = usize::try_from(i.saturating_mul(2)).unwrap_or(usize::MAX); + let s = self.regs.get(a).copied().unwrap_or(NONE); + let e = self.regs.get(a.saturating_add(1)).copied().unwrap_or(NONE); + captures.push((s != NONE && e != NONE).then_some((s, e))); + } + Match { captures } + } +} diff --git a/crates/clazel-js-regexp/tests/differential.rs b/crates/clazel-js-regexp/tests/differential.rs new file mode 100644 index 00000000..216720d1 --- /dev/null +++ b/crates/clazel-js-regexp/tests/differential.rs @@ -0,0 +1,1101 @@ +//! A differential: the matcher against a reference matcher, on random small +//! patterns and inputs. +//! +//! The reference is a direct transcription of ECMA-262 §22.2.2† (Pattern +//! Semantics): Matchers are closures from a state and a continuation to a +//! state or failure, RepeatMatcher recurses exactly as the standard's steps +//! do, and the input is a list of characters (code points with `u` or `v`), +//! indexed by character, not by code unit. It is exponential and recursive, +//! which is the point: it shares nothing with the real matcher's loop, its +//! instruction list or its stack. It reads the same syntax tree +//! ([`clazel_js_regexp::parse`]) and the same case-folding function and +//! property tables (`src/tables.rs`, checked in `tests/tables.rs`); it does not +//! use the real matcher's tables of equivalent characters: for `i` it searches +//! a universe of characters for those with the same `Canonicalize` +//! (CharacterSetMatcher step 3, read literally). +//! +//! Patterns come from a small random grammar over a few letters and the +//! characters where case mappings are interesting: alternation, groups +//! (capturing, named, non-capturing, with modifiers), the quantifiers (greedy +//! and lazy, counted), lookahead and lookbehind, backreferences, `^ $ \b \B`, +//! `.`, classes and escapes, and for `v` class set operations; with +//! the flags `i m s u v` at random. Inputs are random strings over the same +//! characters. For each pattern and input, every start index is tried with and +//! without `y`, and the captures must be equal. + +use std::cell::{Cell, RefCell}; +use std::collections::HashMap; + +use clazel_js_regexp::ast::{ + Assertion, Atom, ClassContents, ClassEscape, ClassItem, ClassSetExpr, ClassSetItem, + ClassSetOperand, Disjunction, Property, Term, TermKind, +}; +use clazel_js_regexp::unicode::{Prop, canonicalize, category_mask}; +use clazel_js_regexp::{Flags, Limits, Pattern, Program, compile, parse}; + +// --------------------------------------------------------------------------- +// The reference matcher. + +type Caps = Vec>; + +/// MatchState: an end index (in characters) and the captures. +#[derive(Clone)] +struct State { + end: usize, + caps: Caps, +} + +/// The flags in scope (modifiers can change them). +#[derive(Clone, Copy)] +struct Fl { + ic: bool, + ml: bool, + dot_all: bool, +} + +type Cont<'k> = &'k dyn Fn(State) -> Option; + +/// The input as characters, with each one's code unit index. +struct Input { + chars: Vec, + /// `pos[i]` is the code unit index of character `i`; `pos[chars.len()]` is + /// the length in code units. + pos: Vec, +} + +fn decode(units: &[u16], unicode: bool) -> Input { + let mut chars = Vec::new(); + let mut pos = Vec::new(); + let mut i = 0usize; + while i < units.len() { + pos.push(i); + let u = units.get(i).copied().unwrap_or(0); + let next = units.get(i.saturating_add(1)).copied(); + match next { + Some(l) + if unicode && (0xD800..0xDC00).contains(&u) && (0xDC00..0xE000).contains(&l) => + { + let cp = 0x10000u32 + .wrapping_add(u32::from(u).wrapping_sub(0xD800).wrapping_mul(0x400)) + .wrapping_add(u32::from(l).wrapping_sub(0xDC00)); + chars.push(cp); + i = i.saturating_add(2); + } + _ => { + chars.push(u32::from(u)); + i = i.saturating_add(1); + } + } + } + pos.push(units.len()); + Input { chars, pos } +} + +struct Reference<'a> { + input: &'a Input, + unicode: bool, + /// Matchers entered before giving up (the reference is exponential). + fuel: Cell, + memo: RefCell>>, +} + +/// Characters among which equivalents are searched: ASCII and Latin-1 and +/// Latin Extended, the places the test alphabet's case mappings live. +fn universe() -> impl Iterator { + (0u32..0x300) + .chain([0x17F, 0x1E9E, 0x212A, 0x2126, 0x3A3, 0x3C2, 0x3C3]) + .chain(0x10400..0x10450) +} + +fn is_lt(c: u32) -> bool { + matches!(c, 0x0A | 0x0D | 0x2028 | 0x2029) +} + +fn basic_word(c: u32) -> bool { + matches!(c, 0x30..=0x39 | 0x41..=0x5A | 0x61..=0x7A | 0x5F) +} + +fn is_space(c: u32) -> bool { + matches!( + c, + 0x09 | 0x0A | 0x0B | 0x0C | 0x0D | 0x20 | 0xA0 | 0xFEFF | 0x2028 | 0x2029 | 0x1680 | 0x2000 + ..=0x200A | 0x202F | 0x205F | 0x3000 + ) +} + +/// The count of left-capturing groups at or inside a term: their numbers. +fn caps_in_kind(k: &TermKind, out: &mut Vec) { + match k { + TermKind::Atom(Atom::Group(g)) => { + if let Some(i) = g.index { + out.push(i); + } + caps_in_disj(&g.body, out); + } + TermKind::Atom(Atom::Modified(m)) => caps_in_disj(&m.body, out), + TermKind::Look(l) => caps_in_disj(&l.body, out), + _ => {} + } +} + +fn caps_in_disj(d: &Disjunction, out: &mut Vec) { + for a in &d.alternatives { + for t in &a.terms { + caps_in_kind(&t.kind, out); + } + } +} + +impl Reference<'_> { + fn burn(&self) -> bool { + let f = self.fuel.get(); + if f == 0 { + return false; + } + self.fuel.set(f.saturating_sub(1)); + true + } + + fn exhausted(&self) -> bool { + self.fuel.get() == 0 + } + + fn canon(&self, c: u32) -> u32 { + canonicalize(c, self.unicode) + } + + /// Every `a` in the universe (and `ch`) with the same Canonicalize as `ch`. + fn equivalents(&self, ch: u32) -> Vec { + let cc = self.canon(ch); + let mut memo = self.memo.borrow_mut(); + let mut v = memo + .entry(cc) + .or_insert_with(|| universe().filter(|&a| self.canon(a) == cc).collect()) + .clone(); + if self.canon(ch) == cc && !v.contains(&ch) { + v.push(ch); + } + v + } + + fn is_word(&self, c: u32, fl: Fl) -> bool { + basic_word(c) || (self.unicode && fl.ic && basic_word(self.canon(c))) + } + + /// Disjunction. + fn disj(&self, d: &Disjunction, fl: Fl, fwd: bool, x: &State, c: Cont<'_>) -> Option { + if !self.burn() { + return None; + } + for alt in &d.alternatives { + if let Some(r) = self.seq(&alt.terms, fl, fwd, x, c) { + return Some(r); + } + } + None + } + + /// Alternative: the terms left to right, or right to left. + fn seq(&self, terms: &[Term], fl: Fl, fwd: bool, x: &State, c: Cont<'_>) -> Option { + let split = if fwd { + terms.split_first() + } else { + terms.split_last() + }; + match split { + None => c(x.clone()), + Some((t, rest)) => self.term(t, fl, fwd, x, &|y| self.seq(rest, fl, fwd, &y, c)), + } + } + + fn term(&self, t: &Term, fl: Fl, fwd: bool, x: &State, c: Cont<'_>) -> Option { + match &t.quantifier { + None => self.kind(&t.kind, fl, fwd, x, c), + Some(q) => { + let mut parens = Vec::new(); + caps_in_kind(&t.kind, &mut parens); + self.repeat(&t.kind, (q.min, q.max, q.greedy), &parens, (fl, fwd), x, c) + } + } + } + + /// RepeatMatcher (§22.2.2.3.2†), step by step. + fn repeat( + &self, + kind: &TermKind, + (min, max, greedy): (u64, Option, bool), + parens: &[u32], + (fl, fwd): (Fl, bool), + x: &State, + c: Cont<'_>, + ) -> Option { + if !self.burn() { + return None; + } + // 1. If max = 0, return c(x). + if max == Some(0) { + return c(x.clone()); + } + // 2. The continuation d. + let d = |y: State| -> Option { + // 2.a. If min = 0 and y's endIndex = x's endIndex, return failure. + if min == 0 && y.end == x.end { + return None; + } + let min2 = if min == 0 { 0 } else { min.saturating_sub(1) }; + let max2 = max.map(|m| m.saturating_sub(1)); + self.repeat(kind, (min2, max2, greedy), parens, (fl, fwd), &y, c) + }; + // 3-4. Clear the captures inside. + let mut xr = x.clone(); + for &i in parens { + if let Some(slot) = xr.caps.get_mut(i as usize) { + *slot = None; + } + } + // 5. If min != 0, return m(xr, d). + if min != 0 { + return self.kind(kind, fl, fwd, &xr, &d); + } + // 6. If greedy is false, try c(x) first. + if !greedy { + if let Some(z) = c(x.clone()) { + return Some(z); + } + return self.kind(kind, fl, fwd, &xr, &d); + } + // 7. Try m(xr, d), then c(x). + if let Some(z) = self.kind(kind, fl, fwd, &xr, &d) { + return Some(z); + } + c(x.clone()) + } + + fn kind(&self, k: &TermKind, fl: Fl, fwd: bool, x: &State, c: Cont<'_>) -> Option { + if !self.burn() { + return None; + } + let chars = &self.input.chars; + let at = |i: usize| chars.get(i).copied(); + match k { + TermKind::Assertion(a) => { + let e = x.end; + let before = e.checked_sub(1).and_then(at); + let after = at(e); + let ok = match a { + Assertion::Start => before.is_none_or(|ch| fl.ml && is_lt(ch)), + Assertion::End => after.is_none_or(|ch| fl.ml && is_lt(ch)), + Assertion::WordBoundary | Assertion::NotWordBoundary => { + let a1 = before.is_some_and(|ch| self.is_word(ch, fl)); + let b1 = after.is_some_and(|ch| self.is_word(ch, fl)); + (a1 != b1) == matches!(a, Assertion::WordBoundary) + } + }; + if ok { c(x.clone()) } else { None } + } + TermKind::Look(l) => { + let r = self.disj(&l.body, fl, !l.behind, x, &Some); + if l.negative { + if r.is_some() { None } else { c(x.clone()) } + } else { + let y = r?; + c(State { + end: x.end, + caps: y.caps, + }) + } + } + TermKind::Atom(a) => self.atom(a, fl, fwd, x, c), + } + } + + /// CharacterSetMatcher (§22.2.2.7.1†). + fn set( + &self, + pred: &dyn Fn(u32) -> bool, + invert: bool, + fl: Fl, + fwd: bool, + x: &State, + c: Cont<'_>, + ) -> Option { + let idx = if fwd { x.end } else { x.end.checked_sub(1)? }; + let ch = *self.input.chars.get(idx)?; + let found = if fl.ic { + self.equivalents(ch).into_iter().any(pred) + } else { + pred(ch) + }; + if found == invert { + return None; + } + let end = if fwd { x.end.saturating_add(1) } else { idx }; + c(State { + end, + caps: x.caps.clone(), + }) + } + + fn escape_has(&self, e: &ClassEscape, a: u32, fl: Fl) -> bool { + match e { + ClassEscape::Digit => (0x30..=0x39).contains(&a), + ClassEscape::NotDigit => !(0x30..=0x39).contains(&a), + ClassEscape::Space => is_space(a), + ClassEscape::NotSpace => !is_space(a), + ClassEscape::Word => self.is_word(a, fl), + ClassEscape::NotWord => !self.is_word(a, fl), + ClassEscape::Property { negated, property } => { + self.property_has(property, a) != *negated + } + } + } + + fn property_has(&self, p: &Property, a: u32) -> bool { + match p { + Property::GeneralCategory(v) => { + category_mask(v).is_some_and(|m| Prop::Category(m).contains(a)) + } + _ => false, + } + } + + /// A positive escape (for `v`, where negation is the complement of the + /// folded set). + fn positive_escape_has(&self, e: &ClassEscape, a: u32, fl: Fl) -> bool { + match e { + ClassEscape::Digit | ClassEscape::NotDigit => (0x30..=0x39).contains(&a), + ClassEscape::Space | ClassEscape::NotSpace => is_space(a), + ClassEscape::Word | ClassEscape::NotWord => self.is_word(a, fl), + ClassEscape::Property { property, .. } => self.property_has(property, a), + } + } + + fn is_negated_escape(e: &ClassEscape) -> bool { + matches!( + e, + ClassEscape::NotDigit + | ClassEscape::NotSpace + | ClassEscape::NotWord + | ClassEscape::Property { negated: true, .. } + ) + } + + /// Membership in a `v` set, with the standard's folding: with `i`, the set + /// is the Canonicalize of each element, and `target` is the input + /// character's Canonicalize. + fn vset_has(&self, e: &ClassSetExpr, target: u32, fl: Fl) -> bool { + let same = |a: u32| { + if fl.ic { + self.canon(a) == target + } else { + a == target + } + }; + let operand = |o: &ClassSetOperand| -> bool { + match o { + ClassSetOperand::Char(c) => same(*c), + ClassSetOperand::Escape(esc) => { + let pos = self.exists(target, fl, |a| self.positive_escape_has(esc, a, fl)); + pos != Self::is_negated_escape(esc) + } + ClassSetOperand::Nested { negated, expr } => { + self.vset_has(expr, target, fl) != *negated + } + ClassSetOperand::Strings(list) => { + list.iter().any(|s| matches!(s.as_slice(), [c] if same(*c))) + } + } + }; + match e { + ClassSetExpr::Union(items) => items.iter().any(|it| match it { + ClassSetItem::Operand(o) => operand(o), + ClassSetItem::Range(lo, hi) => { + if fl.ic { + (*lo..=*hi).any(&same) + } else { + *lo <= target && target <= *hi + } + } + }), + ClassSetExpr::Intersection(os) => os.iter().all(operand), + ClassSetExpr::Subtraction(os) => match os.split_first() { + Some((first, rest)) => operand(first) && !rest.iter().any(operand), + None => false, + }, + } + } + + /// Whether some character that Canonicalizes to `target` (with `i`) or is + /// `target` (without) satisfies `f`. + fn exists(&self, target: u32, fl: Fl, f: impl Fn(u32) -> bool) -> bool { + if fl.ic { + self.equivalents(target).into_iter().any(f) + } else { + f(target) + } + } + + fn atom(&self, a: &Atom, fl: Fl, fwd: bool, x: &State, c: Cont<'_>) -> Option { + match a { + Atom::Char(ch) => self.set(&|a| a == *ch, false, fl, fwd, x, c), + Atom::Dot => { + let idx = if fwd { x.end } else { x.end.checked_sub(1)? }; + let ch = *self.input.chars.get(idx)?; + if !fl.dot_all && is_lt(ch) { + return None; + } + let end = if fwd { x.end.saturating_add(1) } else { idx }; + c(State { + end, + caps: x.caps.clone(), + }) + } + Atom::Escape(e) => { + if self.v_mode() && Self::is_negated_escape(e) { + // `\P{..}` with `v`: the complement of the folded set. + let idx = if fwd { x.end } else { x.end.checked_sub(1)? }; + let ch = *self.input.chars.get(idx)?; + let cc = if fl.ic { self.canon(ch) } else { ch }; + let pos = self.exists(cc, fl, |a| self.positive_escape_has(e, a, fl)); + return if pos { + None + } else { + let end = if fwd { x.end.saturating_add(1) } else { idx }; + c(State { + end, + caps: x.caps.clone(), + }) + }; + } + self.set(&|a| self.escape_has(e, a, fl), false, fl, fwd, x, c) + } + Atom::Class(cls) => match &cls.contents { + ClassContents::Ranges(items) => { + let pred = |a: u32| { + items.iter().any(|it| match it { + ClassItem::Char(ch) => a == *ch, + ClassItem::Range(lo, hi) => *lo <= a && a <= *hi, + ClassItem::Escape(e) => self.escape_has(e, a, fl), + }) + }; + self.set(&pred, cls.negated, fl, fwd, x, c) + } + ClassContents::Set(expr) => { + let idx = if fwd { x.end } else { x.end.checked_sub(1)? }; + let ch = *self.input.chars.get(idx)?; + let cc = if fl.ic { self.canon(ch) } else { ch }; + let has = self.vset_has(expr, cc, fl) != cls.negated; + if !has { + return None; + } + let end = if fwd { x.end.saturating_add(1) } else { idx }; + c(State { + end, + caps: x.caps.clone(), + }) + } + }, + Atom::Group(g) => { + let after = |y: State| -> Option { + match g.index { + None => c(y), + Some(i) => { + let (s, e) = if fwd { (x.end, y.end) } else { (y.end, x.end) }; + let mut caps = y.caps.clone(); + if let Some(slot) = caps.get_mut(i as usize) { + *slot = Some((s, e)); + } + c(State { end: y.end, caps }) + } + } + }; + self.disj(&g.body, fl, fwd, x, &after) + } + Atom::Modified(m) => { + let flag = |cur: bool, add: bool, remove: bool| (cur || add) && !remove; + let inner = Fl { + ic: flag(fl.ic, m.add.ignore_case, m.remove.ignore_case), + ml: flag(fl.ml, m.add.multiline, m.remove.multiline), + dot_all: flag(fl.dot_all, m.add.dot_all, m.remove.dot_all), + }; + self.disj(&m.body, inner, fwd, x, c) + } + Atom::BackReference(n) => self.backref(&[*n], fl, fwd, x, c), + Atom::NamedBackReference(name) => { + let ns: Vec = self + .names() + .iter() + .filter(|(n, _)| n == name) + .map(|&(_, i)| i) + .collect(); + self.backref(&ns, fl, fwd, x, c) + } + } + } + + /// BackreferenceMatcher (§22.2.2.7.2†), over the first group of `ns` that + /// has a capture. + fn backref(&self, ns: &[u32], fl: Fl, fwd: bool, x: &State, c: Cont<'_>) -> Option { + let r = ns + .iter() + .find_map(|&n| x.caps.get(n as usize).copied().flatten()); + let Some((rs, re)) = r else { + return c(x.clone()); + }; + let len = re.checked_sub(rs)?; + let e = x.end; + let f = if fwd { + e.checked_add(len)? + } else { + e.checked_sub(len)? + }; + if f > self.input.chars.len() { + return None; + } + let g = e.min(f); + for i in 0..len { + let a = *self.input.chars.get(rs.checked_add(i)?)?; + let b = *self.input.chars.get(g.checked_add(i)?)?; + let (a, b) = if fl.ic { + (self.canon(a), self.canon(b)) + } else { + (a, b) + }; + if a != b { + return None; + } + } + c(State { + end: f, + caps: x.caps.clone(), + }) + } + + fn v_mode(&self) -> bool { + V_MODE.with(Cell::get) + } + + fn names(&self) -> Vec<(Vec, u32)> { + NAMES.with(|n| n.borrow().clone()) + } +} + +thread_local! { + static V_MODE: Cell = const { Cell::new(false) }; + static NAMES: RefCell, u32)>> = const { RefCell::new(Vec::new()) }; +} + +/// The reference's answer for a match starting at character `start`: +/// the captures in code unit indices, or `Err` if it ran out of fuel. +fn reference_at( + pattern: &Pattern, + flags: Flags, + input: &Input, + start: usize, +) -> Result, ()> { + V_MODE.with(|v| v.set(flags.unicode_sets)); + NAMES.with(|n| *n.borrow_mut() = pattern.group_names.clone()); + let r = Reference { + input, + unicode: flags.unicode_mode(), + fuel: Cell::new(300_000), + memo: RefCell::new(HashMap::new()), + }; + let fl = Fl { + ic: flags.ignore_case, + ml: flags.multiline, + dot_all: flags.dot_all, + }; + let x = State { + end: start, + caps: vec![None; (pattern.capture_count as usize).saturating_add(1)], + }; + let res = r.disj(&pattern.disjunction, fl, true, &x, &Some); + if r.exhausted() { + return Err(()); + } + let to_unit = |i: usize| input.pos.get(i).copied().unwrap_or(usize::MAX); + Ok(res.map(|st| { + let mut caps: Caps = st + .caps + .iter() + .map(|c| c.map(|(s, e)| (to_unit(s), to_unit(e)))) + .collect(); + if let Some(first) = caps.first_mut() { + *first = Some((to_unit(start), to_unit(st.end))); + } + caps + })) +} + +// --------------------------------------------------------------------------- +// Random patterns and inputs. + +struct Rng(u64); + +impl Rng { + fn next(&mut self) -> u64 { + // xorshift64* + let mut x = self.0; + x ^= x.wrapping_shr(12); + x ^= x.wrapping_shl(25); + x ^= x.wrapping_shr(27); + self.0 = x; + x.wrapping_mul(0x2545_F491_4F6C_DD1D) + } + + fn below(&mut self, n: usize) -> usize { + let n = u64::try_from(n).unwrap_or(1).max(1); + usize::try_from(self.next().checked_rem(n).unwrap_or(0)).unwrap_or(0) + } + + fn chance(&mut self, percent: usize) -> bool { + self.below(100) < percent + } + + fn pick<'a, T>(&mut self, list: &'a [T]) -> Option<&'a T> { + list.get(self.below(list.len())) + } +} + +const LETTERS: &[&str] = &["a", "b", "c", "a", "b", "A", "B"]; +const SPECIAL: &[&str] = &[ + "k", "K", "\u{212a}", "s", "S", "\u{17f}", "\u{e9}", "\u{c9}", "1", "_", " ", "-", +]; +const ASTRAL: &[&str] = &["\u{1F600}", "\u{10400}", "\u{10428}"]; + +struct Gen<'r> { + rng: &'r mut Rng, + unicode: bool, + v: bool, + groups: u32, + names: u32, +} + +impl Gen<'_> { + fn s(&mut self, list: &[&str]) -> String { + self.rng.pick(list).copied().unwrap_or("a").to_string() + } + + fn literal(&mut self) -> String { + let r = self.rng.below(100); + if r < 70 { + self.s(LETTERS) + } else if r < 92 || !self.unicode { + self.s(SPECIAL) + } else { + self.s(ASTRAL) + } + } + + fn disjunction(&mut self, depth: u32) -> String { + let n = if self.rng.chance(35) { + self.rng.below(2).saturating_add(2) + } else { + 1 + }; + let alts: Vec = (0..n).map(|_| self.alternative(depth)).collect(); + alts.join("|") + } + + fn alternative(&mut self, depth: u32) -> String { + let n = self.rng.below(4); + (0..n).map(|_| self.term(depth)).collect() + } + + fn quantifier(&mut self) -> String { + let q = self + .rng + .pick(&[ + "*", "+", "?", "{1,2}", "{0,2}", "{2}", "{2,}", "{0,1}", "{1}", + ]) + .copied() + .unwrap_or("*"); + let lazy = if self.rng.chance(30) { "?" } else { "" }; + format!("{q}{lazy}") + } + + fn term(&mut self, depth: u32) -> String { + let r = self.rng.below(100); + let (text, quantifiable) = if r < 36 { + (self.literal(), true) + } else if r < 44 { + (".".to_string(), true) + } else if r < 56 { + (self.class(), true) + } else if r < 62 { + (self.escape(), true) + } else if r < 78 && depth < 3 { + (self.group(depth), true) + } else if r < 85 && depth < 3 { + self.look(depth) + } else if r < 92 { + (self.s(&["^", "$", "\\b", "\\B"]), false) + } else { + (self.backref(), true) + }; + if quantifiable && self.rng.chance(35) { + format!("{text}{}", self.quantifier()) + } else { + text + } + } + + fn escape(&mut self) -> String { + let list: &[&str] = if self.unicode { + &[ + "\\d", "\\w", "\\s", "\\D", "\\W", "\\S", "\\p{Lu}", "\\P{Lu}", "\\p{L}", "\\p{Ll}", + ] + } else { + &["\\d", "\\w", "\\s", "\\D", "\\W", "\\S"] + }; + self.s(list) + } + + fn backref(&mut self) -> String { + if self.names > 0 && self.rng.chance(40) { + let n = self.rng.below(self.names as usize).saturating_add(1); + format!("\\k") + } else { + format!("\\{}", self.rng.below(3).saturating_add(1)) + } + } + + fn group(&mut self, depth: u32) -> String { + let r = self.rng.below(100); + if r < 45 { + self.groups = self.groups.saturating_add(1); + format!("({})", self.disjunction(depth.saturating_add(1))) + } else if r < 62 { + self.names = self.names.saturating_add(1); + self.groups = self.groups.saturating_add(1); + let n = self.names; + format!("(?{})", self.disjunction(depth.saturating_add(1))) + } else if r < 88 { + format!("(?:{})", self.disjunction(depth.saturating_add(1))) + } else { + let m = self + .rng + .pick(&["i", "-i", "s", "-s", "m", "-m", "i-s", "s-i", "ms"]) + .copied() + .unwrap_or("i"); + format!("(?{m}:{})", self.disjunction(depth.saturating_add(1))) + } + } + + fn look(&mut self, depth: u32) -> (String, bool) { + let kind = self + .rng + .pick(&["=", "!", "<=", " String { + self.s(&["a", "b", "c", "A", "B", "k", "s", "1", "_", "\u{e9}"]) + } + + fn class(&mut self) -> String { + let neg = if self.rng.chance(25) { "^" } else { "" }; + if self.v { + return format!("[{neg}{}]", self.v_contents(0)); + } + let n = self.rng.below(3).saturating_add(1); + let items: String = (0..n) + .map(|_| { + let r = self.rng.below(100); + if r < 50 { + self.class_char() + } else if r < 80 { + self.s(&["a-c", "b-b", "A-C", "0-9", "a-z", "A-Z", "\u{c0}-\u{ff}"]) + } else { + self.escape() + } + }) + .collect(); + format!("[{neg}{items}]") + } + + /// The contents of a `v` class: a union, an intersection or a subtraction. + fn v_contents(&mut self, depth: u32) -> String { + let r = self.rng.below(100); + if r < 55 || depth >= 2 { + let n = self.rng.below(3).saturating_add(1); + (0..n) + .map(|_| { + let r = self.rng.below(100); + if r < 40 { + self.class_char() + } else if r < 65 { + self.s(&["a-c", "A-C", "0-9", "a-z"]) + } else if r < 80 { + self.escape() + } else { + format!("[{}]", self.v_contents(depth.saturating_add(1))) + } + }) + .collect() + } else { + let op = if r < 78 { "&&" } else { "--" }; + let n = self.rng.below(2).saturating_add(2); + let operands: Vec = (0..n) + .map(|_| { + let r = self.rng.below(100); + if r < 40 { + format!("[{}]", self.v_contents(depth.saturating_add(1))) + } else if r < 60 { + self.escape() + } else if r < 80 { + format!("[^{}]", self.class_char()) + } else { + self.class_char() + } + }) + .collect(); + operands.join(op) + } + } +} + +const INPUT_CHARS: &[&str] = &[ + "a", + "b", + "c", + "a", + "b", + "A", + "B", + "k", + "K", + "\u{212a}", + "s", + "S", + "\u{17f}", + "\u{e9}", + "\u{c9}", + "1", + "_", + " ", + "\n", + "-", + "\u{1F600}", + "\u{10400}", + "\u{10428}", +]; + +fn random_input(rng: &mut Rng, max_len: usize) -> String { + let n = rng.below(max_len.saturating_add(1)); + (0..n) + .map(|_| rng.pick(INPUT_CHARS).copied().unwrap_or("a")) + .collect() +} + +/// The three kinds of mode, so each gets a share of the patterns. +fn random_flags(rng: &mut Rng) -> (String, Flags) { + let mut s = String::new(); + for (flag, pct) in [('i', 50), ('m', 30), ('s', 30)] { + if rng.chance(pct) { + s.push(flag); + } + } + match rng.below(10) { + 0..=2 => s.push('u'), + 3 | 4 => s.push('v'), + _ => {} + } + let units: Vec = s.encode_utf16().collect(); + let f = Flags::parse(&units).unwrap_or_default(); + (s, f) +} + +fn units(s: &str) -> Vec { + s.encode_utf16().collect() +} + +struct Tally { + patterns: usize, + parse_errors: usize, + compile_errors: usize, + compared: usize, + matched: usize, + out_of_fuel: usize, +} + +/// A pattern under test. +struct Subject<'a> { + pattern: &'a str, + flag_text: &'a str, + flags: Flags, + pat: &'a Pattern, + prog: &'a Program, +} + +fn compare_one( + subject: &Subject<'_>, + input_text: &str, + tally: &mut Tally, + rng: &mut Rng, +) -> Result<(), String> { + let Subject { + pattern, + flag_text, + flags, + pat, + prog, + } = *subject; + let text = units(input_text); + let input = decode(&text, flags.unicode_mode()); + // The standard scan: the first start index (in characters) that matches. + let mut expected: Option = None; + for k in 0..=input.chars.len() { + match reference_at(pat, flags, &input, k) { + Ok(Some(c)) => { + expected = Some(c); + break; + } + Ok(None) => {} + Err(()) => { + tally.out_of_fuel = tally.out_of_fuel.saturating_add(1); + return Ok(()); + } + } + } + let limits = Limits { + max_stack: 1 << 20, + max_steps: Some(50_000_000), + }; + let got = prog + .exec(&text, 0, false, &limits, None) + .map_err(|e| format!("/{pattern}/{flag_text} on {input_text:?}: {e}"))?; + tally.compared = tally.compared.saturating_add(1); + if got.is_some() { + tally.matched = tally.matched.saturating_add(1); + } + if got.map(|m| m.captures) != expected { + return Err(format!( + "/{pattern}/{flag_text} on {input_text:?} (scan): got {:?}, reference {expected:?}", + prog.exec(&text, 0, false, &limits, None) + .ok() + .flatten() + .map(|m| m.captures) + )); + } + // A sticky match at one start index, chosen at random among the + // characters' boundaries. + let k = rng.below(input.chars.len().saturating_add(1)); + let start = input.pos.get(k).copied().unwrap_or(0); + let want = match reference_at(pat, flags, &input, k) { + Ok(c) => c, + Err(()) => return Ok(()), + }; + let got = prog + .exec(&text, start, true, &limits, None) + .map_err(|e| format!("/{pattern}/{flag_text} on {input_text:?} at {start}: {e}"))?; + if got.map(|m| m.captures) != want { + return Err(format!( + "/{pattern}/{flag_text} on {input_text:?} sticky at {start}: differs from the reference ({want:?})" + )); + } + Ok(()) +} + +fn run_differential( + seed: u64, + patterns: usize, + inputs: usize, + max_len: usize, +) -> Result { + let mut rng = Rng(seed); + let mut tally = Tally { + patterns: 0, + parse_errors: 0, + compile_errors: 0, + compared: 0, + matched: 0, + out_of_fuel: 0, + }; + for _ in 0..patterns { + let (flag_text, flags) = random_flags(&mut rng); + let text = { + let mut g = Gen { + rng: &mut rng, + unicode: flags.unicode_mode(), + v: flags.unicode_sets, + groups: 0, + names: 0, + }; + g.disjunction(0) + }; + tally.patterns = tally.patterns.saturating_add(1); + let Ok(pat) = parse(&units(&text), flags) else { + tally.parse_errors = tally.parse_errors.saturating_add(1); + continue; + }; + let Ok(prog) = compile(&pat, flags) else { + tally.compile_errors = tally.compile_errors.saturating_add(1); + continue; + }; + for _ in 0..inputs { + let input = random_input(&mut rng, max_len); + let subject = Subject { + pattern: &text, + flag_text: &flag_text, + flags, + pat: &pat, + prog: &prog, + }; + compare_one(&subject, &input, &mut tally, &mut rng)?; + } + } + Ok(tally) +} + +#[test] +fn matcher_agrees_with_the_reference() -> Result<(), String> { + let (patterns, inputs) = if cfg!(miri) { (40, 3) } else { (6000, 8) }; + let mut total = Tally { + patterns: 0, + parse_errors: 0, + compile_errors: 0, + compared: 0, + matched: 0, + out_of_fuel: 0, + }; + for seed in [0x9E37_79B9_7F4A_7C15u64, 0xD1B5_4A32_D192_ED03] { + let t = run_differential(seed, patterns, inputs, 7)?; + total.patterns = total.patterns.saturating_add(t.patterns); + total.parse_errors = total.parse_errors.saturating_add(t.parse_errors); + total.compile_errors = total.compile_errors.saturating_add(t.compile_errors); + total.compared = total.compared.saturating_add(t.compared); + total.matched = total.matched.saturating_add(t.matched); + total.out_of_fuel = total.out_of_fuel.saturating_add(t.out_of_fuel); + } + println!( + "clazel-conformance: suite=\"differential vs reference matcher\" pass={} xfail=0 fail=0 total={}", + total.compared, total.compared + ); + println!( + "differential: {} patterns, {} parse errors, {} compile errors, {} comparisons ({} with a match), {} out of fuel", + total.patterns, + total.parse_errors, + total.compile_errors, + total.compared, + total.matched, + total.out_of_fuel + ); + // The test must not be vacuous. + assert!(total.compared > total.patterns / 2, "too few comparisons"); + assert!( + total.matched.saturating_mul(10) > total.compared, + "fewer than a tenth of the comparisons found a match" + ); + assert!(total.out_of_fuel.saturating_mul(20) < total.compared); + Ok(()) +} diff --git a/crates/clazel-js-regexp/tests/limits.rs b/crates/clazel-js-regexp/tests/limits.rs new file mode 100644 index 00000000..32479802 --- /dev/null +++ b/crates/clazel-js-regexp/tests/limits.rs @@ -0,0 +1,202 @@ +//! The matcher's limits: the bounded backtrack stack, the step budget and the +//! interrupt hook (phase-7.md items 7.10, 7.0(g) and 7.19), on catastrophic +//! patterns. A catastrophic pattern runs until a limit says stop, and ends in +//! an error value, never in a crash or an unbounded allocation. + +use clazel_js_regexp::{Flags, Limits, MatchError, Program, compile, parse}; + +fn units(s: &str) -> Vec { + s.encode_utf16().collect() +} + +fn build(pattern: &str, flags: &str) -> Result { + let f = Flags::parse(&units(flags)).map_err(|e| format!("{e:?}"))?; + let p = parse(&units(pattern), f).map_err(|e| e.to_string())?; + compile(&p, f).map_err(|e| e.to_string()) +} + +fn is_match( + pattern: &str, + input: &[u16], + limits: &Limits, +) -> Result, String> { + let prog = build(pattern, "")?; + Ok(prog + .exec(input, 0, false, limits, None) + .map(|m| m.is_some())) +} + +/// How big the pathological inputs are: Miri is about 100 times slower. +fn scale(native: usize, miri: usize) -> usize { + if cfg!(miri) { miri } else { native } +} + +#[test] +fn nested_quantifier_hits_the_step_limit() -> Result<(), String> { + // (a*)*b on a run of a's: exponentially many ways to split the run, and + // the empty check keeps the stack shallow, so what stops it is the budget. + let input = units(&"a".repeat(40)); + let limits = Limits { + max_stack: 1 << 20, + max_steps: Some(scale(5_000_000, 20_000) as u64), + }; + assert_eq!( + is_match("(a*)*b", &input, &limits)?, + Err(MatchError::StepLimit) + ); + assert_eq!( + is_match("(a+)+b", &input, &limits)?, + Err(MatchError::StepLimit) + ); + assert_eq!( + is_match("(a|a)*b", &input, &limits)?, + Err(MatchError::StepLimit) + ); + Ok(()) +} + +#[test] +fn small_catastrophic_input_still_finishes() -> Result<(), String> { + // Without a limit the same pattern is just slow: 2^n paths, so n = 14 + // finishes at once and has no match. + let input = units(&"a".repeat(14)); + assert_eq!(is_match("(a*)*b", &input, &Limits::default())?, Ok(false)); + let with_b = units(&format!("{}b", "a".repeat(14))); + assert_eq!(is_match("(a*)*b", &with_b, &Limits::default())?, Ok(true)); + Ok(()) +} + +#[test] +fn deep_backtracking_hits_the_stack_bound() -> Result<(), String> { + // (?:a|aa)*b on a long run of a's with no b: every iteration leaves a + // choice behind, so the first descent is as deep as the input is long. The + // stack is bounded, so it ends in StackOverflow, with memory never + // beyond the bound. + let n = scale(400_000, 2_000); + let input = units(&"a".repeat(n)); + let limits = Limits { + max_stack: scale(1 << 20, 1 << 10), + max_steps: None, + }; + assert_eq!( + is_match("(?:a|aa)*b", &input, &limits)?, + Err(MatchError::StackOverflow) + ); + assert_eq!( + is_match("(?:a|b)*c", &input, &limits)?, + Err(MatchError::StackOverflow) + ); + // The same bound is what a lookahead in a loop meets. + assert_eq!( + is_match("(?:(?=a)a|b)*c", &input, &limits)?, + Err(MatchError::StackOverflow) + ); + Ok(()) +} + +#[test] +fn the_stack_bound_is_exact() -> Result<(), String> { + // `(?:a|b)*c` needs a number of entries that grows with the input; with a + // bound just above what it needs it matches, and with half it overflows. + let input = units(&format!("{}c", "ab".repeat(50))); + let prog = build("(?:a|b)*c", "")?; + let run = |max_stack: usize| { + prog.exec( + &input, + 0, + true, + &Limits { + max_stack, + max_steps: None, + }, + None, + ) + .map(|m| m.is_some()) + }; + assert_eq!(run(1 << 20), Ok(true)); + let mut need = None; + for bound in 1..2000 { + if run(bound) == Ok(true) { + need = Some(bound); + break; + } + } + let need = need.ok_or("never matched")?; + assert_eq!(run(need.saturating_sub(1)), Err(MatchError::StackOverflow)); + // 100 characters, a handful of entries each. + assert!(need > 100 && need < 1000, "{need}"); + Ok(()) +} + +#[test] +fn a_zero_bound_overflows_at_the_first_choice() -> Result<(), String> { + let input = units("ab"); + let limits = Limits { + max_stack: 0, + max_steps: None, + }; + // No choice point, no entry: a plain literal needs no stack. + assert_eq!(is_match("ab", &input, &limits)?, Ok(true)); + assert_eq!( + is_match("a|b", &input, &limits)?, + Err(MatchError::StackOverflow) + ); + Ok(()) +} + +#[test] +fn the_interrupt_hook_is_asked_and_can_stop_the_match() -> Result<(), String> { + let input = units(&"a".repeat(40)); + let prog = build("(a*)*b", "")?; + let mut asked = 0u32; + let mut hook = || { + asked = asked.saturating_add(1); + asked >= 3 + }; + let r = prog.exec(&input, 0, false, &Limits::default(), Some(&mut hook)); + assert_eq!(r, Err(MatchError::Interrupted)); + assert_eq!(asked, 3); + + // A hook that never says stop does not change the result. + let short = units("aaab"); + let prog = build("a+b", "")?; + let mut calls = 0u32; + let mut hook = || { + calls = calls.saturating_add(1); + false + }; + let r = prog + .exec(&short, 0, false, &Limits::default(), Some(&mut hook)) + .map_err(|e| e.to_string())?; + assert!(r.is_some()); + Ok(()) +} + +#[test] +fn errors_leave_nothing_behind() -> Result<(), String> { + // The same program is reusable after an error, and gives the same answers. + let prog = build("(?:a|aa)*b", "")?; + let long = units(&"a".repeat(scale(100_000, 2_000))); + let tight = Limits { + max_stack: 1000, + max_steps: None, + }; + assert_eq!( + prog.exec(&long, 0, false, &tight, None), + Err(MatchError::StackOverflow) + ); + let short = units("aab"); + let m = prog + .exec(&short, 0, false, &Limits::default(), None) + .map_err(|e| e.to_string())? + .ok_or("no match")?; + assert_eq!(m.get(0), Some((0, 3))); + Ok(()) +} + +#[test] +fn error_messages_name_the_limit() { + assert!(MatchError::StackOverflow.to_string().contains("stack")); + assert!(MatchError::StepLimit.to_string().contains("step")); + assert!(MatchError::Interrupted.to_string().contains("interrupted")); +} diff --git a/crates/clazel-js-regexp/tests/matching.rs b/crates/clazel-js-regexp/tests/matching.rs new file mode 100644 index 00000000..86b166cb --- /dev/null +++ b/crates/clazel-js-regexp/tests/matching.rs @@ -0,0 +1,649 @@ +//! The matcher on hand-written patterns and inputs (ECMA-262 §22.2.2†): each +//! feature of the semantics, with the result a conforming engine gives. Every +//! expected value is what the standard's algorithm yields (several are the +//! worked examples of the standard's own text). The differential against a +//! reference matcher is in `differential.rs`; limits and catastrophic patterns +//! are in `limits.rs`. + +use clazel_js_regexp::{CompileError, Flags, Limits, Match, Program, compile, parse}; + +fn units(s: &str) -> Vec { + s.encode_utf16().collect() +} + +fn build(pattern: &str, flags: &str) -> Result { + let f = Flags::parse(&units(flags)).map_err(|e| format!("flags {flags:?}: {e:?}"))?; + let p = parse(&units(pattern), f).map_err(|e| format!("/{pattern}/{flags}: {e}"))?; + compile(&p, f).map_err(|e| format!("/{pattern}/{flags}: {e}")) +} + +/// The captures of the first match as text (`None` for a group that did not +/// take part), with `lastIndex` 0 and `y` taken from the flags. +fn exec_at( + pattern: &str, + flags: &str, + input: &str, + start: usize, +) -> Result>>, String> { + let prog = build(pattern, flags)?; + let sticky = flags.contains('y'); + let text = units(input); + let m = prog + .exec(&text, start, sticky, &Limits::default(), None) + .map_err(|e| format!("/{pattern}/{flags} on {input:?}: {e}"))?; + Ok(m.map(|m| texts(&m, &text))) +} + +fn texts(m: &Match, text: &[u16]) -> Vec> { + m.captures + .iter() + .map(|c| c.and_then(|(a, b)| text.get(a..b).map(String::from_utf16_lossy))) + .collect() +} + +fn exec(pattern: &str, flags: &str, input: &str) -> Result>>, String> { + exec_at(pattern, flags, input, 0) +} + +const N: Option<&str> = None; + +/// `(pattern, flags, input, expected)`; `expected` is the whole match and +/// then each group, or `None` for no match. +type Case = ( + &'static str, + &'static str, + &'static str, + Option<&'static [Option<&'static str>]>, +); + +fn run(suite: &str, cases: &[Case]) -> Result<(), String> { + let mut bad = Vec::new(); + for &(pattern, flags, input, want) in cases { + let got = exec(pattern, flags, input)?; + let want: Option>> = + want.map(|w| w.iter().map(|x| x.map(str::to_string)).collect()); + if got != want { + bad.push(format!( + "/{pattern}/{flags}.exec({input:?}): got {got:?}, want {want:?}" + )); + } + } + println!( + "clazel-conformance: suite=\"{suite}\" pass={} xfail=0 fail={} total={}", + cases.len().saturating_sub(bad.len()), + bad.len(), + cases.len() + ); + if bad.is_empty() { + Ok(()) + } else { + Err(bad.join("\n")) + } +} + +#[test] +fn literals_alternation_and_quantifiers() -> Result<(), String> { + run( + "matcher: literals, alternation, quantifiers", + &[ + ("abc", "", "xxabcxx", Some(&[Some("abc")])), + ("abc", "", "ab", None), + ("", "", "abc", Some(&[Some("")])), + ("a|ab", "", "abc", Some(&[Some("a")])), + ("(a)|b", "", "b", Some(&[Some("b"), N])), + ("(a)|(b)", "", "b", Some(&[Some("b"), N, Some("b")])), + ("a*", "", "aaa", Some(&[Some("aaa")])), + ("a*?", "", "aaa", Some(&[Some("")])), + ("a+?", "", "aaa", Some(&[Some("a")])), + ("a?", "", "b", Some(&[Some("")])), + ("a{2,3}", "", "aaaa", Some(&[Some("aaa")])), + ("a{2,3}?", "", "aaaa", Some(&[Some("aa")])), + ("a{2}", "", "a", None), + ("a{2,}", "", "aaaa", Some(&[Some("aaaa")])), + ("a{0}b", "", "ab", Some(&[Some("b")])), + ("(?:ab){2}", "", "ababab", Some(&[Some("abab")])), + ("(?:ab){2,}?", "", "ababab", Some(&[Some("abab")])), + ( + "(a|ab)(c|bcd)(d*)", + "", + "abcd", + Some(&[Some("abcd"), Some("a"), Some("bcd"), Some("")]), + ), + ("a+b", "", "aaab", Some(&[Some("aaab")])), + ("a+?b", "", "aaab", Some(&[Some("aaab")])), + ("a*b", "", "aaac", None), + ("x*y+$", "", "xxyy", Some(&[Some("xxyy")])), + ("(?:)*", "", "x", Some(&[Some("")])), + // A brace that is no quantifier (Annex B). + ("a{", "", "a{", Some(&[Some("a{")])), + ("a{,5}", "", "a{,5}", Some(&[Some("a{,5}")])), + ("x{1}", "", "x", Some(&[Some("x")])), + ], + ) +} + +#[test] +fn captures_and_the_empty_check() -> Result<(), String> { + run( + "matcher: captures, the empty check", + &[ + // §22.2.2.3.1† RepeatMatcher's notes: an iteration beyond the + // least number that matches the empty string fails. + ("(a*)*", "", "b", Some(&[Some(""), N])), + ("(a*)+", "", "b", Some(&[Some(""), Some("")])), + ("(a*)*", "", "aa", Some(&[Some("aa"), Some("aa")])), + ("(a?)*", "", "aa", Some(&[Some("aa"), Some("a")])), + ("(?:a?)*?b", "", "aab", Some(&[Some("aab")])), + // The standard's example: the captures are reset on each iteration. + ( + "(z)((a+)?(b+)?(c))*", + "", + "zaacbbbcac", + Some(&[ + Some("zaacbbbcac"), + Some("z"), + Some("ac"), + Some("a"), + N, + Some("c"), + ]), + ), + ("(?:(a)|b)*", "", "ab", Some(&[Some("ab"), N])), + ("(?:(a)|(b))+", "", "ab", Some(&[Some("ab"), N, Some("b")])), + ( + "((a)|(b))*?c", + "", + "abc", + Some(&[Some("abc"), Some("b"), N, Some("b")]), + ), + ( + "(a)(?:(b)|c)\\2", + "", + "acb", + Some(&[Some("ac"), Some("a"), N]), + ), + // Backreferences. + ("(a)\\1", "", "aa", Some(&[Some("aa"), Some("a")])), + ("(a)\\1", "", "ab", None), + ("\\1(a)", "", "aa", Some(&[Some("a"), Some("a")])), + ("(a\\1)", "", "a", Some(&[Some("a"), Some("a")])), + ("(a)|\\1b", "", "b", Some(&[Some("b"), N])), + ("(?a)\\k", "", "aa", Some(&[Some("aa"), Some("a")])), + ("(a)\\2", "", "a\u{2}", Some(&[Some("a\u{2}"), Some("a")])), + ("\\1", "", "\u{1}", Some(&[Some("\u{1}")])), + // Duplicate names: the group that took part. + ( + "(?:(?a)|(?b))\\k", + "", + "bb", + Some(&[Some("bb"), N, Some("b")]), + ), + ( + "(?:(?a)|(?b))\\k", + "", + "aa", + Some(&[Some("aa"), Some("a"), N]), + ), + ("(?:(?a)|(?b))\\k", "", "ab", None), + ], + ) +} + +#[test] +fn assertions_and_dot() -> Result<(), String> { + run( + "matcher: assertions, dot", + &[ + ("^b", "", "a\nb", None), + ("^b", "m", "a\nb", Some(&[Some("b")])), + ("a$", "", "a\nb", None), + ("a$", "m", "a\nb", Some(&[Some("a")])), + ("^$", "", "", Some(&[Some("")])), + ("^$", "m", "a\n\nb", Some(&[Some("")])), + ("^b", "m", "a\u{2028}b", Some(&[Some("b")])), + ("^b", "m", "a\u{b}b", None), + ("\\bfoo\\b", "", "a foo b", Some(&[Some("foo")])), + ("\\bfoo\\b", "", "afoo b", None), + ("\\Boo", "", "foo", Some(&[Some("oo")])), + ("\\b", "", "", None), + ("\\B", "", "", Some(&[Some("")])), + ("\\b", "", "-a", Some(&[Some("")])), + (".", "", "\n", None), + (".", "s", "\n", Some(&[Some("\n")])), + (".", "", "\u{2028}", None), + (".", "", "\r", None), + (".+", "", "ab\ncd", Some(&[Some("ab")])), + (".+", "s", "ab\ncd", Some(&[Some("ab\ncd")])), + ("(?s:.)", "", "\n", Some(&[Some("\n")])), + ("(?-s:.)", "s", "\n", None), + ("(?m:^b)", "", "a\nb", Some(&[Some("b")])), + ("(?-m:^b)", "m", "a\nb", None), + ("(?m:^b)^", "", "a\nb", None), + ], + ) +} + +#[test] +fn lookaround() -> Result<(), String> { + run( + "matcher: lookahead, lookbehind", + &[ + ("a(?=b)", "", "ab", Some(&[Some("a")])), + ("a(?!b)", "", "ab", None), + ("a(?!b)", "", "ac", Some(&[Some("a")])), + ("(?=(a))\\1", "", "aa", Some(&[Some("a"), Some("a")])), + ("(?!(a))\\1", "", "b", Some(&[Some(""), N])), + // The standard's example: no backtracking into a lookahead. + ( + "(?=(a+))a*b\\1", + "", + "baaabac", + Some(&[Some("aba"), Some("a")]), + ), + ( + "(.*?)a(?!(a+)b\\2c)\\2(.*)", + "", + "baaabaac", + Some(&[Some("baaabaac"), Some("ba"), N, Some("abaac")]), + ), + ("(?=a)*b", "", "b", Some(&[Some("b")])), + ("(?<=a)b", "", "ab", Some(&[Some("b")])), + ("(?<=a)b", "", "cb", None), + ("(? Result<(), String> { + run( + "matcher: classes, escapes", + &[ + ("[^a]", "", "a", None), + ("[^a]", "", "ab", Some(&[Some("b")])), + ("[]", "", "a", None), + ("[^]", "", "\n", Some(&[Some("\n")])), + ("[\\d-x]", "", "-", Some(&[Some("-")])), + ("[a-c]+", "", "abcd", Some(&[Some("abc")])), + ("[\\w-]+", "", "a-b c", Some(&[Some("a-b")])), + ("[\\b]", "", "\u{8}", Some(&[Some("\u{8}")])), + ("\\s", "", "\u{a0}", Some(&[Some("\u{a0}")])), + ("\\s", "", "\u{feff}", Some(&[Some("\u{feff}")])), + ("\\s", "", "\u{200b}", None), + ( + "\\s+", + "", + "a \t\n\u{2003}b", + Some(&[Some(" \t\n\u{2003}")]), + ), + ("\\S+", "", " ab ", Some(&[Some("ab")])), + ("\\d+", "", "a12b", Some(&[Some("12")])), + ("\\D+", "", "12ab3", Some(&[Some("ab")])), + ("\\w+", "", "-ab_1-", Some(&[Some("ab_1")])), + ("\\W", "", "ab-", Some(&[Some("-")])), + ( + "\\x41\\u0042\\cJ\\0", + "", + "AB\n\u{0}", + Some(&[Some("AB\n\u{0}")]), + ), + ("\\101", "", "A", Some(&[Some("A")])), + ("[\\x41-\\x43]+", "", "ABCD", Some(&[Some("ABC")])), + ("[a-z&&[aeiou]]", "", "&]", Some(&[Some("&]")])), + ], + ) +} + +#[test] +fn ignore_case() -> Result<(), String> { + run( + "matcher: ignore case", + &[ + ("abc", "i", "ABC", Some(&[Some("ABC")])), + ("ABC", "i", "abc", Some(&[Some("abc")])), + ("[a-z]+", "i", "ABC", Some(&[Some("ABC")])), + ("[^a-z]", "i", "ABC1", Some(&[Some("1")])), + ("(a)\\1", "i", "aA", Some(&[Some("aA"), Some("a")])), + ("(?<=(a))\\1", "i", "aA", Some(&[Some("A"), Some("a")])), + // Without u: toUpperCase of the code unit, never into or out of ASCII. + ("\u{e9}", "i", "\u{c9}", Some(&[Some("\u{c9}")])), + ("\u{3c3}", "i", "\u{3c2}", Some(&[Some("\u{3c2}")])), + ("\u{212a}", "i", "k", None), + ("k", "i", "\u{212a}", None), + ("\u{17f}", "i", "s", None), + ("s", "i", "\u{17f}", None), + ("\u{df}", "i", "SS", None), + ("\\w", "i", "\u{17f}", None), + ("\\w", "i", "\u{212a}", None), + ("[\u{17f}]", "i", "S", None), + // With u: simple case folding. + ("\u{212a}", "iu", "k", Some(&[Some("k")])), + ("k", "iu", "\u{212a}", Some(&[Some("\u{212a}")])), + ("[k]", "iu", "\u{212a}", Some(&[Some("\u{212a}")])), + ("\u{17f}", "iu", "S", Some(&[Some("S")])), + ("\u{df}", "iu", "SS", None), + ("\u{df}", "iu", "\u{1e9e}", Some(&[Some("\u{1e9e}")])), + ("\\w", "iu", "\u{17f}", Some(&[Some("\u{17f}")])), + ("\\w", "iu", "\u{212a}", Some(&[Some("\u{212a}")])), + ("\\W", "iu", "S", None), + ("\\W", "iu", "\u{17f}", None), + ("\\bk", "iu", "\u{212a}", Some(&[Some("\u{212a}")])), + ("\u{10400}", "iu", "\u{10428}", Some(&[Some("\u{10428}")])), + ( + "[\u{10400}-\u{10410}]", + "iu", + "\u{10428}", + Some(&[Some("\u{10428}")]), + ), + ("\u{1c5}", "i", "\u{1c4}", Some(&[Some("\u{1c4}")])), + ("\u{1c5}", "i", "\u{1c6}", Some(&[Some("\u{1c6}")])), + ("\\p{Lu}", "iu", "a", Some(&[Some("a")])), + ("\\p{Lu}", "u", "a", None), + ("\\p{Ll}", "iu", "A", Some(&[Some("A")])), + // Without v, a negated escape is complemented before folding: the + // standard's behaviour, which v fixes. + ("\\P{Lu}", "iu", "A", Some(&[Some("A")])), + ("\\P{Lu}", "iv", "A", None), + ("[^\\P{Lu}]", "iv", "a", Some(&[Some("a")])), + ("[^\\p{Lu}]", "iv", "a", None), + ("[^\\p{Lu}]", "iu", "a", None), + ("\\D", "iu", "5", None), + ("(?i:a)b", "", "Ab", Some(&[Some("Ab")])), + ("(?i:a)b", "", "AB", None), + ("(?-i:a)b", "i", "aB", Some(&[Some("aB")])), + ("(?-i:a)b", "i", "AB", None), + ("(?i:[a-b]+)", "", "aBcD", Some(&[Some("aB")])), + ], + ) +} + +#[test] +fn unicode_mode() -> Result<(), String> { + run( + "matcher: code points", + &[ + ("^.$", "u", "\u{1F600}", Some(&[Some("\u{1F600}")])), + ("^.$", "", "\u{1F600}", None), + ("^..$", "", "\u{1F600}", Some(&[Some("\u{1F600}")])), + ("^.$", "v", "\u{1F600}", Some(&[Some("\u{1F600}")])), + ("\\u{1F600}", "u", "\u{1F600}", Some(&[Some("\u{1F600}")])), + ( + "\\ud83d\\ude00", + "u", + "\u{1F600}", + Some(&[Some("\u{1F600}")]), + ), + ("[\u{1F600}]", "u", "\u{1F600}", Some(&[Some("\u{1F600}")])), + ( + "[\u{1F600}-\u{1F64F}]+", + "u", + "x\u{1F601}\u{1F602}", + Some(&[Some("\u{1F601}\u{1F602}")]), + ), + ("^[^x]$", "u", "\u{1F600}", Some(&[Some("\u{1F600}")])), + ("^[^x]$", "", "\u{1F600}", None), + ( + "\u{1F600}+", + "u", + "\u{1F600}\u{1F600}", + Some(&[Some("\u{1F600}\u{1F600}")]), + ), + // Without u the quantifier is on the low surrogate alone. + ( + "\u{1F600}+", + "", + "\u{1F600}\u{1F600}", + Some(&[Some("\u{1F600}")]), + ), + // A lone surrogate is not half of a pair with u. + ("\\ud83d", "u", "\u{1F600}", None), + ("\\ud83d", "u", "\u{FFFD}", None), + ("\\ude00", "u", "\u{1F600}", None), + ( + "(?<=\\ud83d)\\ude00", + "", + "\u{1F600}", + Some(&[Some("\u{FFFD}")]), + ), + ( + "(.)\\1", + "u", + "\u{1F600}\u{1F600}", + Some(&[Some("\u{1F600}\u{1F600}"), Some("\u{1F600}")]), + ), + ( + "(?<=(.))x", + "u", + "\u{1F600}x", + Some(&[Some("x"), Some("\u{1F600}")]), + ), + ("\\b", "u", "\u{1F600}", None), + (".+?", "u", "\u{1F600}", Some(&[Some("\u{1F600}")])), + ( + ".{2}", + "u", + "\u{1F600}\u{1F601}", + Some(&[Some("\u{1F600}\u{1F601}")]), + ), + ( + "^.{3}$", + "u", + "\u{1F600}a\u{1F601}", + Some(&[Some("\u{1F600}a\u{1F601}")]), + ), + ], + ) +} + +#[test] +fn property_escapes() -> Result<(), String> { + run( + "matcher: property escapes", + &[ + ("\\p{Lu}", "u", "aBc", Some(&[Some("B")])), + ( + "\\p{L}+", + "u", + "h\u{e9}llo w\u{f6}rld", + Some(&[Some("h\u{e9}llo")]), + ), + ("\\p{Letter}+", "u", "ab1", Some(&[Some("ab")])), + ("\\p{gc=Nd}", "u", "x\u{663}", Some(&[Some("\u{663}")])), + ( + "\\p{General_Category=Decimal_Number}", + "u", + "x\u{663}", + Some(&[Some("\u{663}")]), + ), + ("\\P{L}", "u", "ab1", Some(&[Some("1")])), + ("\\p{ASCII}", "u", "\u{e9}a", Some(&[Some("a")])), + ("\\p{Any}", "u", "\u{1F600}", Some(&[Some("\u{1F600}")])), + ("\\p{Cn}", "u", "a\u{378}", Some(&[Some("\u{378}")])), + ("\\p{Assigned}", "u", "\u{378}a", Some(&[Some("a")])), + ("\\p{Alphabetic}+", "u", "ab1", Some(&[Some("ab")])), + ("\\p{Alpha}+", "u", "ab1", Some(&[Some("ab")])), + ("\\p{Emoji}", "u", "a\u{1F600}", Some(&[Some("\u{1F600}")])), + ( + "\\p{White_Space}", + "u", + "a\u{2003}", + Some(&[Some("\u{2003}")]), + ), + ("\\p{Uppercase}", "u", "aB", Some(&[Some("B")])), + ("\\p{ID_Start}+", "u", "$ab1", Some(&[Some("ab")])), + ("\\p{Hex_Digit}+", "u", "xfF9g", Some(&[Some("fF9")])), + ("\\p{Cs}", "u", "a", None), + ("[\\p{L}\\p{N}]+", "u", "-a1-", Some(&[Some("a1")])), + ("[^\\p{L}]", "u", "a1", Some(&[Some("1")])), + ("\\p{Lu}", "v", "aB", Some(&[Some("B")])), + ("\\p{Sc}", "u", "a$", Some(&[Some("$")])), + ("\\p{Pd}", "u", "a-", Some(&[Some("-")])), + ("\\p{Zs}", "u", "a ", Some(&[Some(" ")])), + ("\\p{Cc}", "u", "a\n", Some(&[Some("\n")])), + ("\\p{Cased_Letter}+", "u", "aB1", Some(&[Some("aB")])), + ], + ) +} + +#[test] +fn unicode_sets() -> Result<(), String> { + run( + "matcher: v-mode class sets", + &[ + ("[\\p{L}--[a-z]]", "v", "aB", Some(&[Some("B")])), + ("[[a-z]&&[aeiou]]+", "v", "hello", Some(&[Some("e")])), + ("[[a-z]--[aeiou]]+", "v", "hello", Some(&[Some("h")])), + ("[^[a-z]]", "v", "aB", Some(&[Some("B")])), + ("[\\w--\\d]+", "v", "12ab3", Some(&[Some("ab")])), + ("[\\q{abc|d}]", "v", "xabc", Some(&[Some("abc")])), + ("[\\q{abc|ab}]", "v", "abx", Some(&[Some("ab")])), + ("[\\q{ab|abc}]", "v", "abcx", Some(&[Some("abc")])), + ("^[\\q{ab|}]$", "v", "", Some(&[Some("")])), + ("^[\\q{ab|}]$", "v", "ab", Some(&[Some("ab")])), + ("[\\q{ab}x]+", "v", "xabx", Some(&[Some("xabx")])), + ("[\\q{a}b]+", "v", "ab", Some(&[Some("ab")])), + ("[\\q{abc}--\\q{abc}]", "v", "abc", None), + ("[\\q{ab|cd}&&\\q{cd|ef}]", "v", "abcd", Some(&[Some("cd")])), + ("[\\q{ab|cd}--\\q{cd}]", "v", "cdab", Some(&[Some("ab")])), + ("[\\q{ab}]", "iv", "AB", Some(&[Some("AB")])), + ("(?<=[\\q{ab|c}])d", "v", "abd", Some(&[Some("d")])), + ("[\\q{ab|c}]d", "v", "abd", Some(&[Some("abd")])), + ("[[a-c]&&[b-d]]", "v", "abcd", Some(&[Some("b")])), + ("[[a-c][x-z]]+", "v", "abxy-", Some(&[Some("abxy")])), + ], + ) +} + +#[test] +fn start_index_and_sticky() -> Result<(), String> { + let some = |p: &str, f: &str, s: &str, at: usize, want: Option<(usize, usize)>| { + let prog = build(p, f)?; + let m = prog + .exec(&units(s), at, f.contains('y'), &Limits::default(), None) + .map_err(|e| e.to_string())?; + let got = m.and_then(|m| m.get(0)); + if got == want { + Ok(()) + } else { + Err(format!( + "/{p}/{f} at {at} on {s:?}: got {got:?}, want {want:?}" + )) + } + }; + some("a", "", "aaa", 1, Some((1, 2)))?; + some("a", "y", "aaa", 1, Some((1, 2)))?; + some("b", "y", "ab", 0, None)?; + some("b", "", "ab", 0, Some((1, 2)))?; + some("b", "y", "ab", 1, Some((1, 2)))?; + some("^a", "", "aa", 1, None)?; + some("^a", "m", "a\na", 1, Some((2, 3)))?; + some("", "", "abc", 3, Some((3, 3)))?; + some("", "", "abc", 4, None)?; + some("a", "", "abc", 4, None)?; + some("(?<=a)b", "y", "ab", 1, Some((1, 2)))?; + some("\\b", "", "ab cd", 2, Some((2, 2)))?; + // A start inside a surrogate pair is the pair's start, with u or v; and an + // unanchored search steps by code points. + some(".", "uy", "\u{1F600}", 1, Some((0, 2)))?; + some(".", "y", "\u{1F600}", 1, Some((1, 2)))?; + some("\\udc00|x", "u", "\u{10000}x", 0, Some((2, 3)))?; + some("^", "", "\u{1F600}", 1, None)?; + Ok(()) +} + +#[test] +fn many_repetitions_in_a_long_input() -> Result<(), String> { + // A run of one character takes one stack entry, however long. (Under Miri + // the input is shorter, to keep the test under its time limit.) + let n: usize = if cfg!(miri) { 300 } else { 100_000 }; + let a = "a".repeat(n); + let input = format!("{a}b"); + let r = exec("a*b", "", &input)?; + assert_eq!(r.map(|v| v.len()), Some(1)); + let r = exec("a*a*a*b", "", &input)?; + assert!(r.is_some()); + let r = exec("[a-z]+?b", "", &input)?; + assert!(r.is_some()); + let r = exec("(?:a|b)*b", "", &input)?; + assert!(r.is_some()); + // A large count is a counter, not a copy of the body. + let r = exec(&format!("a{{{n}}}b"), "", &input)?; + assert!(r.is_some()); + let r = exec(&format!("(?:a){{{}}}ab", n - 1), "", &input)?; + assert!(r.is_some()); + // A count beyond the input fails, after trying every start. + let short = "a".repeat(if cfg!(miri) { 50 } else { 2000 }); + let r = exec("a{4000000000}", "", &short)?; + assert!(r.is_none()); + Ok(()) +} + +#[test] +fn named_groups_through_the_api() -> Result<(), String> { + let prog = build("(?:(?a)|(?b))(?c)?", "")?; + let text = units("bc"); + let m = prog + .exec(&text, 0, false, &Limits::default(), None) + .map_err(|e| e.to_string())? + .ok_or("no match")?; + let name = |s: &str| s.chars().map(u32::from).collect::>(); + assert_eq!(prog.named_capture(&m, &name("x")), Some((0, 1))); + assert_eq!(prog.named_capture(&m, &name("y")), Some((1, 2))); + assert_eq!(prog.named_capture(&m, &name("z")), None); + assert_eq!(prog.capture_count(), 3); + assert_eq!(prog.group_names().len(), 3); + assert!(!prog.unicode()); + Ok(()) +} + +#[test] +fn properties_without_a_table_are_not_compiled() -> Result<(), String> { + for (p, flags) in [ + ("\\p{Script=Latin}", "u"), + ("\\p{sc=Latn}", "u"), + ("\\p{scx=Grek}", "v"), + ("[\\p{RGI_Emoji}]", "v"), + ("\\p{Basic_Emoji}", "v"), + ] { + let f = Flags::parse(&units(flags)).map_err(|e| format!("{e:?}"))?; + let pat = parse(&units(p), f).map_err(|e| e.to_string())?; + match compile(&pat, f) { + Err(CompileError::UnsupportedProperty(_)) => {} + other => return Err(format!("/{p}/{flags}: {other:?}")), + } + } + Ok(()) +} diff --git a/crates/clazel-js-regexp/tests/tables.rs b/crates/clazel-js-regexp/tests/tables.rs new file mode 100644 index 00000000..1e0cae62 --- /dev/null +++ b/crates/clazel-js-regexp/tests/tables.rs @@ -0,0 +1,561 @@ +//! The generated tables (`src/tables.rs`) against the vendored Unicode 18.0.0 +//! files (`tests/data/ucd-regexp/`, phase-7.md item 7.1). +//! +//! This file is the generator: [`render`] writes the whole of `src/tables.rs` +//! from the UCD, and the test `tables_are_current` fails if the committed file +//! differs from what it writes. To rewrite the file after changing this +//! generator or the data, run +//! `CLAZEL_WRITE_TABLES=1 cargo test -p clazel-js-regexp --test tables` +//! and then `cargo fmt -p clazel-js-regexp` (the output is already what rustfmt +//! writes, so the second step changes nothing; the test is what says so). +//! +//! What it derives, and from which file: +//! +//! - `SIMPLE_FOLD`: Simple Case Folding, the `C` and `S` rows of +//! `CaseFolding.txt` (ECMA-262's `Canonicalize` with `u` or `v`, §22.2.2.7.3†), +//! and `SIMPLE_FOLD_INVERSE`, the same pairs sorted by their second element. +//! - `UPPER`: `toUppercase` of a BMP code point where the result is one BMP +//! code point, different from the argument, and not an ASCII letter for a +//! non-ASCII argument (`Canonicalize` without `u` or `v`): the full +//! unconditional mapping of `SpecialCasing.txt` where it has one, else the +//! simple uppercase of `UnicodeData.txt`. `UPPER_INVERSE` likewise. +//! - `GENERAL_CATEGORY`: the ranges of `DerivedGeneralCategory.txt`, every +//! code point covered, a gap being `Cn`. +//! - One table per binary property of ECMA-262's list, from +//! `PropList.txt`, `DerivedCoreProperties.txt`, `DerivedNormalizationProps.txt`, +//! `DerivedBinaryProperties.txt` or `emoji-data.txt` (the first that lists it). +//! +//! The other tests are independent checks of the committed tables: the +//! categories against `UnicodeData.txt` (a different file from the one the +//! table is made from), and spot checks of the case mappings. + +use std::collections::BTreeMap; +use std::fmt::Write as _; +use std::path::PathBuf; + +use clazel_js_regexp::props::BINARY_PROPERTIES; +use clazel_js_regexp::tables; +use clazel_js_regexp::unicode::{canonicalize, equivalents, simple_fold}; + +const LAST: u32 = 0x10FFFF; + +/// The thirty general categories, in the order of the table's index. +const CATEGORIES: [&str; 30] = [ + "Lu", "Ll", "Lt", "Lm", "Lo", "Mn", "Mc", "Me", "Nd", "Nl", "No", "Pc", "Pd", "Ps", "Pe", "Pi", + "Pf", "Po", "Sm", "Sc", "Sk", "So", "Zs", "Zl", "Zp", "Cc", "Cf", "Cs", "Co", "Cn", +]; + +const CN: u8 = 29; + +fn data(file: &str) -> Result { + let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/data/ucd-regexp") + .join(file); + std::fs::read_to_string(&path).map_err(|e| format!("{}: {e}", path.display())) +} + +/// The `;`-separated fields of each line of a UCD file, comments removed. +fn rows(text: &str) -> Vec> { + text.lines() + .map(|l| l.split('#').next().unwrap_or_default()) + .filter(|l| !l.trim().is_empty()) + .map(|l| l.split(';').map(|f| f.trim().to_string()).collect()) + .collect() +} + +fn hex(s: &str) -> Result { + u32::from_str_radix(s.trim(), 16).map_err(|e| format!("{s:?}: {e}")) +} + +fn range(s: &str) -> Result<(u32, u32), String> { + match s.split_once("..") { + Some((a, b)) => Ok((hex(a)?, hex(b)?)), + None => hex(s).map(|c| (c, c)), + } +} + +/// Sorted, disjoint, with touching ranges merged. +fn merge(mut r: Vec<(u32, u32)>) -> Vec<(u32, u32)> { + r.sort_unstable(); + let mut out: Vec<(u32, u32)> = Vec::new(); + for (a, b) in r { + match out.last_mut() { + Some(last) if a <= last.1.saturating_add(1) => last.1 = last.1.max(b), + _ => out.push((a, b)), + } + } + out +} + +fn property_ranges(files: &[String], name: &str) -> Result, String> { + for text in files { + let mut found = Vec::new(); + for row in rows(text) { + if let (Some(r), Some(n)) = (row.first(), row.get(1)) + && n == name + { + found.push(range(r)?); + } + } + if !found.is_empty() { + return Ok(merge(found)); + } + } + Err(format!("{name}: in no file")) +} + +fn pairs(out: &mut String, name: &str, doc: &str, list: &[(u32, u32)]) { + let _ = writeln!(out, "/// {doc}"); + // rustfmt puts an array on one line if its elements take at most 60 + // characters; the generator writes what rustfmt would. + let one: Vec = list + .iter() + .map(|(a, b)| format!("({a:#X}, {b:#X})")) + .collect(); + let joined = one.join(", "); + if joined.len() <= 60 { + let line = format!("pub static {name}: &[(u32, u32)] = &[{joined}];"); + if line.len() <= 100 { + let _ = writeln!(out, "{line}\n"); + } else { + let _ = writeln!( + out, + "pub static {name}: &[(u32, u32)] =\n &[{joined}];\n" + ); + } + } else { + let _ = writeln!(out, "pub static {name}: &[(u32, u32)] = &["); + for (a, b) in list { + let _ = writeln!(out, " ({a:#X}, {b:#X}),"); + } + out.push_str("];\n\n"); + } +} + +fn fold_table() -> Result, String> { + let mut v = Vec::new(); + for row in rows(&data("CaseFolding.txt")?) { + if let [code, status, mapping, ..] = row.as_slice() + && (status == "C" || status == "S") + { + v.push((hex(code)?, hex(mapping)?)); + } + } + v.sort_unstable(); + Ok(v) +} + +fn upper_table() -> Result, String> { + // Unconditional full mappings of SpecialCasing.txt: code; lower; title; + // upper; (condition;)? + let mut special: BTreeMap> = BTreeMap::new(); + for row in rows(&data("SpecialCasing.txt")?) { + if let [code, _, _, upper, rest @ ..] = row.as_slice() { + let conditional = rest.iter().any(|f| !f.is_empty()); + if !conditional { + let u = upper + .split_whitespace() + .map(hex) + .collect::, _>>()?; + special.insert(hex(code)?, u); + } + } + } + let mut simple: BTreeMap = BTreeMap::new(); + for line in data("UnicodeData.txt")?.lines() { + let f: Vec<&str> = line.split(';').collect(); + if let (Some(code), Some(up)) = (f.first(), f.get(12)) + && !up.is_empty() + { + simple.insert(hex(code)?, hex(up)?); + } + } + let mut v = Vec::new(); + for c in 0..=0xFFFFu32 { + let result = match special.get(&c) { + Some(u) => u.clone(), + None => vec![simple.get(&c).copied().unwrap_or(c)], + }; + if let [y] = result.as_slice() { + let y = *y; + if y != c && y <= 0xFFFF && !(c >= 128 && y < 128) { + v.push((c, y)); + } + } + } + Ok(v) +} + +fn category_table() -> Result, String> { + let mut v: Vec<(u32, u32, u8)> = Vec::new(); + for row in rows(&data("DerivedGeneralCategory.txt")?) { + if let [r, cat, ..] = row.as_slice() { + let idx = CATEGORIES + .iter() + .position(|c| c == cat) + .ok_or_else(|| format!("category {cat}"))?; + let (a, b) = range(r)?; + v.push((a, b, u8::try_from(idx).map_err(|e| e.to_string())?)); + } + } + v.sort_unstable(); + let mut out: Vec<(u32, u32, u8)> = Vec::new(); + let mut next = 0u32; + let mut push = |a: u32, b: u32, c: u8| match out.last_mut() { + Some(last) if last.2 == c && last.1.saturating_add(1) == a => last.1 = b, + _ => out.push((a, b, c)), + }; + for (a, b, c) in v { + if a < next { + return Err(format!("overlap at {a:X}")); + } + if a > next { + push(next, a.saturating_sub(1), CN); + } + push(a, b, c); + next = b.saturating_add(1); + } + if next <= LAST { + push(next, LAST, CN); + } + Ok(out) +} + +/// The text of `src/tables.rs`. +fn render() -> Result { + let mut out = String::new(); + out.push_str( + "//! Unicode 18.0.0 tables for case folding, `\\p{..}` and `\\w`: generated.\n\ +//!\n\ +//! @generated by `tests/tables.rs` (`CLAZEL_WRITE_TABLES=1 cargo test -p\n\ +//! clazel-js-regexp --test tables`) from `tests/data/ucd-regexp/` (source,\n\ +//! commit and license: `SOURCE.md` there). Do not edit by hand: the test\n\ +//! `tables_are_current` fails if this file differs from what the generator\n\ +//! writes. What each table holds and which file it comes from is in the\n\ +//! header of that test file.\n\n", + ); + let fold = fold_table()?; + pairs( + &mut out, + "SIMPLE_FOLD", + "Simple Case Folding (CaseFolding.txt, statuses C and S): code point, folded, sorted by code point.", + &fold, + ); + let mut inv: Vec<(u32, u32)> = fold.iter().map(|&(a, b)| (b, a)).collect(); + inv.sort_unstable(); + pairs( + &mut out, + "SIMPLE_FOLD_INVERSE", + "`SIMPLE_FOLD` as (folded, code point), sorted.", + &inv, + ); + let upper = upper_table()?; + pairs( + &mut out, + "UPPER", + "toUppercase of a BMP code point where it is one different BMP code point, and not ASCII for a non-ASCII argument: code point, upper case, sorted by code point.", + &upper, + ); + let mut inv: Vec<(u32, u32)> = upper.iter().map(|&(a, b)| (b, a)).collect(); + inv.sort_unstable(); + pairs( + &mut out, + "UPPER_INVERSE", + "`UPPER` as (upper case, code point), sorted.", + &inv, + ); + let cats = category_table()?; + out.push_str("/// The general categories, in the order of the index in `GENERAL_CATEGORY`.\n"); + out.push_str("pub static CATEGORY_NAMES: [&str; 30] = [\n"); + for line in CATEGORIES.chunks(16) { + let items: Vec = line.iter().map(|c| format!("\"{c}\"")).collect(); + let _ = writeln!(out, " {},", items.join(", ")); + } + out.push_str("];\n\n"); + out.push_str("/// General_Category (DerivedGeneralCategory.txt): first, last, index into `CATEGORY_NAMES`. Sorted, disjoint, covers U+0000 to U+10FFFF.\n"); + out.push_str("pub static GENERAL_CATEGORY: &[(u32, u32, u8)] = &[\n"); + for (a, b, c) in &cats { + let _ = writeln!(out, " ({a:#X}, {b:#X}, {c}),"); + } + out.push_str("];\n\n"); + + let files: Vec = [ + "PropList.txt", + "DerivedCoreProperties.txt", + "DerivedNormalizationProps.txt", + "DerivedBinaryProperties.txt", + "emoji-data.txt", + ] + .iter() + .map(|f| data(f)) + .collect::>()?; + let mut names: Vec = BINARY_PROPERTIES + .iter() + .map(|(full, _)| String::from_utf8_lossy(full).into_owned()) + .filter(|n| !matches!(n.as_str(), "Any" | "ASCII" | "Assigned")) + .collect(); + names.sort(); + for n in &names { + let r = property_ranges(&files, n)?; + pairs( + &mut out, + &format!("BINARY_{}", n.to_ascii_uppercase()), + &format!("The code points with the binary property {n}, as ranges."), + &r, + ); + } + out.push_str("/// The binary properties of ECMA-262's list that need a table, by canonical name (`Any`, `ASCII` and `Assigned` need none).\n"); + out.push_str("pub static BINARY: &[(&str, &[(u32, u32)])] = &[\n"); + for n in &names { + let up = n.to_ascii_uppercase(); + let line = format!(" (\"{n}\", BINARY_{up}),"); + // rustfmt breaks a tuple whose contents take more than 60 characters. + if line.len() <= 100 && format!("\"{n}\", BINARY_{up}").len() <= 60 { + let _ = writeln!(out, "{line}"); + } else { + let _ = writeln!(out, " (\n \"{n}\",\n BINARY_{up},\n ),"); + } + } + out.push_str("];\n"); + Ok(out) +} + +#[test] +#[cfg_attr(miri, ignore = "reads files")] +fn tables_are_current() -> Result<(), String> { + let want = render()?; + let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/tables.rs"); + if std::env::var_os("CLAZEL_WRITE_TABLES").is_some() { + std::fs::write(&path, &want).map_err(|e| e.to_string())?; + return Ok(()); + } + let have = std::fs::read_to_string(&path).map_err(|e| e.to_string())?; + if have == want { + println!("clazel-conformance: suite=\"generated tables\" pass=1 xfail=0 fail=0 total=1"); + Ok(()) + } else { + Err( + "src/tables.rs differs from the generator's output; see the header of tests/tables.rs" + .into(), + ) + } +} + +#[test] +#[cfg_attr(miri, ignore = "reads files")] +fn categories_agree_with_unicode_data() -> Result<(), String> { + // UnicodeData.txt lists each assigned code point, or a range between a + // `<.., First>` and `<.., Last>` pair; every other code point is Cn. + let total = usize::try_from(LAST) + .map_err(|e| e.to_string())? + .saturating_add(1); + let mut expect: Vec = vec![CN; total]; + let mut first: Option = None; + for line in data("UnicodeData.txt")?.lines() { + let f: Vec<&str> = line.split(';').collect(); + let (Some(code), Some(name), Some(cat)) = (f.first(), f.get(1), f.get(2)) else { + continue; + }; + let c = hex(code)?; + let idx = u8::try_from( + CATEGORIES + .iter() + .position(|x| x == cat) + .ok_or_else(|| format!("category {cat}"))?, + ) + .map_err(|e| e.to_string())?; + if name.ends_with(", First>") { + first = Some(c); + continue; + } + let lo = if name.ends_with(", Last>") { + first.take().unwrap_or(c) + } else { + c + }; + for x in lo..=c { + if let Some(slot) = expect.get_mut(usize::try_from(x).map_err(|e| e.to_string())?) { + *slot = idx; + } + } + } + let mut bad = 0u32; + let mut at = 0u32; + for &(a, b, c) in tables::GENERAL_CATEGORY { + if a != at { + return Err(format!("gap before {a:X}")); + } + for x in a..=b { + let want = expect.get(usize::try_from(x).map_err(|e| e.to_string())?); + if want != Some(&c) { + bad = bad.saturating_add(1); + } + } + at = b.saturating_add(1); + } + if at != LAST.saturating_add(1) { + return Err("does not reach U+10FFFF".into()); + } + let all = LAST.saturating_add(1); + println!( + "clazel-conformance: suite=\"general category vs UnicodeData.txt\" pass={} xfail=0 fail={bad} total={all}", + all.saturating_sub(bad) + ); + assert_eq!(bad, 0); + Ok(()) +} + +#[test] +fn tables_are_sorted() { + for t in [ + tables::SIMPLE_FOLD, + tables::SIMPLE_FOLD_INVERSE, + tables::UPPER, + tables::UPPER_INVERSE, + ] { + assert!(!t.is_empty()); + assert!(t.windows(2).all(|w| match w { + [a, b] => a < b, + _ => true, + })); + } + assert!(!tables::BINARY.is_empty()); + for (_, t) in tables::BINARY { + assert!(t.windows(2).all(|w| match w { + [a, b] => a.0 <= a.1 && a.1 < b.0, + _ => true, + })); + } +} + +#[test] +fn spot_checks_of_the_mappings() { + // Canonicalize with u: simple case folding. + assert_eq!(simple_fold(0x41), 0x61); + assert_eq!(simple_fold(0x61), 0x61); + assert_eq!(simple_fold(0xDF), 0xDF, "sharp s has only a full folding"); + assert_eq!(simple_fold(0x1E9E), 0xDF, "capital sharp s folds simply"); + assert_eq!(simple_fold(0x17F), 0x73, "long s folds to s"); + assert_eq!(simple_fold(0x212A), 0x6B, "kelvin folds to k"); + assert_eq!(simple_fold(0x130), 0x130, "dotted I: only T and F rows"); + assert_eq!(simple_fold(0x1C5), 0x1C6); + assert_eq!(simple_fold(0x10400), 0x10428); + assert_eq!(simple_fold(0x10FFFF), 0x10FFFF); + // Canonicalize without u: toUppercase of the code unit. + assert_eq!(canonicalize(0x61, false), 0x41); + assert_eq!(canonicalize(0x41, false), 0x41); + assert_eq!(canonicalize(0xE9, false), 0xC9); + assert_eq!(canonicalize(0xDF, false), 0xDF, "uppercase is two units"); + assert_eq!(canonicalize(0x17F, false), 0x17F, "S would be ASCII"); + assert_eq!(canonicalize(0x131, false), 0x131, "I would be ASCII"); + assert_eq!(canonicalize(0x3C3, false), 0x3A3); + assert_eq!(canonicalize(0x3C2, false), 0x3A3, "final sigma"); + assert_eq!(canonicalize(0x1C5, false), 0x1C4); + assert_eq!(canonicalize(0xD801, false), 0xD801, "a lone surrogate"); + assert_eq!(canonicalize(0x212A, false), 0x212A); +} + +/// How many code points to skip between checks: every one natively, a stride +/// under Miri. +fn stride() -> usize { + if cfg!(miri) { 61 } else { 1 } +} + +#[test] +fn equivalents_invert_canonicalize() { + // For every character, its equivalence class (what the matcher compares + // class members and backreferences by) holds it, and holds exactly the + // characters with its canonical form. + let mut out = Vec::new(); + for unicode in [false, true] { + let top = if unicode { 0x10FFFFu32 } else { 0xFFFF }; + for c in (0..=top).step_by(stride()) { + let cc = canonicalize(c, unicode); + equivalents(cc, unicode, &mut out); + assert!( + out.contains(&c), + "{c:X} (unicode: {unicode}) is not in the class of {cc:X}" + ); + for &a in &out { + assert_eq!(canonicalize(a, unicode), cc, "{a:X} in the class of {cc:X}"); + } + assert!(out.len() <= 6, "{cc:X} has {} equivalents", out.len()); + } + } +} + +#[test] +fn simple_folding_is_idempotent_and_canonicalize_unit_is_in_range() { + for c in (0..=0x10FFFFu32).step_by(stride()) { + let f = simple_fold(c); + assert_eq!(simple_fold(f), f, "{c:X}"); + if c <= 0xFFFF { + let u = canonicalize(c, false); + assert!(u <= 0xFFFF); + assert!(c < 128 || u >= 128, "{c:X} became ASCII"); + } + } +} + +#[test] +fn word_characters_with_u_and_i_are_the_two_extras() { + // §22.2.2.9† WordCharacters: the extras are the characters that are not + // basic word characters but whose Canonicalize is. The matcher hard-codes + // them (U+017F and U+212A). + let basic = |c: u32| matches!(c, 0x30..=0x39 | 0x41..=0x5A | 0x61..=0x7A | 0x5F); + let mut extras = Vec::new(); + for c in (0..=0x10FFFFu32).step_by(if cfg!(miri) { 1 << 12 } else { 1 }) { + if !basic(c) && basic(simple_fold(c)) { + extras.push(c); + } + } + if !cfg!(miri) { + assert_eq!(extras, vec![0x17F, 0x212A]); + } + // Without u the canonical form of a non-ASCII unit is never ASCII. + assert!( + (0x80..=0xFFFFu32) + .step_by(stride()) + .all(|c| !basic(canonicalize(c, false))) + ); +} + +#[test] +fn every_property_name_resolves() { + use clazel_js_regexp::props::{BINARY_NAMES, GENERAL_CATEGORY_VALUES}; + use clazel_js_regexp::unicode::{binary_property, category_mask}; + for n in GENERAL_CATEGORY_VALUES { + let n = String::from_utf8_lossy(n); + assert!(category_mask(&n).is_some(), "{n}"); + } + for n in BINARY_NAMES { + let n = String::from_utf8_lossy(n); + assert!(binary_property(&n).is_some(), "{n}"); + } + assert!(category_mask("Latin").is_none()); + assert!(binary_property("Latin").is_none()); +} + +#[test] +fn category_groups_are_unions_of_their_members() { + use clazel_js_regexp::unicode::{category_mask, general_category}; + let m = |n: &str| category_mask(n).unwrap_or(0); + assert_eq!(m("L"), m("Lu") | m("Ll") | m("Lt") | m("Lm") | m("Lo")); + assert_eq!(m("LC"), m("Lu") | m("Ll") | m("Lt")); + assert_eq!(m("M"), m("Mn") | m("Mc") | m("Me")); + assert_eq!(m("N"), m("Nd") | m("Nl") | m("No")); + assert_eq!(m("Z"), m("Zs") | m("Zl") | m("Zp")); + assert_eq!( + m("P"), + m("Pc") | m("Pd") | m("Ps") | m("Pe") | m("Pi") | m("Pf") | m("Po") + ); + assert_eq!(m("S"), m("Sm") | m("Sc") | m("Sk") | m("So")); + assert_eq!(m("C"), m("Cc") | m("Cf") | m("Cs") | m("Co") | m("Cn")); + // Together the thirty are every bit of a 30-bit mask, and the table + // yields one of them for every code point. + let all = m("L") | m("M") | m("N") | m("P") | m("S") | m("Z") | m("C"); + assert_eq!(all, 0x3FFF_FFFF); + assert_eq!(general_category(0x41), 0); + assert_eq!(general_category(0x378), 29); + assert_eq!(general_category(0x10FFFF), 29); +} From fd4ea5d3bbf7db0dfaf122db8da53d5f7a248dc4 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 16:51:47 +0000 Subject: [PATCH 027/195] clazel-js-syntax: proven early errors for lexical declarations and statement lists arena_decls computes LexicallyDeclaredNames, TopLevelLexicallyDeclaredNames, VarDeclaredNames and TopLevelVarDeclaredNames of every node, proven equal to the specification's. list_early for blocks, scripts and function bodies (duplicates, Annex B.3.2, lexical versus var), LexicalDeclaration rules, the lexical for head and the parameter-versus-lexical rule of function_early are checked from them. for-in/of, switch, try/catch, labels, classes and modules are still Unsupported. Early errors verified for 1229 of 1567 script runs. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-syntax/src/arena_decls.rs | 1574 +++++++++++++++++++ crates/clazel-js-syntax/src/arena_early.rs | 135 +- crates/clazel-js-syntax/src/arena_names.rs | 53 +- crates/clazel-js-syntax/src/lib.rs | 1 + crates/clazel-js-syntax/tests/derivation.rs | 4 +- 5 files changed, 1642 insertions(+), 125 deletions(-) create mode 100644 crates/clazel-js-syntax/src/arena_decls.rs diff --git a/crates/clazel-js-syntax/src/arena_decls.rs b/crates/clazel-js-syntax/src/arena_decls.rs new file mode 100644 index 00000000..71c75856 --- /dev/null +++ b/crates/clazel-js-syntax/src/arena_decls.rs @@ -0,0 +1,1574 @@ +//! The declared names of every node, computed over the arena and proven equal to the +//! specification's (item 7.3): LexicallyDeclaredNames and TopLevelLexicallyDeclaredNames +//! (`spec::lex_names_item`), VarDeclaredNames and TopLevelVarDeclaredNames +//! (`spec::var_names_item`), each as a list of [`Decl`]s (the token that names the +//! declaration, and whether it is a plain function declaration), bottom-up +//! ([`decl_names_all`]), and the lists of a statement list put together ([`cat_exec`]). +//! +//! The `import` and `export` declarations of a module are not covered: the computation +//! returns `None` for them. + +use crate::arena_d::*; +use crate::arena_early::*; +use crate::arena_names::*; +use crate::ast::*; +use crate::spec::*; +use vstd::prelude::*; + +verus! { + +/// A declared name: the token that names it, and whether the declaration is a +/// `FunctionDeclaration` that is not a generator or an async function. +#[derive(Clone, Copy)] +pub struct Decl { + /// The token. + pub x: usize, + /// A plain function declaration. + pub pf: bool, +} + +/// The specification's declared names of `ds`. +pub open spec fn decls_of(toks: Seq, ds: Seq) -> Seq { + Seq::new(ds.len(), |i: int| DeclName { name: toks[ds[i].x as int].name@, plain_function: ds[i].pf }) +} + +/// The names of `ds`. +pub open spec fn dn(toks: Seq, ds: Seq) -> Seq> { + Seq::new(ds.len(), |i: int| toks[ds[i].x as int].name@) +} + +/// Every declaration of `ds` names a token. +pub open spec fn decl_ok(toks: Seq, ds: Seq) -> bool { + forall|i: int| 0 <= i < ds.len() ==> (#[trigger] ds[i]).x < toks.len() +} + +/// `plain_names` of the declared names. +proof fn lemma_dn_plain(toks: Seq, ds: Seq) + ensures + plain_names(decls_of(toks, ds)) =~= dn(toks, ds), +{ +} + +/// The declared names of two lists put together. +pub proof fn lemma_decls_add(toks: Seq, xs: Seq, ys: Seq) + ensures + decls_of(toks, xs + ys) =~= decls_of(toks, xs) + decls_of(toks, ys), + dn(toks, xs + ys) =~= dn(toks, xs) + dn(toks, ys), +{ +} + +/// The declarations the names `xs` make, none of them a plain function declaration. +pub open spec fn decls_of_names(xs: Seq) -> Seq { + Seq::new(xs.len(), |i: int| Decl { x: xs[i], pf: false }) +} + +/// `dst` gets the elements of `src` after its own. +fn push_decls(dst: &mut Vec, src: &[Decl]) + ensures + final(dst)@ =~= old(dst)@ + src@, +{ + let len = src.len(); + let mut i: usize = 0; + while i < len + invariant + len == src.len(), + i <= len, + dst@ =~= old(dst)@ + src@.subrange(0, i as int), + decreases len - i, + { + match src.get(i) { + Some(x) => { + dst.push(*x); + }, + None => { + return; + }, + } + proof { + assert(src@.subrange(0, i as int + 1) =~= src@.subrange(0, i as int).push(src@[i as int])); + } + i = i.saturating_add(1); + } + proof { + assert(src@.subrange(0, len as int) =~= src@); + } +} + +/// The declarations of the names `xs`. +pub fn decls_from_names(xs: &[usize]) -> (r: Vec) + ensures + r@ =~= decls_of_names(xs@), +{ + let mut out: Vec = Vec::new(); + let mut i: usize = 0; + while i < xs.len() + invariant + i <= xs.len(), + out@ =~= decls_of_names(xs@).subrange(0, i as int), + decreases xs.len() - i, + { + match xs.get(i) { + Some(x) => { + out.push(Decl { x: *x, pf: false }); + }, + None => { + return out; + }, + } + proof { + assert(decls_of_names(xs@).subrange(0, i as int + 1) =~= decls_of_names(xs@).subrange( + 0, + i as int, + ).push(decls_of_names(xs@)[i as int])); + } + i = i.saturating_add(1); + } + proof { + assert(decls_of_names(xs@).subrange(0, xs@.len() as int) =~= decls_of_names(xs@)); + } + out +} + +/// The declarations of the children `ks[k..]`, put together, from the declarations `arr` of each node. +pub open spec fn cat_d(arr: Seq>, ks: Seq, k: int) -> Seq + decreases ks.len() - k, +{ + if k < 0 || k >= ks.len() { + Seq::empty() + } else { + arr[ks[k]]@ + cat_d(arr, ks, k + 1) + } +} + +/// The declarations `arr[j]` name tokens, for `j < m`. +pub open spec fn arr_ok(toks: Seq, arr: Seq>, m: int) -> bool { + forall|j: int| 0 <= j < m ==> decl_ok(toks, (#[trigger] arr[j])@) +} + +/// A concatenation of declarations that name tokens does. +proof fn lemma_cat_ok(toks: Seq, arr: Seq>, ks: Seq, k: int, m: int) + requires + arr_ok(toks, arr, m), + forall|q: int| 0 <= q < ks.len() ==> 0 <= #[trigger] ks[q] < m, + ensures + decl_ok(toks, cat_d(arr, ks, k)), + decreases ks.len() - k, +{ + if 0 <= k < ks.len() { + lemma_cat_ok(toks, arr, ks, k + 1, m); + let r = cat_d(arr, ks, k + 1); + let l = arr[ks[k]]@; + assert(decl_ok(toks, l)); + assert forall|i: int| 0 <= i < (l + r).len() implies (#[trigger] (l + r)[i]).x < toks.len() by { + if i < l.len() { + assert((l + r)[i] == l[i]); + } else { + assert((l + r)[i] == r[i - l.len()]); + } + } + } +} + +/// The declarations of the children of node `m` from `from` on, put together. +pub fn cat_exec(nodes: &[Node], arr: &[Vec], m: usize, from: usize) -> (r: Option>) + requires + m < nodes.len(), + ast_wf(arena_of(nodes@)), + arr.len() >= m, + ensures + match r { + Some(v) => v@ =~= cat_d(arr@, arena_of(nodes@).nodes[m as int].children, from as int), + None => true, + }, +{ + let ghost a = arena_of(nodes@); + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + let len = nd.children.len(); + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == len); + } + let ghost ks = a.nodes[m as int].children; + let mut acc: Vec = Vec::new(); + if from >= len { + return Some(acc); + } + let mut k = len; + while k > from + invariant + from <= k <= len, + len == nd.children.len(), + len == ks.len(), + m < nodes.len(), + arr.len() >= m, + nd == &nodes@[m as int], + a == arena_of(nodes@), + ast_wf(a), + ks == a.nodes[m as int].children, + acc@ =~= cat_d(arr@, ks, k as int), + decreases k, + { + k = k.saturating_sub(1); + let c = match nd.children.as_slice().get(k) { + Some(c) => *c as usize, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int].children[k as int] == c as int); + lemma_child_before(a, m as int, k as int); + } + let item = match arr.get(c) { + Some(v) => v, + None => { + return None; + }, + }; + let mut next: Vec = Vec::new(); + push_decls(&mut next, item.as_slice()); + push_decls(&mut next, acc.as_slice()); + proof { + assert(arr@[c as int] == item); + assert(next@ =~= cat_d(arr@, ks, k as int)); + } + acc = next; + } + Some(acc) +} + +// --------------------------------------------------------------------- +// The names of every node. +// --------------------------------------------------------------------- + +/// `arr[j]` is the lexically declared names of node `j` (`top`: top-level), for `j < m`. +pub open spec fn inv_l(a: AstV, ts: Stream, toks: Seq, arr: Seq>, top: bool, m: int) -> bool { + forall|j: int| + 0 <= j < m ==> { + let v = (#[trigger] arr[j])@; + decl_ok(toks, v) && decls_of(toks, v) =~= lex_names_item(a, ts, j, top) + } +} + +/// `arr[j]` is the var declared names of node `j` (`top`: top-level), for `j < m`. +pub open spec fn inv_v(a: AstV, ts: Stream, toks: Seq, arr: Seq>, top: bool, m: int) -> bool { + forall|j: int| + 0 <= j < m ==> { + let v = (#[trigger] arr[j])@; + decl_ok(toks, v) && dn(toks, v) =~= var_names_item(a, ts, j, top) + } +} + +/// The declarations of child `i` of a node, none if there is no such child. +pub open spec fn kid_spec(arr: Seq>, ks: Seq, i: int) -> Seq { + if 0 <= i < ks.len() { + arr[ks[i]]@ + } else { + Seq::empty() + } +} + +/// The declarations of child `i` of node `m`. +fn kid_d(nodes: &[Node], arr: &[Vec], m: usize, i: usize) -> (r: Option>) + requires + m < nodes.len(), + ast_wf(arena_of(nodes@)), + arr.len() >= m, + ensures + match r { + Some(v) => v@ =~= kid_spec(arr@, arena_of(nodes@).nodes[m as int].children, i as int), + None => true, + }, +{ + let ghost a = arena_of(nodes@); + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == nd.children.len()); + } + let c = match nd.children.as_slice().get(i) { + Some(c) => *c as usize, + None => { + return Some(Vec::new()); + }, + }; + proof { + assert(a.nodes[m as int].children[i as int] == c as int); + lemma_child_before(a, m as int, i as int); + } + let item = match arr.get(c) { + Some(v) => v, + None => { + return None; + }, + }; + let mut out: Vec = Vec::new(); + push_decls(&mut out, item.as_slice()); + proof { + assert(arr@[c as int] == item); + } + Some(out) +} + +/// The declarations of children `i`, `j` and `l` of node `m` put together. +fn sum3(nodes: &[Node], arr: &[Vec], m: usize, i: usize, j: usize, l: usize) -> (r: Option>) + requires + m < nodes.len(), + ast_wf(arena_of(nodes@)), + arr.len() == m, + ensures + match r { + Some(v) => { + let ks = arena_of(nodes@).nodes[m as int].children; + v@ =~= kid_spec(arr@, ks, i as int) + kid_spec(arr@, ks, j as int) + kid_spec( + arr@, + ks, + l as int, + ) + }, + None => true, + }, +{ + let x = match kid_d(nodes, arr, m, i) { + Some(v) => v, + None => { + return None; + }, + }; + let y = match kid_d(nodes, arr, m, j) { + Some(v) => v, + None => { + return None; + }, + }; + let z = match kid_d(nodes, arr, m, l) { + Some(v) => v, + None => { + return None; + }, + }; + let mut out: Vec = Vec::new(); + push_decls(&mut out, x.as_slice()); + push_decls(&mut out, y.as_slice()); + push_decls(&mut out, z.as_slice()); + Some(out) +} + +/// A declaration list that names tokens, of a child. +proof fn lemma_kid_ok(toks: Seq, arr: Seq>, ks: Seq, i: int, m: int) + requires + arr_ok(toks, arr, m), + forall|q: int| 0 <= q < ks.len() ==> 0 <= #[trigger] ks[q] < m, + ensures + decl_ok(toks, kid_spec(arr, ks, i)), +{ +} + +/// Two lists of declarations that name tokens, put together, do. +proof fn lemma_ok_add(toks: Seq, xs: Seq, ys: Seq) + requires + decl_ok(toks, xs), + decl_ok(toks, ys), + ensures + decl_ok(toks, xs + ys), +{ + assert forall|i: int| 0 <= i < (xs + ys).len() implies (#[trigger] (xs + ys)[i]).x < toks.len() by { + if i < xs.len() { + assert((xs + ys)[i] == xs[i]); + } else { + assert((xs + ys)[i] == ys[i - xs.len()]); + } + } +} + +/// The lexically declared names of a list of items are those of its items put together. +proof fn lemma_lex_cat( + a: AstV, + ts: Stream, + toks: Seq, + arr: Seq>, + top: bool, + n: int, + ks: Seq, + k: int, +) + requires + inv_l(a, ts, toks, arr, top, n), + arr.len() >= n, + forall|q: int| 0 <= q < ks.len() ==> 0 <= #[trigger] ks[q] < n, + ensures + decls_of(toks, cat_d(arr, ks, k)) =~= lex_names_list(a, ts, n, ks, k, top), + decreases ks.len() - k, +{ + if 0 <= k < ks.len() { + lemma_lex_cat(a, ts, toks, arr, top, n, ks, k + 1); + lemma_decls_add(toks, arr[ks[k]]@, cat_d(arr, ks, k + 1)); + assert(decls_of(toks, arr[ks[k]]@) =~= lex_names_item(a, ts, ks[k], top)); + } +} + +/// The var declared names of a list of items are those of its items put together. +proof fn lemma_var_cat( + a: AstV, + ts: Stream, + toks: Seq, + arr: Seq>, + top: bool, + n: int, + ks: Seq, + k: int, +) + requires + inv_v(a, ts, toks, arr, top, n), + arr.len() >= n, + forall|q: int| 0 <= q < ks.len() ==> 0 <= #[trigger] ks[q] < n, + ensures + dn(toks, cat_d(arr, ks, k)) =~= (if top { + top_var_names_list(a, ts, n, ks, k) + } else { + var_names_list(a, ts, n, ks, k) + }), + decreases ks.len() - k, +{ + if 0 <= k < ks.len() { + lemma_var_cat(a, ts, toks, arr, top, n, ks, k + 1); + lemma_decls_add(toks, arr[ks[k]]@, cat_d(arr, ks, k + 1)); + assert(dn(toks, arr[ks[k]]@) =~= var_names_item(a, ts, ks[k], top)); + if top { + assert(top_var_names_list(a, ts, n, ks, k) =~= var_names_sub_top(a, ts, n, ks[k], true) + + top_var_names_list(a, ts, n, ks, k + 1)); + assert(var_names_sub_top(a, ts, n, ks[k], true) =~= var_names_item(a, ts, ks[k], true)); + } else { + assert(var_names_list(a, ts, n, ks, k) =~= var_names_sub(a, ts, n, ks[k]) + var_names_list( + a, + ts, + n, + ks, + k + 1, + )); + assert(var_names_sub(a, ts, n, ks[k]) =~= var_names_item(a, ts, ks[k], false)); + } + } +} + +/// The var declared names of child `i` of node `m`, as a `var_names_sub` (not top-level) or +/// the item itself. +proof fn lemma_kid_var(a: AstV, ts: Stream, toks: Seq, arr: Seq>, top: bool, m: int, i: int) + requires + inv_v(a, ts, toks, arr, top, m), + arr.len() >= m, + forall|q: int| 0 <= q < a.nodes[m].children.len() ==> 0 <= #[trigger] a.nodes[m].children[q] < m, + ensures + dn(toks, kid_spec(arr, a.nodes[m].children, i)) =~= var_names_sub_top( + a, + ts, + m, + kid(a.nodes[m].children, i), + top, + ), +{ +} + +/// The lexically declared names of child `i` of node `m`. +proof fn lemma_kid_lex(a: AstV, ts: Stream, toks: Seq, arr: Seq>, top: bool, m: int, i: int) + requires + inv_l(a, ts, toks, arr, top, m), + arr.len() >= m, + forall|q: int| 0 <= q < a.nodes[m].children.len() ==> 0 <= #[trigger] a.nodes[m].children[q] < m, + ensures + decls_of(toks, kid_spec(arr, a.nodes[m].children, i)) =~= (if 0 <= kid(a.nodes[m].children, i) + < m { + lex_names_item(a, ts, kid(a.nodes[m].children, i), top) + } else { + Seq::empty() + }), +{ +} + +/// The declaration of the name of the `BindingIdentifier` node `c`. +fn decl_of_ident( + tk: &Tk, + nodes: &[Node], + c: usize, + pf: bool, + Ghost(ts): Ghost, +) -> (r: Option) + requires + c < nodes.len(), + ast_wf(arena_of(nodes@)), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + ensures + match r { + Some(d) => d.x < tk.toks@.len() && d.pf == pf && tk.toks@[d.x as int].name@ =~= name_of( + arena_of(nodes@), + ts, + c as int, + ), + None => true, + }, +{ + let toks = tk.toks; + let x = match node_token(nodes, toks, tk.by_start, c) { + Some(x) => x, + None => { + return None; + }, + }; + proof { + let a = arena_of(nodes@); + assert(dtok_matches(tk.src@, toks@[x as int], ts.toks[x as int])); + lemma_node_tok_at(a, ts, c as int, x as int); + } + Some(Decl { x, pf }) +} + +/// The preconditions the per-node computations share. +pub open spec fn names_pre(tk: &Tk, nodes: Seq, ts: Stream, m: int) -> bool { + let a = arena_of(nodes); + 0 <= m < nodes.len() && ast_wf(a) && toks_match(tk.src@, tk.toks@, ts) && starts_inc(ts) + && tk.bn.len() == nodes.len() && bn_inv(a, ts, tk.toks@, tk.bn@, nodes.len() as int) +} + +/// The children of node `m` are before it. +proof fn lemma_kids_before(a: AstV, m: int) + requires + ast_wf(a), + 0 <= m < a.nodes.len(), + ensures + forall|q: int| 0 <= q < a.nodes[m].children.len() ==> 0 <= #[trigger] a.nodes[m].children[q] < m, +{ +} + +/// The lexically declared names of node `m`, not top-level and top-level. +#[verifier::rlimit(400)] +pub fn item_lex(tk: &Tk, nodes: &[Node], m: usize, lf: &[Vec], Ghost(ts): Ghost) -> (r: Option< + (Vec, Vec), +>) + requires + names_pre(tk, nodes@, ts, m as int), + lf.len() == m, + inv_l(arena_of(nodes@), ts, tk.toks@, lf@, false, m as int), + ensures + match r { + Some((l1, l2)) => { + let a = arena_of(nodes@); + decl_ok(tk.toks@, l1@) && decl_ok(tk.toks@, l2@) && decls_of(tk.toks@, l1@) =~= lex_names_item( + a, + ts, + m as int, + false, + ) && decls_of(tk.toks@, l2@) =~= lex_names_item(a, ts, m as int, true) + }, + None => true, + }, +{ + let ghost a = arena_of(nodes@); + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].children.len() == nd.children.len()); + lemma_kids_before(a, m as int); + } + let kind = nd.kind; + match kind { + NodeKind::LexicalDeclaration => { + let names = match tk.bn.get(m) { + Some(v) => v, + None => { + return None; + }, + }; + let l1 = decls_from_names(names.as_slice()); + let l2 = decls_from_names(names.as_slice()); + proof { + assert(tk.bn@[m as int] == names); + assert(decls_of(tk.toks@, l1@) =~= bound_names(a, ts, m as int).map_values( + |n: Seq| DeclName { name: n, plain_function: false }, + )); + assert(decl_ok(tk.toks@, l1@)); + } + Some((l1, l2)) + }, + NodeKind::ClassDeclaration | NodeKind::FunctionDeclaration | NodeKind::GeneratorDeclaration + | NodeKind::AsyncFunctionDeclaration | NodeKind::AsyncGeneratorDeclaration => { + let k0 = match kid_kind(nodes, m, 0) { + Some(k) => k, + None => { + return None; + }, + }; + let is_class = matches!(kind, NodeKind::ClassDeclaration); + if !matches!(k0, NodeKind::BindingIdentifier) { + proof { + assert(decls_of(tk.toks@, Seq::::empty()) =~= Seq::::empty()); + } + return Some((Vec::new(), Vec::new())); + } + let c0 = match nd.children.as_slice().get(ZERO) { + Some(c) => *c as usize, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int].children[0] == c0 as int); + lemma_child_before(a, m as int, 0); + } + let pf = matches!(kind, NodeKind::FunctionDeclaration); + let d = match decl_of_ident(tk, nodes, c0, if is_class { + false + } else { + pf + }, Ghost(ts)) { + Some(d) => d, + None => { + return None; + }, + }; + let l1 = vec![d]; + let l2: Vec = if is_class { + vec![d] + } else { + Vec::new() + }; + proof { + assert(decls_of(tk.toks@, l1@) =~= seq![DeclName { + name: name_of(a, ts, c0 as int), + plain_function: if is_class { + false + } else { + pf + }, + }]); + assert(decl_ok(tk.toks@, l1@)); + assert(decl_ok(tk.toks@, l2@)); + if is_class { + assert(decls_of(tk.toks@, l2@) =~= seq![DeclName { + name: name_of(a, ts, c0 as int), + plain_function: false, + }]); + } else { + assert(decls_of(tk.toks@, l2@) =~= Seq::::empty()); + } + } + Some((l1, l2)) + }, + NodeKind::LabelledStatement => { + let l1 = match kid_d(nodes, lf, m, 1) { + Some(v) => v, + None => { + return None; + }, + }; + proof { + lemma_kid_lex(a, ts, tk.toks@, lf@, false, m as int, 1); + lemma_kid_ok(tk.toks@, lf@, a.nodes[m as int].children, 1, m as int); + assert(decls_of(tk.toks@, Seq::::empty()) =~= Seq::::empty()); + } + Some((l1, Vec::new())) + }, + NodeKind::ImportDeclaration | NodeKind::ExportDeclaration => None, + _ => { + proof { + assert(decls_of(tk.toks@, Seq::::empty()) =~= Seq::::empty()); + } + Some((Vec::new(), Vec::new())) + }, + } +} + +/// `dn` of three children's declarations put together is the three `var_names_sub`. +proof fn lemma_sum3_dn(a: AstV, ts: Stream, toks: Seq, vf: Seq>, m: int, i: int, j: int, l: int) + requires + inv_v(a, ts, toks, vf, false, m), + vf.len() >= m, + 0 <= m < a.nodes.len(), + forall|q: int| 0 <= q < a.nodes[m].children.len() ==> 0 <= #[trigger] a.nodes[m].children[q] < m, + ensures + ({ + let ks = a.nodes[m].children; + dn(toks, kid_spec(vf, ks, i) + kid_spec(vf, ks, j) + kid_spec(vf, ks, l)) =~= var_names_sub( + a, + ts, + m, + kid(ks, i), + ) + var_names_sub(a, ts, m, kid(ks, j)) + var_names_sub(a, ts, m, kid(ks, l)) + }), +{ + let ks = a.nodes[m].children; + lemma_kid_var(a, ts, toks, vf, false, m, i); + lemma_kid_var(a, ts, toks, vf, false, m, j); + lemma_kid_var(a, ts, toks, vf, false, m, l); + lemma_decls_add(toks, kid_spec(vf, ks, i), kid_spec(vf, ks, j)); + lemma_decls_add(toks, kid_spec(vf, ks, i) + kid_spec(vf, ks, j), kid_spec(vf, ks, l)); + assert(var_names_sub_top(a, ts, m, kid(ks, i), false) =~= var_names_sub(a, ts, m, kid(ks, i))); + assert(var_names_sub_top(a, ts, m, kid(ks, j), false) =~= var_names_sub(a, ts, m, kid(ks, j))); + assert(var_names_sub_top(a, ts, m, kid(ks, l), false) =~= var_names_sub(a, ts, m, kid(ks, l))); +} + +/// The var declared names of node `m` that are a sum of up to three children's, the same +/// whether top-level or not. +#[verifier::rlimit(400)] +fn item_var_sum( + nodes: &[Node], + Ghost(toks): Ghost>, + vf: &[Vec], + m: usize, + ix: (usize, usize, usize), + Ghost(ts): Ghost, +) -> (r: Option>) + requires + m < nodes.len(), + ast_wf(arena_of(nodes@)), + vf.len() == m, + inv_v(arena_of(nodes@), ts, toks, vf@, false, m as int), + ensures + match r { + Some(v) => { + let a = arena_of(nodes@); + decl_ok(toks, v@) && dn(toks, v@) =~= var_names_sub( + a, + ts, + m as int, + kid(a.nodes[m as int].children, ix.0 as int), + ) + var_names_sub(a, ts, m as int, kid(a.nodes[m as int].children, ix.1 as int)) + + var_names_sub(a, ts, m as int, kid(a.nodes[m as int].children, ix.2 as int)) + }, + None => true, + }, +{ + let v = match sum3(nodes, vf, m, ix.0, ix.1, ix.2) { + Some(v) => v, + None => { + return None; + }, + }; + proof { + let a = arena_of(nodes@); + lemma_kids_before(a, m as int); + lemma_sum3_dn(a, ts, toks, vf@, m as int, ix.0 as int, ix.1 as int, ix.2 as int); + let ks = a.nodes[m as int].children; + lemma_kid_ok(toks, vf@, ks, ix.0 as int, m as int); + lemma_kid_ok(toks, vf@, ks, ix.1 as int, m as int); + lemma_kid_ok(toks, vf@, ks, ix.2 as int, m as int); + lemma_ok_add(toks, kid_spec(vf@, ks, ix.0 as int), kid_spec(vf@, ks, ix.1 as int)); + lemma_ok_add( + toks, + kid_spec(vf@, ks, ix.0 as int) + kid_spec(vf@, ks, ix.1 as int), + kid_spec(vf@, ks, ix.2 as int), + ); + } + Some(v) +} + +/// A kind whose var declared names depend on whether the item is top-level, or that +/// this module does not cover. +pub open spec fn var_special(k: NodeKind) -> bool { + k == NodeKind::LabelledStatement || k == NodeKind::FunctionDeclaration || k + == NodeKind::GeneratorDeclaration || k == NodeKind::AsyncFunctionDeclaration || k + == NodeKind::AsyncGeneratorDeclaration || k == NodeKind::ForInStatement || k + == NodeKind::ForOfStatement || k == NodeKind::ImportDeclaration || k + == NodeKind::ExportDeclaration +} + +/// The var declared names of node `m` of a kind that is not [`var_special`]: the same whether +/// top-level or not. +#[verifier::rlimit(800)] +fn item_var_same(tk: &Tk, nodes: &[Node], m: usize, vf: &[Vec], Ghost(ts): Ghost) -> (r: Option< + Vec, +>) + requires + names_pre(tk, nodes@, ts, m as int), + vf.len() == m, + inv_v(arena_of(nodes@), ts, tk.toks@, vf@, false, m as int), + !var_special(nodes@[m as int].kind), + ensures + match r { + Some(v) => { + let a = arena_of(nodes@); + decl_ok(tk.toks@, v@) && dn(tk.toks@, v@) =~= var_names_item(a, ts, m as int, false) + && dn(tk.toks@, v@) =~= var_names_item(a, ts, m as int, true) + }, + None => true, + }, +{ + let ghost a = arena_of(nodes@); + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].kind == nd.kind); + assert(a.nodes[m as int].children.len() == nd.children.len()); + lemma_kids_before(a, m as int); + assert(dn(tk.toks@, Seq::::empty()) =~= Seq::>::empty()); + } + let toks = Ghost(tk.toks@); + let kind = nd.kind; + let none = usize::MAX; + match kind { + NodeKind::VariableStatement | NodeKind::VariableDeclarationList => { + let names = match tk.bn.get(m) { + Some(v) => v, + None => { + return None; + }, + }; + let v = decls_from_names(names.as_slice()); + proof { + assert(tk.bn@[m as int] == names); + assert(dn(tk.toks@, v@) =~= bound_names(a, ts, m as int)); + assert(decl_ok(tk.toks@, v@)); + } + Some(v) + }, + NodeKind::BlockStatement | NodeKind::SwitchStatement | NodeKind::CaseClause + | NodeKind::DefaultClause => { + let from: usize = if matches!(kind, NodeKind::BlockStatement | NodeKind::DefaultClause) { + 0 + } else { + 1 + }; + let v = match cat_exec(nodes, vf, m, from) { + Some(v) => v, + None => { + return None; + }, + }; + proof { + let ks = a.nodes[m as int].children; + lemma_var_cat(a, ts, tk.toks@, vf@, false, m as int, ks, from as int); + lemma_cat_ok(tk.toks@, vf@, ks, from as int, m as int); + } + Some(v) + }, + NodeKind::IfStatement => item_var_sum(nodes, toks, vf, m, (1, 2, none), Ghost(ts)), + NodeKind::DoWhileStatement | NodeKind::Finally => item_var_sum(nodes, toks, vf, m, (0, none, none), Ghost(ts)), + NodeKind::WhileStatement | NodeKind::WithStatement => item_var_sum(nodes, toks, vf, m, (1, none, none), Ghost(ts)), + NodeKind::ForStatement => item_var_sum(nodes, toks, vf, m, (0, 3, none), Ghost(ts)), + NodeKind::TryStatement => item_var_sum(nodes, toks, vf, m, (0, 1, 2), Ghost(ts)), + NodeKind::Catch => item_var_sum(nodes, toks, vf, m, (1, none, none), Ghost(ts)), + _ => Some(Vec::new()), + } +} + +/// The var declared names of node `m`, not top-level and top-level. +#[verifier::rlimit(800)] +pub fn item_var( + tk: &Tk, + nodes: &[Node], + m: usize, + vf: &[Vec], + Ghost(ts): Ghost, +) -> (r: Option<(Vec, Vec)>) + requires + names_pre(tk, nodes@, ts, m as int), + vf.len() == m, + inv_v(arena_of(nodes@), ts, tk.toks@, vf@, false, m as int), + ensures + match r { + Some((v1, v2)) => { + let a = arena_of(nodes@); + decl_ok(tk.toks@, v1@) && decl_ok(tk.toks@, v2@) && dn(tk.toks@, v1@) =~= var_names_item( + a, + ts, + m as int, + false, + ) && dn(tk.toks@, v2@) =~= var_names_item(a, ts, m as int, true) + }, + None => true, + }, +{ + let ghost a = arena_of(nodes@); + let kind = match nodes.get(m) { + Some(x) => x.kind, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(a.nodes[m as int].kind == kind); + assert(dn(tk.toks@, Seq::::empty()) =~= Seq::>::empty()); + } + match kind { + NodeKind::FunctionDeclaration | NodeKind::GeneratorDeclaration | NodeKind::AsyncFunctionDeclaration + | NodeKind::AsyncGeneratorDeclaration => { + let k0 = match kid_kind(nodes, m, 0) { + Some(k) => k, + None => { + return None; + }, + }; + if !matches!(k0, NodeKind::BindingIdentifier) { + return Some((Vec::new(), Vec::new())); + } + let c0 = match nodes.get(m) { + Some(nd) => match nd.children.as_slice().get(ZERO) { + Some(c) => *c as usize, + None => { + return None; + }, + }, + None => { + return None; + }, + }; + proof { + assert(a.nodes[m as int].children.len() > 0); + assert(a.nodes[m as int] == nodes@[m as int]@); + lemma_child_before(a, m as int, 0); + } + let d = match decl_of_ident(tk, nodes, c0, false, Ghost(ts)) { + Some(d) => d, + None => { + return None; + }, + }; + proof { + assert(dn(tk.toks@, seq![d]) =~= seq![name_of(a, ts, c0 as int)]); + assert(a.nodes[m as int].children[0] == c0 as int); + } + Some((Vec::new(), vec![d])) + }, + NodeKind::LabelledStatement | NodeKind::ForInStatement | NodeKind::ForOfStatement + | NodeKind::ImportDeclaration | NodeKind::ExportDeclaration => None, + _ => { + let v = match item_var_same(tk, nodes, m, vf, Ghost(ts)) { + Some(v) => v, + None => { + return None; + }, + }; + let mut w: Vec = Vec::new(); + push_decls(&mut w, v.as_slice()); + Some((v, w)) + }, + } +} + +/// The declared names of every node, bottom-up. +pub struct Names { + /// LexicallyDeclaredNames of each node. + pub lf: Vec>, + /// TopLevelLexicallyDeclaredNames. + pub lt: Vec>, + /// VarDeclaredNames. + pub vf: Vec>, + /// TopLevelVarDeclaredNames. + pub vt: Vec>, +} + +/// Every node's four lists of declared names (`None` where a node is not covered). +#[verifier::rlimit(400)] +pub fn decl_names_all(tk: &Tk, nodes: &[Node], Ghost(ts): Ghost) -> (r: Option) + requires + nodes.len() > 0, + ast_wf(arena_of(nodes@)), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + tk.bn.len() == nodes.len(), + bn_inv(arena_of(nodes@), ts, tk.toks@, tk.bn@, nodes.len() as int), + ensures + match r { + Some(nm) => { + let a = arena_of(nodes@); + let n = nodes.len() as int; + nm.lf.len() == nodes.len() && nm.lt.len() == nodes.len() && nm.vf.len() == nodes.len() + && nm.vt.len() == nodes.len() && inv_l(a, ts, tk.toks@, nm.lf@, false, n) && inv_l( + a, + ts, + tk.toks@, + nm.lt@, + true, + n, + ) && inv_v(a, ts, tk.toks@, nm.vf@, false, n) && inv_v(a, ts, tk.toks@, nm.vt@, true, n) + }, + None => true, + }, +{ + let ghost a = arena_of(nodes@); + let n = nodes.len(); + let mut lf: Vec> = Vec::new(); + let mut lt: Vec> = Vec::new(); + let mut vf: Vec> = Vec::new(); + let mut vt: Vec> = Vec::new(); + let mut m: usize = 0; + while m < n + invariant + m <= n, + n == nodes.len(), + lf.len() == m, + lt.len() == m, + vf.len() == m, + vt.len() == m, + a == arena_of(nodes@), + ast_wf(a), + toks_match(tk.src@, tk.toks@, ts), + starts_inc(ts), + tk.bn.len() == nodes.len(), + bn_inv(a, ts, tk.toks@, tk.bn@, nodes.len() as int), + inv_l(a, ts, tk.toks@, lf@, false, m as int), + inv_l(a, ts, tk.toks@, lt@, true, m as int), + inv_v(a, ts, tk.toks@, vf@, false, m as int), + inv_v(a, ts, tk.toks@, vt@, true, m as int), + decreases n - m, + { + let (l1, l2) = match item_lex(tk, nodes, m, lf.as_slice(), Ghost(ts)) { + Some(p) => p, + None => { + return None; + }, + }; + let (v1, v2) = match item_var(tk, nodes, m, vf.as_slice(), Ghost(ts)) { + Some(p) => p, + None => { + return None; + }, + }; + let ghost (olf, olt, ovf, ovt) = (lf@, lt@, vf@, vt@); + lf.push(l1); + lt.push(l2); + vf.push(v1); + vt.push(v2); + proof { + assert forall|j: int| 0 <= j < m as int + 1 implies { + let v = (#[trigger] lf@[j])@; + decl_ok(tk.toks@, v) && decls_of(tk.toks@, v) =~= lex_names_item(a, ts, j, false) + } by { + if j < m as int { + assert(lf@[j] == olf[j]); + } + } + assert forall|j: int| 0 <= j < m as int + 1 implies { + let v = (#[trigger] lt@[j])@; + decl_ok(tk.toks@, v) && decls_of(tk.toks@, v) =~= lex_names_item(a, ts, j, true) + } by { + if j < m as int { + assert(lt@[j] == olt[j]); + } + } + assert forall|j: int| 0 <= j < m as int + 1 implies { + let v = (#[trigger] vf@[j])@; + decl_ok(tk.toks@, v) && dn(tk.toks@, v) =~= var_names_item(a, ts, j, false) + } by { + if j < m as int { + assert(vf@[j] == ovf[j]); + } + } + assert forall|j: int| 0 <= j < m as int + 1 implies { + let v = (#[trigger] vt@[j])@; + decl_ok(tk.toks@, v) && dn(tk.toks@, v) =~= var_names_item(a, ts, j, true) + } by { + if j < m as int { + assert(vt@[j] == ovt[j]); + } + } + } + m = m.saturating_add(1); + } + Some(Names { lf, lt, vf, vt }) +} + +// --------------------------------------------------------------------- +// The rules that read the declared names. +// --------------------------------------------------------------------- + +/// `tk.nm` holds the declared names of every node. +pub open spec fn names_inv(tk: &Tk, nodes: Seq, ts: Stream) -> bool { + let a = arena_of(nodes); + let n = nodes.len() as int; + tk.nm.lf.len() == nodes.len() && tk.nm.lt.len() == nodes.len() && tk.nm.vf.len() == nodes.len() + && tk.nm.vt.len() == nodes.len() && inv_l(a, ts, tk.toks@, tk.nm.lf@, false, n) && inv_l( + a, + ts, + tk.toks@, + tk.nm.lt@, + true, + n, + ) && inv_v(a, ts, tk.toks@, tk.nm.vf@, false, n) && inv_v(a, ts, tk.toks@, tk.nm.vt@, true, n) +} + +/// No name of `ds` is declared twice, except by plain function declarations in sloppy mode code. +pub fn forbid_dup_exec(toks: &[DTok], ds: &[Decl], strict: bool) -> (r: bool) + requires + decl_ok(toks@, ds@), + ensures + r ==> !has_forbidden_duplicate(decls_of(toks@, ds@), strict), +{ + let len = ds.len(); + let mut i: usize = 0; + while i < len + invariant + len == ds.len(), + i <= len, + decl_ok(toks@, ds@), + forall|x: int, y: int| + 0 <= x < i && x < y < len ==> !(dn(toks@, ds@)[x] =~= dn(toks@, ds@)[y] && !(!strict + && ds@[x].pf && ds@[y].pf)), + decreases len - i, + { + let di = match ds.get(i) { + Some(d) => *d, + None => { + return false; + }, + }; + let ni = match toks.get(di.x) { + Some(t) => t, + None => { + return false; + }, + }; + let mut j: usize = i.saturating_add(1); + while j < len + invariant + len == ds.len(), + i < len, + i < j, + j <= len, + decl_ok(toks@, ds@), + di == ds@[i as int], + ni == &toks@[di.x as int], + forall|x: int, y: int| + 0 <= x < i && x < y < len ==> !(dn(toks@, ds@)[x] =~= dn(toks@, ds@)[y] && !( + !strict && ds@[x].pf && ds@[y].pf)), + forall|y: int| + i < y < j ==> !(dn(toks@, ds@)[i as int] =~= dn(toks@, ds@)[y] && !(!strict + && ds@[i as int].pf && ds@[y].pf)), + decreases len - j, + { + let dj = match ds.get(j) { + Some(d) => *d, + None => { + return false; + }, + }; + let nj = match toks.get(dj.x) { + Some(t) => t, + None => { + return false; + }, + }; + if seq_eq(ni.name.as_slice(), nj.name.as_slice()) && !(!strict && di.pf && dj.pf) { + return false; + } + j = j.saturating_add(1); + } + i = i.saturating_add(1); + } + proof { + let dd = decls_of(toks@, ds@); + assert forall|x: int, y: int| + 0 <= x < y < dd.len() implies !(#[trigger] decl_name(dd, x) =~= #[trigger] decl_name(dd, y) + && !(!strict && dd[x].plain_function && dd[y].plain_function)) by { + assert(x < len && y < len); + assert(decl_name(dd, x) == dn(toks@, ds@)[x]); + assert(decl_name(dd, y) == dn(toks@, ds@)[y]); + } + } + true +} + +/// No name is in both `xs` and `ys`. +pub fn no_intersect_dd(toks: &[DTok], xs: &[Decl], ys: &[Decl]) -> (r: bool) + requires + decl_ok(toks@, xs@), + decl_ok(toks@, ys@), + ensures + r ==> !intersects(dn(toks@, xs@), dn(toks@, ys@)), +{ + let xl = xs.len(); + let yl = ys.len(); + let mut i: usize = 0; + while i < xl + invariant + xl == xs.len(), + yl == ys.len(), + i <= xl, + decl_ok(toks@, xs@), + decl_ok(toks@, ys@), + forall|x: int, y: int| + 0 <= x < i && 0 <= y < yl ==> !(dn(toks@, xs@)[x] =~= dn(toks@, ys@)[y]), + decreases xl - i, + { + let dx = match xs.get(i) { + Some(d) => *d, + None => { + return false; + }, + }; + let nx = match toks.get(dx.x) { + Some(t) => t, + None => { + return false; + }, + }; + let mut j: usize = 0; + while j < yl + invariant + xl == xs.len(), + yl == ys.len(), + i < xl, + j <= yl, + decl_ok(toks@, xs@), + decl_ok(toks@, ys@), + dx == xs@[i as int], + nx == &toks@[dx.x as int], + forall|x: int, y: int| + 0 <= x < i && 0 <= y < yl ==> !(dn(toks@, xs@)[x] =~= dn(toks@, ys@)[y]), + forall|y: int| 0 <= y < j ==> !(dn(toks@, xs@)[i as int] =~= dn(toks@, ys@)[y]), + decreases yl - j, + { + let dy = match ys.get(j) { + Some(d) => *d, + None => { + return false; + }, + }; + let ny = match toks.get(dy.x) { + Some(t) => t, + None => { + return false; + }, + }; + if seq_eq(nx.name.as_slice(), ny.name.as_slice()) { + return false; + } + j = j.saturating_add(1); + } + i = i.saturating_add(1); + } + proof { + assert forall|x: int, y: int| + 0 <= x < dn(toks@, xs@).len() && 0 <= y < dn(toks@, ys@).len() implies !( + #[trigger] dn(toks@, xs@)[x] =~= #[trigger] dn(toks@, ys@)[y]) by { + assert(x < xl && y < yl); + } + } + true +} + +/// `list_early` of the statement list that is the children of node `m`. +#[verifier::rlimit(400)] +pub fn list_early_exec(tk: &Tk, nodes: &[Node], m: usize, strict: bool, top: bool, Ghost(ts): Ghost) -> (r: bool) + requires + names_pre(tk, nodes@, ts, m as int), + names_inv(tk, nodes@, ts), + ensures + r ==> list_early(arena_of(nodes@), ts, m as int, arena_of(nodes@).nodes[m as int].children, strict, top), +{ + let ghost a = arena_of(nodes@); + let toks = tk.toks; + let lexa: &Vec> = if top { + &tk.nm.lt + } else { + &tk.nm.lf + }; + let vara: &Vec> = if top { + &tk.nm.vt + } else { + &tk.nm.vf + }; + let lex = match cat_exec(nodes, lexa.as_slice(), m, 0) { + Some(v) => v, + None => { + return false; + }, + }; + let vars = match cat_exec(nodes, vara.as_slice(), m, 0) { + Some(v) => v, + None => { + return false; + }, + }; + proof { + lemma_kids_before(a, m as int); + let ks = a.nodes[m as int].children; + let la = if top { + tk.nm.lt@ + } else { + tk.nm.lf@ + }; + let va = if top { + tk.nm.vt@ + } else { + tk.nm.vf@ + }; + assert(arr_ok(toks@, la, m as int)); + assert(arr_ok(toks@, va, m as int)); + lemma_cat_ok(toks@, la, ks, 0, m as int); + lemma_cat_ok(toks@, va, ks, 0, m as int); + assert(lexa@ == la); + assert(vara@ == va); + lemma_lex_cat(a, ts, toks@, la, top, m as int, ks, 0); + lemma_var_cat(a, ts, toks@, va, top, m as int, ks, 0); + } + let ok1 = forbid_dup_exec(toks, lex.as_slice(), strict); + let ok2 = no_intersect_dd(toks, lex.as_slice(), vars.as_slice()); + proof { + lemma_dn_plain(toks@, lex@); + } + ok1 && ok2 +} + +/// The `LexicalDeclaration` node `m` has no `let` binding, no name twice, and an initializer for +/// each `const` (`early_local`, §14.3.1.1). +#[verifier::rlimit(400)] +pub fn lexical_decl_exec(tk: &Tk, nodes: &[Node], m: usize, Ghost(ts): Ghost) -> (r: bool) + requires + names_pre(tk, nodes@, ts, m as int), + arena_of(nodes@).nodes[m as int].kind == NodeKind::LexicalDeclaration, + ensures + r ==> ({ + let a = arena_of(nodes@); + let nd = a.nodes[m as int]; + let bn = bound_names(a, ts, m as int); + !has_name(bn, sv("let"@)) && !has_duplicate(bn) && (nd.op == Op::Const ==> forall|k: int| + 0 <= k < nd.children.len() ==> kd(a, kid(kids(a, #[trigger] nd.children[k]), 1)) + != NodeKind::Absent) + }), +{ + let ghost a = arena_of(nodes@); + let toks = tk.toks; + let names = match tk.bn.get(m) { + Some(v) => v, + None => { + return false; + }, + }; + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return false; + }, + }; + proof { + assert(tk.bn@[m as int] == names); + assert(bound_names(a, ts, m as int) =~= names_of(toks@, names@)); + assert(idx_ok(toks@, names@)); + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].op == nd.op); + assert(a.nodes[m as int].children.len() == nd.children.len()); + lemma_words_early(); + } + // No binding named `let`. + let len = names.len(); + let mut i: usize = 0; + while i < len + invariant + len == names.len(), + i <= len, + idx_ok(toks@, names@), + forall|q: int| 0 <= q < i ==> !(names_of(toks@, names@)[q] =~= sv("let"@)), + decreases len - i, + { + let t = match names.get(i) { + Some(x) => match toks.get(*x) { + Some(t) => t, + None => { + return false; + }, + }, + None => { + return false; + }, + }; + proof { + lemma_words_early(); + assert(t == &toks@[names@[i as int] as int]); + } + if seq_eq(t.name.as_slice(), &[0x6C, 0x65, 0x74]) { + return false; + } + i = i.saturating_add(1); + } + if !no_dup_exec(toks, names.as_slice()) { + return false; + } + if matches!(nd.op, Op::Const) { + let cl = nd.children.len(); + let mut k: usize = 0; + while k < cl + invariant + cl == nd.children.len(), + k <= cl, + m < nodes.len(), + nd == &nodes@[m as int], + a == arena_of(nodes@), + ast_wf(a), + cl == a.nodes[m as int].children.len(), + forall|q: int| + 0 <= q < k ==> kd(a, kid(kids(a, #[trigger] a.nodes[m as int].children[q]), 1)) + != NodeKind::Absent, + decreases cl - k, + { + let c = match nd.children.as_slice().get(k) { + Some(c) => *c as usize, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[k as int] == c as int); + lemma_child_before(a, m as int, k as int); + } + match kid_kind(nodes, c, 1) { + Some(NodeKind::Absent) => { + return false; + }, + Some(_) => {}, + None => { + return false; + }, + } + proof { + assert(kids(a, c as int) == a.nodes[c as int].children); + } + k = k.saturating_add(1); + } + } + true +} + +/// A `for ( LexicalDeclaration ...; ...; ...) Statement` node `m` has no bound name that the +/// body var-declares (`early_local`, §14.7.4.1); true for any other head. +#[verifier::rlimit(400)] +pub fn for_lex_exec(tk: &Tk, nodes: &[Node], m: usize, Ghost(ts): Ghost) -> (r: bool) + requires + names_pre(tk, nodes@, ts, m as int), + names_inv(tk, nodes@, ts), + ensures + r ==> ({ + let a = arena_of(nodes@); + let ks = a.nodes[m as int].children; + kd(a, kid(ks, 0)) == NodeKind::LexicalDeclaration ==> !intersects( + bound_names(a, ts, kid(ks, 0)), + var_names_sub(a, ts, m as int, kid(ks, 3)), + ) + }), +{ + let ghost a = arena_of(nodes@); + let toks = tk.toks; + let k0 = match kid_kind(nodes, m, 0) { + Some(k) => k, + None => { + return false; + }, + }; + if !matches!(k0, NodeKind::LexicalDeclaration) { + return true; + } + let nd = match nodes.get(m) { + Some(x) => x, + None => { + return false; + }, + }; + proof { + assert(a.nodes[m as int] == nodes@[m as int]@); + assert(nd == &nodes@[m as int]); + assert(a.nodes[m as int].children.len() == nd.children.len()); + lemma_kids_before(a, m as int); + } + let (c0, c3) = match (nd.children.as_slice().get(ZERO), nd.children.as_slice().get(3)) { + (Some(x), Some(y)) => (*x as usize, *y as usize), + _ => { + return false; + }, + }; + proof { + assert(a.nodes[m as int].children[0] == c0 as int); + assert(a.nodes[m as int].children[3] == c3 as int); + lemma_child_before(a, m as int, 0); + lemma_child_before(a, m as int, 3); + } + let names = match tk.bn.get(c0) { + Some(v) => v, + None => { + return false; + }, + }; + let body = match tk.nm.vf.get(c3) { + Some(v) => v, + None => { + return false; + }, + }; + let dd = decls_from_names(names.as_slice()); + proof { + assert(tk.bn@[c0 as int] == names); + assert(tk.nm.vf@[c3 as int] == body); + assert(dn(toks@, dd@) =~= names_of(toks@, names@)); + assert(bound_names(a, ts, c0 as int) =~= dn(toks@, dd@)); + assert(decl_ok(toks@, dd@)); + assert(dn(toks@, body@) =~= var_names_item(a, ts, c3 as int, false)); + assert(var_names_sub(a, ts, m as int, c3 as int) =~= var_names_item(a, ts, c3 as int, false)); + } + no_intersect_dd(toks, dd.as_slice(), body.as_slice()) +} + +/// The declarations of names that are tokens are of tokens. +pub proof fn lemma_decl_ok_names(toks: Seq, xs: Seq) + requires + idx_ok(toks, xs), + ensures + decl_ok(toks, decls_of_names(xs)), +{ +} + +/// The lexically declared names of the top-level items of node `b` (a function body). +pub proof fn lemma_lex_body(a: AstV, ts: Stream, tk: &Tk, nodes: Seq, b: int) + requires + names_inv(tk, nodes, ts), + a == arena_of(nodes), + ast_wf(a), + 0 <= b < nodes.len(), + ensures + decl_ok(tk.toks@, cat_d(tk.nm.lt@, a.nodes[b].children, 0)), + decls_of(tk.toks@, cat_d(tk.nm.lt@, a.nodes[b].children, 0)) =~= lex_names_list( + a, + ts, + a.nodes.len() as int, + a.nodes[b].children, + 0, + true, + ), +{ + let ks = a.nodes[b].children; + let n = nodes.len() as int; + lemma_kids_before(a, b); + assert forall|q: int| 0 <= q < ks.len() implies 0 <= #[trigger] ks[q] < n by { + assert(0 <= ks[q] < b); + } + assert(arr_ok(tk.toks@, tk.nm.lt@, n)); + lemma_cat_ok(tk.toks@, tk.nm.lt@, ks, 0, n); + lemma_lex_cat(a, ts, tk.toks@, tk.nm.lt@, true, n, ks, 0); +} + +} // verus! diff --git a/crates/clazel-js-syntax/src/arena_early.rs b/crates/clazel-js-syntax/src/arena_early.rs index 2f58b88e..f014e0b3 100644 --- a/crates/clazel-js-syntax/src/arena_early.rs +++ b/crates/clazel-js-syntax/src/arena_early.rs @@ -39,6 +39,7 @@ //! and `name`, the lexer's contract of item 7.2). use crate::arena_d::*; +use crate::arena_decls::*; use crate::arena_names::*; use crate::ast::*; use crate::spec::*; @@ -79,7 +80,7 @@ pub(crate) proof fn lemma_node_tok_at(a: AstV, ts: Stream, n: int, x: int) } /// The words of the identifier rules, as code points. -proof fn lemma_words_early() +pub(crate) proof fn lemma_words_early() ensures sv("yield"@) =~= seq![0x79u32, 0x69, 0x65, 0x6C, 0x64], sv("await"@) =~= seq![0x61u32, 0x77, 0x61, 0x69, 0x74], @@ -1083,83 +1084,6 @@ pub(crate) proof fn lemma_list_early_empty(a: AstV, ts: Stream, n: int, ks: Seq< })); } -/// The items of node `m` declare nothing lexically. -pub(crate) fn items_lex_empty(nodes: &[Node], m: usize, top: bool) -> (r: bool) - requires - m < nodes.len(), - ast_wf(arena_of(nodes@)), - ensures - r ==> forall|j: int| - 0 <= j < arena_of(nodes@).nodes[m as int].children.len() ==> lex_empty_kind( - kd(arena_of(nodes@), #[trigger] arena_of(nodes@).nodes[m as int].children[j]), - top, - ), -{ - let nd = match nodes.get(m) { - Some(x) => x, - None => { - return false; - }, - }; - let len = nd.children.len(); - let ghost a = arena_of(nodes@); - proof { - assert(a.nodes[m as int] == nodes@[m as int]@); - assert(nd == &nodes@[m as int]); - assert(a.nodes[m as int].children.len() == len); - } - let mut k: usize = 0; - while k < len - invariant - m < nodes.len(), - nodes@.len() == nodes.len(), - a == arena_of(nodes@), - ast_wf(a), - nd == &nodes@[m as int], - len == nd.children.len(), - len == a.nodes[m as int].children.len(), - k <= len, - forall|j: int| - 0 <= j < k ==> lex_empty_kind(kd(a, #[trigger] a.nodes[m as int].children[j]), top), - decreases len - k, - { - let c = match nd.children.as_slice().get(k) { - Some(x) => *x as usize, - None => { - return false; - }, - }; - proof { - assert(a.nodes[m as int].children[k as int] == c as int); - lemma_child_before(a, m as int, k as int); - } - let ck = match nodes.get(c) { - Some(x) => x.kind, - None => { - return false; - }, - }; - proof { - assert(a.nodes[c as int] == nodes@[c as int]@); - } - let ok = !(matches!( - ck, - NodeKind::LexicalDeclaration | NodeKind::ClassDeclaration | NodeKind::ImportDeclaration - | NodeKind::ExportDeclaration - ) || (!top && matches!( - ck, - NodeKind::FunctionDeclaration | NodeKind::GeneratorDeclaration - | NodeKind::AsyncFunctionDeclaration | NodeKind::AsyncGeneratorDeclaration - | NodeKind::LabelledStatement - ))); - if !ok { - return false; - } - k = k.saturating_add(1); - } - true -} - /// The kind of child `i` of node `m`, `Script` where there is none (`spec::kd(a, kid(ks, i))`). pub(crate) fn kid_kind(nodes: &[Node], m: usize, i: usize) -> (r: Option) requires @@ -1224,6 +1148,7 @@ fn early_local_exec( starts_inc(ts), tk.bn.len() == nodes.len(), bn_inv(arena_of(nodes@), ts, tk.toks@, tk.bn@, nodes.len() as int), + names_inv(tk, nodes@, ts), ensures r ==> early_local(arena_of(nodes@), ts, m as int, eenv_of(*e)), { @@ -1387,17 +1312,11 @@ fn early_local_exec( return false; }, }; - let k0 = match kid_kind(nodes, m, 0) { - Some(k) => k, - None => { - return false; - }, - }; proof { assert(a.nodes[m as int].children[3] == c as int); lemma_child_before(a, m as int, 3); } - c < m && not_labelled(nodes, c) && !matches!(k0, NodeKind::LexicalDeclaration) + c < m && not_labelled(nodes, c) && for_lex_exec(tk, nodes, m, Ghost(ts)) }, NodeKind::ContinueStatement | NodeKind::BreakStatement => { let k0 = match kid_kind(nodes, m, 0) { @@ -1415,34 +1334,11 @@ fn early_local_exec( e.in_breakable } }, - NodeKind::BlockStatement => { - let ok = items_lex_empty(nodes, m, false); - proof { - if ok { - lemma_list_early_empty(a, ts, m as int, a.nodes[m as int].children, e.strict, false); - } - } - ok - }, - NodeKind::Script => { - let ok = items_lex_empty(nodes, m, true); - proof { - if ok { - lemma_list_early_empty(a, ts, m as int, a.nodes[m as int].children, e.strict, true); - } - } - ok - }, + NodeKind::BlockStatement => list_early_exec(tk, nodes, m, e.strict, false, Ghost(ts)), + NodeKind::Script => list_early_exec(tk, nodes, m, e.strict, true, Ghost(ts)), NodeKind::ObjectLiteral => object_literal_exec(tk, nodes, m, Ghost(ts)), - NodeKind::FunctionBody => { - let ok = items_lex_empty(nodes, m, true); - proof { - if ok { - lemma_list_early_empty(a, ts, m as int, a.nodes[m as int].children, e.strict, true); - } - } - ok - }, + NodeKind::FunctionBody => list_early_exec(tk, nodes, m, e.strict, true, Ghost(ts)), + NodeKind::LexicalDeclaration => lexical_decl_exec(tk, nodes, m, Ghost(ts)), NodeKind::FunctionDeclaration | NodeKind::FunctionExpression | NodeKind::GeneratorDeclaration | NodeKind::GeneratorExpression | NodeKind::AsyncFunctionDeclaration | NodeKind::AsyncFunctionExpression | NodeKind::AsyncGeneratorDeclaration @@ -1661,7 +1557,18 @@ pub fn check_early( return Derivation::Unsupported; }, }; - let tk = Tk { src, toks, by_start: by_start.as_slice(), bn: bn.as_slice() }; + let empty = Names { lf: Vec::new(), lt: Vec::new(), vf: Vec::new(), vt: Vec::new() }; + let tk0 = Tk { src, toks, by_start: by_start.as_slice(), bn: bn.as_slice(), nm: &empty }; + let nm = match decl_names_all(&tk0, nodes, Ghost(ts)) { + Some(nm) => nm, + None => { + return Derivation::Unsupported; + }, + }; + let tk = Tk { src, toks, by_start: by_start.as_slice(), bn: bn.as_slice(), nm: &nm }; + proof { + assert(names_inv(&tk, nodes@, ts)); + } // The root's environment: a script, strict if its Directive Prologue has a Use Strict Directive. let root_strict = match use_strict_exec(src, nodes, toks, by_start.as_slice(), last, Ghost(ts)) { Some(v) => v, @@ -1772,6 +1679,7 @@ pub fn check_early( tk.src@ == src@, tk.toks@ == toks@, tk.bn@ == bn@, + names_inv(&tk, nodes@, ts), starts_inc(ts), bn.len() == n, bn_inv(a, ts, toks@, bn@, n as int), @@ -1815,6 +1723,7 @@ pub fn check_early( tk.src@ == src@, tk.toks@ == toks@, tk.bn@ == bn@, + names_inv(&tk, nodes@, ts), starts_inc(ts), forall|j: int| 0 <= j < m ==> early(a, ts, j, eenv_of(envs@[j])), forall|q: int| diff --git a/crates/clazel-js-syntax/src/arena_names.rs b/crates/clazel-js-syntax/src/arena_names.rs index ad225722..8d47cfd4 100644 --- a/crates/clazel-js-syntax/src/arena_names.rs +++ b/crates/clazel-js-syntax/src/arena_names.rs @@ -27,6 +27,8 @@ pub struct Tk<'a> { pub by_start: &'a [usize], /// The BoundNames of each node ([`bn_inv`]). pub bn: &'a [Vec], + /// The declared names of each node ([`crate::arena_decls::names_inv`]). + pub nm: &'a crate::arena_decls::Names, } /// The names of the tokens `xs`. @@ -887,6 +889,7 @@ pub fn function_early_exec( starts_inc(ts), tk.bn.len() == nodes.len(), bn_inv(arena_of(nodes@), ts, tk.toks@, tk.bn@, nodes.len() as int), + crate::arena_decls::names_inv(tk, nodes@, ts), ensures r ==> { let a = arena_of(nodes@); @@ -906,7 +909,7 @@ pub fn function_early_exec( let by_start = tk.by_start; let bn = tk.bn; let ghost a = arena_of(nodes@); - let (hus, lex_empty) = match body { + let (hus, lex) = match body { Some(b) => { let h = match use_strict_exec(src, nodes, toks, by_start, b, Ghost(ts)) { Some(h) => h, @@ -914,13 +917,16 @@ pub fn function_early_exec( return false; }, }; - (h, items_lex_empty(nodes, b, true)) + let l = match crate::arena_decls::cat_exec(nodes, tk.nm.lt.as_slice(), b, 0) { + Some(l) => l, + None => { + return false; + }, + }; + (h, l) }, - None => (false, true), + None => (false, Vec::new()), }; - if !lex_empty { - return false; - } let simple = simple_params_exec(nodes, params); if hus && !simple { return false; @@ -940,6 +946,22 @@ pub fn function_early_exec( if need_unique && !distinct { return false; } + let names_dd = crate::arena_decls::decls_from_names(names.as_slice()); + proof { + crate::arena_decls::lemma_decl_ok_names(toks@, names@); + match body { + Some(b) => { + crate::arena_decls::lemma_lex_body(arena_of(nodes@), ts, tk, nodes@, b as int); + }, + None => { + assert(lex@ =~= Seq::::empty()); + }, + } + assert(crate::arena_decls::decl_ok(toks@, lex@)); + } + if !crate::arena_decls::no_intersect_dd(toks, names_dd.as_slice(), lex.as_slice()) { + return false; + } proof { let body_ks = match body { Some(b) => kids(a, b as int), @@ -948,14 +970,23 @@ pub fn function_early_exec( let nb = a.nodes.len() as int; let strict = env_strict || has_use_strict(a, ts, body_ks); assert(has_use_strict(a, ts, body_ks) == hus); - if let Some(b) = body { - lemma_lex_list_empty(a, ts, nb, body_ks, 0, true); + let lexn = lex_names_list(a, ts, nb, body_ks, 0, true); + match body { + Some(b) => { + crate::arena_decls::lemma_lex_body(a, ts, tk, nodes@, b as int); + assert(crate::arena_decls::decls_of(toks@, lex@) =~= lexn); + }, + None => { + assert(body_ks =~= Seq::::empty()); + assert(lexn =~= Seq::::empty()); + assert(crate::arena_decls::decls_of(toks@, lex@) =~= Seq::::empty()); + }, } - assert(lex_names_list(a, ts, nb, body_ks, 0, true) =~= Seq::::empty()); - assert(plain_names(lex_names_list(a, ts, nb, body_ks, 0, true)) =~= Seq::>::empty()); let bnames = bound_names(a, ts, params as int); assert(bnames =~= names_of(toks@, names@)); - assert(!intersects(bnames, plain_names(lex_names_list(a, ts, nb, body_ks, 0, true)))); + assert(crate::arena_decls::dn(toks@, names_dd@) =~= bnames); + assert(plain_names(lexn) =~= crate::arena_decls::dn(toks@, lex@)); + assert(!intersects(bnames, plain_names(lexn))); if strict || unique || !is_simple_params(a, params as int) { if env_strict || hus || unique || !simple { assert(!has_duplicate(names_of(toks@, names@))); diff --git a/crates/clazel-js-syntax/src/lib.rs b/crates/clazel-js-syntax/src/lib.rs index 39ed3cab..7d8d8add 100644 --- a/crates/clazel-js-syntax/src/lib.rs +++ b/crates/clazel-js-syntax/src/lib.rs @@ -62,6 +62,7 @@ pub mod api; pub mod arena_d; pub mod arena_e; +pub mod arena_decls; pub mod arena_early; pub mod arena_names; pub mod arena_m; diff --git a/crates/clazel-js-syntax/tests/derivation.rs b/crates/clazel-js-syntax/tests/derivation.rs index 27a620d1..28d7021e 100644 --- a/crates/clazel-js-syntax/tests/derivation.rs +++ b/crates/clazel-js-syntax/tests/derivation.rs @@ -337,6 +337,9 @@ fn covered_early_rules_are_verified() { "{ a; { b; } }", "var a; var a;", "'use strict'; a = 1;", + "let a; const b = 1; { let a; var c; function f() {} function f() {} }", + "for (let i = 0; i < 1; i++) { var j; }", + "function f(a) { let b; { let a; } }", "x = { m(a) { return a; }, get g() { return 1; }, __proto__: null, ['__proto__']: 1 };", "(function () {})", "function f(a, [b], {c}, ...d) { return a; }", @@ -359,7 +362,6 @@ fn covered_early_rules_are_verified() { #[test] fn other_early_rules_are_unsupported_not_failed() { for s in [ - "let a;", "a: b;", "class A {}", "for (a in b) ;", From 7a4457afece62b8b8b54e07b903396cfbbc0aeb1 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 17:00:02 +0000 Subject: [PATCH 028/195] clazel-jit: the state relation and the refinement statements of the LIR to A64 back end The contract half of J.9's A64 back end (CLAUDE.md rule 3): the state relation over clazel-a64's State with the frame at [x28 + 264 + 8 j], the refines and exit_refines statements, and the emitter's contracts. No template yet. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 1 + crates/clazel-jit/Cargo.toml | 3 +- crates/clazel-jit/src/a64/api.rs | 44 ++++ crates/clazel-jit/src/a64/contract.rs | 153 ++++++++++++ crates/clazel-jit/src/a64/mod.rs | 21 ++ crates/clazel-jit/src/a64/spec.rs | 322 ++++++++++++++++++++++++++ crates/clazel-jit/src/lib.rs | 1 + 7 files changed, 544 insertions(+), 1 deletion(-) create mode 100644 crates/clazel-jit/src/a64/api.rs create mode 100644 crates/clazel-jit/src/a64/contract.rs create mode 100644 crates/clazel-jit/src/a64/mod.rs create mode 100644 crates/clazel-jit/src/a64/spec.rs diff --git a/Cargo.lock b/Cargo.lock index b455056e..7afefd85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -393,6 +393,7 @@ dependencies = [ name = "clazel-jit" version = "0.0.0" dependencies = [ + "clazel-a64", "clazel-codecheck", "clazel-lir", "clazel-x64", diff --git a/crates/clazel-jit/Cargo.toml b/crates/clazel-jit/Cargo.toml index f916b9c3..7e3405cb 100644 --- a/crates/clazel-jit/Cargo.toml +++ b/crates/clazel-jit/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" edition.workspace = true license.workspace = true publish.workspace = true -description = "The JIT's back ends (docs/phases/jit.md item J.9): LIR to x86-64 with no register allocation, each LIR instruction a fixed template over scratch registers, with a Verus refinement proof per template. First slice: straight-line integer code. No JS front end, no A64 back end, no code cache yet." +description = "The JIT's back ends (docs/phases/jit.md item J.9): LIR to x86-64 with no register allocation, each LIR instruction a fixed template over scratch registers, with a Verus refinement proof per template. First slice: straight-line integer code, for x86-64 (crate root) and A64 (`a64`). No JS front end, no code cache yet." [dependencies] vstd = "=0.0.0-2026-10-04-0306" @@ -12,6 +12,7 @@ vstd = "=0.0.0-2026-10-04-0306" # ABI (context register, region table, exit sequence) the templates follow. clazel-lir = { path = "../clazel-lir" } clazel-x64 = { path = "../clazel-x64" } +clazel-a64 = { path = "../clazel-a64" } clazel-codecheck = { path = "../clazel-codecheck" } # Verification tier (docs/VERIFICATION.md). `tier` is what is proven about the diff --git a/crates/clazel-jit/src/a64/api.rs b/crates/clazel-jit/src/a64/api.rs new file mode 100644 index 00000000..4caa4784 --- /dev/null +++ b/crates/clazel-jit/src/a64/api.rs @@ -0,0 +1,44 @@ +//! The contract-only API of the A64 back end: a trait with no implementation, +//! so Verus accepts it with no escape hatch (CLAUDE.md rule 4), the pattern of +//! [`crate::api`]. The implementation (the next commit) implements it. +//! +//! The input is [`Op`]s, as for x86-64: LIR's own `Instr` holds proof-only +//! numbers and sequences, and the JS front end (J.10) will have its own +//! executable form. [`Op`]'s `view` says which LIR instruction each stands for. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// The LIR → A64 back end, with its contracts. +pub trait Backend { + /// The A64 instructions for the straight-line program `ops`, in a + /// function with `nl` locals, entered with an empty operand stack (see + /// [`crate::a64::contract::emit_body_ensures`]). + fn emit_body(ops: &[Op], nl: usize) -> (r: Option>) + requires + crate::a64::contract::emit_requires(ops@, nl), + ensures + crate::a64::contract::emit_body_ensures(ops@, nl, match r { + Some(v) => Some(v@), + None => None, + }), + ; + + /// The bytes of a blob: the canonical encoding of the body, then the exit + /// sequence for `exit_code` (see [`crate::a64::contract::emit_blob_ensures`]). + fn emit_blob(ops: &[Op], nl: usize, exit_code: u16) -> (r: Option>) + requires + crate::a64::contract::emit_requires(ops@, nl), + ensures + crate::a64::contract::emit_blob_ensures(ops@, nl, exit_code, match r { + Some(v) => Some(v@), + None => None, + }), + ; +} + +} // verus! diff --git a/crates/clazel-jit/src/a64/contract.rs b/crates/clazel-jit/src/a64/contract.rs new file mode 100644 index 00000000..06b3346c --- /dev/null +++ b/crates/clazel-jit/src/a64/contract.rs @@ -0,0 +1,153 @@ +//! What the A64 back end must be proven to satisfy (CLAUDE.md rule 3, +//! docs/SPEC-STYLE.md): the refinement statements, and one `requires` and one +//! `ensures` predicate for each method of [`super::api::Backend`], in terms of +//! [`super::spec`] and the two semantics it relates. These are written before +//! any template; reviewing them and `spec` is enough to know what is claimed. +//! They are [`crate::contract`]'s statements with the A64 machine. +//! +//! # The refinement statement +//! +//! [`refines`]`(i, nl, h, code)` says that the A64 instruction list `code` is a +//! correct translation of the LIR instruction `i`, for a function with `nl` +//! locals, when the operand stack has `h` values. For every layout, every LIR +//! state `a` and machine state `m` related by [`rel`]: +//! +//! - if LIR evaluates `i` in `a` (with any fuel) and **falls through** to the +//! state `a2` (a `Stuck` or `OutOfFuel` outcome is not claimed about, and +//! `i` is not required to be well typed: if it is not, LIR is `Stuck`, and +//! the statement says nothing), +//! - and the end of the code does not wrap the address space, +//! - then running `code` from `m` ([`run_seq`]) does not fault, ends in a +//! machine state `m2` related to `a2` by [`rel`], with `pc` after the code, +//! and `m2` differs from `m` only in the exit area ([`preserved`]). +//! +//! That is a **forward simulation of one LIR step by one template**. The exit +//! is [`exit_refines`]; failed steps and branches belong to the control-flow +//! templates, which this slice does not have. A straight-line program is one +//! [`refines`] over [`prog_instr`]. +//! +//! # What is not stated +//! +//! - That the output is **accepted by the A64 validator.** +//! `tests/validator_a64.rs` checks it for every template and generated +//! programs, by running the executable validator. It is not a theorem here. +//! - That a *failed* LIR step is matched by the machine: no template in this +//! slice has one. +//! - Anything about [`rel`]'s `pc`, flags or scratch registers. + +#[allow(unused_imports)] +use super::spec::*; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +/// What the machine must be in after `code` ran from `m`, for the LIR state +/// `a2` that `i` reached: no fault, related, `pc` after the code, and nothing +/// outside the exit area changed. +pub open spec fn refines_post( + lay: lir::Layout, + a2: lir::St, + m: isa::State, + nl: nat, + code: Seq, + r: Option, +) -> bool { + match r { + Some(m2) => rel(lay, a2, m2, nl) && m2.pc as int == m.pc as int + code_len(code) + && preserved(m, m2), + None => false, + } +} + +/// `code` refines the LIR instruction `i` at stack height `h` with `nl` +/// locals (see the module doc). +pub open spec fn refines(i: lir::Instr, nl: nat, h: nat, code: Seq) -> bool { + forall|lay: lir::Layout, a: lir::St, m: isa::State, fuel: nat| + #![trigger lir::eval(lay, i, a, fuel), run_seq(m, code)] + a.stack.len() == h && rel(lay, a, m, nl) && (m.pc as int) + code_len(code) + < isa::p2(64) ==> match lir::eval(lay, i, a, fuel) { + lir::Outcome::Normal(a2) => refines_post(lay, a2, m, nl, code, run_seq(m, code)), + _ => true, + } +} + +/// The exit sequence for `c` refines LIR's `exit c` with no operands: running +/// the three instructions does not fault; the machine ends at the return +/// address the enter stub left in the link register, with the exit code `c` in +/// the context's exit-code word, the frame and the regions as they were +/// ([`rel`] still holds, and the memory outside the exit area is unchanged), +/// and the link register and `SP` as they were. +pub open spec fn exit_refines(c: u16, nl: nat) -> bool { + forall|lay: lir::Layout, a: lir::St, m: isa::State, fuel: nat| + #![trigger lir::eval(lay, lir::Instr::Exit(c as nat, seq![]), a, fuel), run_seq(m, exit_seq(c))] + rel(lay, a, m, nl) && (m.pc as int) + code_len(exit_seq(c)) < isa::p2(64) + ==> match lir::eval(lay, lir::Instr::Exit(c as nat, seq![]), a, fuel) { + lir::Outcome::Exit(code, _, a2) => match run_seq(m, exit_seq(c)) { + Some(m2) => rel(lay, a2, m2, nl) && preserved(m, m2) && isa::mem_read( + m2.mem, + ctx_of(m) + abi::exit_code_off(), + 8, + ) == Some(code as int) && m2.pc == m.r[abi::link_reg() as int], + None => false, + }, + _ => true, + } +} + +// ---------------------------------------------------------------------------- +// The emitter's contracts (the executable back end, `api::Backend`) +// ---------------------------------------------------------------------------- + +/// The instructions of `code` are all in the A64 subset ([`isa::valid_instr`]). +pub open spec fn all_valid_instrs(code: Seq) -> bool { + forall|j: int| 0 <= j < code.len() ==> isa::valid_instr(#[trigger] code[j]) +} + +/// Precondition of `emit_body` and `emit_blob`: none. Every program and every +/// local count is a legal input (one outside the first slice, or too large +/// for the frame, is answered `None`). +pub open spec fn emit_requires(ops: Seq, nl: usize) -> bool { + true +} + +/// Postcondition of `emit_body`: the program has a translation exactly when +/// [`prog_ok`] says every instruction has a template; the translation is in +/// the subset and refines the program's LIR instruction. +pub open spec fn emit_body_ensures( + ops: Seq, + nl: usize, + r: Option>, +) -> bool { + match r { + Some(code) => prog_ok(ops, nl as nat, 0) && all_valid_instrs(code) && refines( + prog_instr(ops), + nl as nat, + 0, + code, + ), + None => !prog_ok(ops, nl as nat, 0), + } +} + +/// Postcondition of `emit_blob`: the bytes are exactly the canonical +/// encodings ([`clazel_codecheck::a64::spec::decodes_to`], which is what the +/// validator reads back) of a body that refines the program, followed by the +/// exit sequence for `exit_code`. `None` exactly when the program has no +/// translation. +pub open spec fn emit_blob_ensures( + ops: Seq, + nl: usize, + exit_code: u16, + r: Option>, +) -> bool { + match r { + Some(bytes) => prog_ok(ops, nl as nat, 0) && exists|body: Seq| + #![trigger all_valid_instrs(body)] + all_valid_instrs(body) && refines(prog_instr(ops), nl as nat, 0, body) + && clazel_codecheck::a64::spec::decodes_to(bytes, body + exit_seq(exit_code)), + None => !prog_ok(ops, nl as nat, 0), + } +} + +} // verus! diff --git a/crates/clazel-jit/src/a64/mod.rs b/crates/clazel-jit/src/a64/mod.rs new file mode 100644 index 00000000..8bc0cba3 --- /dev/null +++ b/crates/clazel-jit/src/a64/mod.rs @@ -0,0 +1,21 @@ +//! The LIR → A64 back end (docs/phases/jit.md item J.9, second half). It +//! mirrors the x86-64 back end in the crate root, module for module, with the +//! A64 differences listed in [`spec`]'s header. Like the root, it was written +//! contract first (CLAUDE.md rule 3): [`spec`], [`contract`] and [`api`] came +//! in their own commit, before any template. +//! +//! - [`spec`]: **what the back end is about.** The state relation between a +//! LIR state and an A64 machine state, the frame layout (the A64 ABI of +//! `clazel-codecheck` fixes where the code may write), the exit sequence. +//! Read its header first: it lists the modelling choices. +//! - [`contract`]: the refinement statements (a template's A64 code, run under +//! `clazel-a64`'s `step` from a related state, reaches a state related to +//! LIR's `eval`), and the emitter's contracts. +//! - [`api`]: the contract-only trait [`api::Backend`]. +//! +//! The templates and their proofs follow in the next commit; this module's +//! documentation then says what is proven and what is not. + +pub mod api; +pub mod contract; +pub mod spec; diff --git a/crates/clazel-jit/src/a64/spec.rs b/crates/clazel-jit/src/a64/spec.rs new file mode 100644 index 00000000..6a329d2c --- /dev/null +++ b/crates/clazel-jit/src/a64/spec.rs @@ -0,0 +1,322 @@ +//! What the LIR → A64 back end is *about* (jit.md item J.9): the state +//! relation between a LIR state and an A64 machine state, the shape of the +//! frame, and the small definitions the refinement statements of +//! [`crate::a64::contract`] are written in. Nothing here runs and nothing is +//! proven. It is the A64 counterpart of [`crate::spec`] and follows its design; +//! this header says where the two differ. Read that header for the choices +//! the two share (the frame is a slot per local and per operand-stack +//! element, a value is a 64-bit word, no register is live between two LIR +//! instructions, memory is related and not yet touched). +//! +//! # Source +//! +//! There is no standard to transcribe. The sources are: +//! +//! - **jit.md, "J.9 Back ends"**: "No register allocation: every LIR local is +//! a frame slot, and each LIR instruction is a fixed template over scratch +//! registers, so each template's proof is local." +//! - **`clazel-lir`'s `spec`** ([`lir::eval`]): the meaning of the source. +//! - **`clazel-a64`'s `spec`** ([`isa::step`]): the meaning of the target. +//! - **`clazel-codecheck`'s `a64::spec::abi`**: the context register `x28`, +//! the reserved registers (`x28`, `x30`, `SP`), the region table, which +//! context bytes the code may write, and the exit sequence (`movz`; `str +//! [x28, #256]`; `ret`). The templates follow it so that what they emit is +//! accepted (the test in `tests/validator_a64.rs`; the validator's own spec +//! is not re-stated here). +//! +//! # Where A64 differs from the x86-64 back end +//! +//! 1. **The frame** is the same bytes: the context's exit area after the exit +//! code, slot `j` at `[x28 + 264 + 8 j]`, `j < 31`. A64's `LDR`/`STR` +//! (unsigned immediate) of an X register takes the whole offset as `imm12 * +//! 8`, so slot `j` is `imm12 = 33 + j` ([`slot_imm`]); the validator accepts +//! a store only at an offset of 256 or more and an access that ends by 512 +//! ([`abi::ctx_size`]), which is exactly the frame ([`max_slots`]). The two +//! ABIs agree on these numbers; the proof module of the next commit shows it +//! against [`crate::spec`]'s. +//! 2. **The scratch registers** are `x0`, `x1` and `x2` ([`x0`], [`x1`], +//! [`x2`]), and so are the temporaries of the templates' middles: no +//! register is live between two LIR instructions, so the relation does not +//! mention them. `x28` (the context), `x30` (the link register) and `SP` are +//! never written ([`preserved`]). The flags `NZCV` are not mentioned either. +//! 3. **There is no undefined-value source.** `clazel-a64`'s [`isa::step`] takes +//! none (its header explains why), so the statements have no `create_undef` +//! parameter. +//! 4. **Instructions are four bytes.** [`code_len`] is `4 * code.len()`, and +//! `pc` advances by 4 per instruction. The end of the code must not wrap the +//! 64-bit address space (a `requires` of each refinement; x86-64's is "the +//! end address is canonical"). That the bytes at `pc` are the canonical +//! encodings ([`isa::fetch_ok`]) is not part of the statement, as for +//! x86-64: [`preserved`] says the code writes only the exit area, so code +//! placed outside it stays what it was, and the bytes are the emitter's +//! contract. +//! 5. **User-space addresses.** The context lies below `2^47` ([`ctx_ok`]), so +//! every address a template forms is far below `2^56`, the bound +//! [`isa::wf`] puts on mapped addresses (no top-byte-ignore subtlety, no +//! wrap-around). +//! 6. **The exit code is 16 bits.** The validator's exit sequence is `movz +//! wt, #code` with `hw = 0`, so the code is a `u16` ([`exit_seq`]); +//! x86-64's `mov eax, imm32` allows 32. +//! 7. **The exit sequence returns through `x30`** and reads no memory: `ret` +//! sets `pc` to `x30` ([`isa::step`]), so there is no stack-pointer +//! precondition ([`crate::spec::stack_ok`]) and `SP` is untouched. +//! +//! # What is not here +//! +//! The memory instructions, structured control flow, `exit` with operands, +//! `f64` arithmetic, comparisons and conversions (LIR's `f64` operators are +//! uninterpreted functions), and rotates (`clazel-a64`'s subset has no `RORV`). + +/// The source subset's instruction type, shared with the x86-64 back end: +/// [`Op`] and its stack effect ([`crate::spec`]) are target-independent. +pub use crate::spec::Op; +/// `clazel-a64`'s semantics (the A64 subset), re-exported so that this crate's +/// modules read one namespace. +pub use clazel_a64::spec as isa; +/// The validator's A64 ABI, re-exported likewise. +pub use clazel_codecheck::a64::spec::abi; +/// LIR's semantics, re-exported likewise. +pub use clazel_lir::spec as lir; +#[allow(unused_imports)] +use vstd::prelude::*; + +verus! { + +// ============================================================================ +// Section: the source subset +// ============================================================================ + +/// The program as one LIR instruction ([`crate::spec::prog_instr`]). +pub open spec fn prog_instr(ops: Seq) -> lir::Instr { + crate::spec::prog_instr(ops) +} + +/// The stack height after the program `ops`, started at height `h` +/// ([`crate::spec::height_after`]). +pub open spec fn height_after(ops: Seq, h: nat) -> nat { + crate::spec::height_after(ops, h) +} + +/// The value in slot `j` of the LIR state `a` ([`crate::spec::slot_val`]). +pub open spec fn slot_val(a: lir::St, nl: nat, j: nat) -> lir::Val { + crate::spec::slot_val(a, nl, j) +} + +/// `a` is an address inside some region of `lay` ([`crate::spec::in_regions`]). +pub open spec fn in_regions(lay: lir::Layout, a: nat) -> bool { + crate::spec::in_regions(lay, a) +} + +/// LIR's memory and the machine's agree on every byte of every region +/// ([`crate::spec::mem_rel`]). +pub open spec fn mem_rel(lay: lir::Layout, lm: lir::Mem, mm: Map) -> bool { + crate::spec::mem_rel(lay, lm, mm) +} + +/// The instruction has a template, and is well formed at a stack of height +/// `h` with `nl` locals: the frame holds the stack as it is (`nl + h` slots) +/// and as it will be, its operands exist, its local index is in range, and so +/// everything it reads or writes is one of the 31 frame slots. As +/// [`crate::spec::op_ok`], with this module's [`max_slots`]. +pub open spec fn op_ok(op: Op, nl: nat, h: nat) -> bool { + nl + h <= max_slots() && crate::spec::pops(op) <= h && nl + crate::spec::height_after_op(op, h) + <= max_slots() && match op { + Op::LocalGet(x) => x < nl, + Op::LocalSet(x) => x < nl, + Op::LocalTee(x) => x < nl, + Op::Bin(b) => crate::spec::bin_supported(b), + Op::Un(u) => crate::spec::un_supported(u), + _ => true, + } +} + +/// Every instruction of `ops` has a template at its place in the program, for +/// `nl` locals and a stack that starts at height `h`, and the starting frame +/// fits. +pub open spec fn prog_ok(ops: Seq, nl: nat, h: nat) -> bool + decreases ops.len(), +{ + if ops.len() == 0 { + nl + h <= max_slots() + } else { + prog_ok(ops.drop_last(), nl, h) && op_ok(ops.last(), nl, height_after(ops.drop_last(), h)) + } +} + +// ============================================================================ +// Section: the frame +// ============================================================================ + +/// `x0`, the first scratch register. +pub open spec fn x0() -> u8 { + 0 +} + +/// `x1`, the second scratch register. +pub open spec fn x1() -> u8 { + 1 +} + +/// `x2`, the third scratch register. +pub open spec fn x2() -> u8 { + 2 +} + +/// The offset from the context register of frame slot 0: the first word +/// after the exit code. +pub open spec fn frame_off() -> int { + abi::exit_code_off() + 8 +} + +/// The number of frame slots: the words of the context after the exit code. +pub open spec fn max_slots() -> nat { + ((abi::ctx_size() - frame_off()) / 8) as nat +} + +/// The displacement of frame slot `j` from the context register. +pub open spec fn slot_disp(j: nat) -> int { + frame_off() + 8 * j +} + +/// The `imm12` of the `LDR`/`STR` (unsigned immediate, X register) of frame +/// slot `j`: the displacement divided by the access size. +pub open spec fn slot_imm(j: nat) -> u16 { + (slot_disp(j) / 8) as u16 +} + +/// The value of the context register in `m`, as an address. +pub open spec fn ctx_of(m: isa::State) -> int { + m.r[abi::ctx_reg() as int] as int +} + +/// The context lies in user space: the 512 bytes from the context register +/// are all below `2^47` (modelling choice 5). +pub open spec fn ctx_ok(m: isa::State) -> bool { + m.r.len() == 31 && 0 <= ctx_of(m) && ctx_of(m) + abi::ctx_size() <= isa::p2(47) +} + +/// `a` is a byte of the context's exit area (what [`abi`] lets code write). +pub open spec fn in_exit_area(ctxb: int, a: int) -> bool { + ctxb + abi::exit_code_off() <= a && a < ctxb + abi::ctx_size() +} + +/// Every byte of the exit area is mapped. +pub open spec fn exit_area_mapped(mm: Map, ctxb: int) -> bool { + forall|a: int| #[trigger] in_exit_area(ctxb, a) ==> mm.dom().contains(a) +} + +/// The 8 bytes at the address of slot `j` read as the word `v`. +pub open spec fn slot_holds(mm: Map, ctxb: int, j: nat, v: nat) -> bool { + isa::mem_read(mm, ctxb + slot_disp(j), 8) == Some(v as int) +} + +// ============================================================================ +// Section: the state relation +// ============================================================================ + +/// No region overlaps the context's exit area, which holds the frame: the +/// frame is the only machine memory the templates write, and it is nobody's +/// region. +pub open spec fn regions_clear_of_exit_area(lay: lir::Layout, ctxb: int) -> bool { + forall|a: nat| #[trigger] in_regions(lay, a) ==> !in_exit_area(ctxb, a as int) +} + +/// **The state relation.** The LIR state `a`, with `nl` locals, is +/// represented by the machine state `m`: +/// +/// 1. `m` is a well-formed machine state ([`isa::wf`]), with the context in +/// user space ([`ctx_ok`]) and the layout well formed and clear of the +/// exit area; +/// 2. the frame fits: `a` has `nl` locals and `nl + height` is at most 31; +/// 3. the exit area is mapped, so a store to a slot does not fault; +/// 4. every local, and every operand-stack element, is in its slot, as the +/// 64-bit word [`lir::val_bits`] of its value; +/// 5. memory is related ([`mem_rel`]). +/// +/// The scratch registers, the flags and `pc` are not constrained; the +/// refinement statements say where `pc` is. +pub open spec fn rel(lay: lir::Layout, a: lir::St, m: isa::State, nl: nat) -> bool { + isa::wf(m) && ctx_ok(m) && lir::layout_wf(lay) && regions_clear_of_exit_area(lay, ctx_of(m)) + && a.locals.len() == nl && nl + a.stack.len() <= max_slots() && exit_area_mapped( + m.mem, + ctx_of(m), + ) && (forall|j: nat| + j < nl + a.stack.len() ==> #[trigger] slot_holds( + m.mem, + ctx_of(m), + j, + lir::val_bits(slot_val(a, nl, j)), + )) && mem_rel(lay, a.mem, m.mem) +} + +/// What a template leaves alone in memory: the context register keeps its +/// value, the set of mapped addresses is the same, and every byte outside the +/// exit area keeps its value. So the code (which lives outside the exit +/// area) and every region are as they were. +pub open spec fn preserved_mem(m: isa::State, m2: isa::State) -> bool { + m.r.len() == 31 && m2.r.len() == 31 && m2.r[abi::ctx_reg() as int] == m.r[abi::ctx_reg() as int] + && m2.mem.dom() == m.mem.dom() && (forall|a: int| + #[trigger] m.mem.dom().contains(a) && !in_exit_area(ctx_of(m), a) ==> m2.mem[a] + == m.mem[a]) +} + +/// [`preserved_mem`], and the link register and the stack pointer keep their +/// values too: the validator forbids writing them, and the exit sequence's +/// `ret` returns through the link register. +pub open spec fn preserved(m: isa::State, m2: isa::State) -> bool { + preserved_mem(m, m2) && m2.r[abi::link_reg() as int] == m.r[abi::link_reg() as int] && m2.sp + == m.sp +} + +// ============================================================================ +// Section: running code +// ============================================================================ + +/// Run the instructions of `code` one after the other from `s`, each by +/// [`isa::step`], stopping at a fault (`None`). `pc` advances by 4 per +/// instruction (and, for a branch, goes to its target; the straight-line +/// templates have none). +pub open spec fn run_seq(s: isa::State, code: Seq) -> Option + decreases code.len(), +{ + if code.len() == 0 { + Some(s) + } else { + match isa::step(s, code[0]) { + Some(s1) => run_seq(s1, code.skip(1)), + None => None, + } + } +} + +/// The exit sequence for `c`, as the validator recognizes it +/// (`clazel_codecheck::a64::spec::exit_unit_at`): `movz w0, #c`, `str x0, +/// [x28, #256]`, `ret`. It is LIR's `exit` with no operands (a function that +/// falls off its end exits with code `c`). +pub open spec fn exit_seq(c: u16) -> Seq { + seq![ + isa::Instr::MoveWide { + sf: isa::Width::W32, + opcode: isa::MoveWideOp::Z, + d: x0(), + imm16: c, + hw: 0, + }, + isa::Instr::LoadStoreImm { + sf: isa::Width::W64, + load: false, + t: x0(), + n: abi::ctx_reg(), + imm12: (abi::exit_code_off() / 8) as u16, + }, + isa::Instr::Ret, + ] +} + +/// The length in bytes of the canonical encodings of `code`: 4 per +/// instruction. +pub open spec fn code_len(code: Seq) -> nat { + 4 * code.len() +} + +} // verus! diff --git a/crates/clazel-jit/src/lib.rs b/crates/clazel-jit/src/lib.rs index 26539075..4b08da42 100644 --- a/crates/clazel-jit/src/lib.rs +++ b/crates/clazel-jit/src/lib.rs @@ -73,6 +73,7 @@ //! Tier: see `[package.metadata.clazel]` in `Cargo.toml` and //! `docs/VERIFICATION.md`. +pub mod a64; pub mod agree; pub mod alu; pub mod api; From 45b3f9dd6e76cebd18a30c28a9118e8cf4e571e7 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 17:01:30 +0000 Subject: [PATCH 029/195] Phase 7.12: the WebIDL parser and `cargo xtask bindings` (generated interface model) xtask/src/bindings/ holds our own WebIDL parser (lexer and recursive-descent parser following the grammar of WebIDL section 2), a resolver that merges partial interfaces, dictionaries, namespaces and `includes`, and an emitter. `cargo xtask bindings` writes the resolved model as plain data into crates/clazel-webidl/src/generated/ (types in src/model.rs); `cargo xtask check` and `verify` fail if it is stale or a vendored file does not parse. No JS-engine glue yet (it needs clazel-js's embedding API, item 7.8). Tier stays 0. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-webidl/Cargo.toml | 9 +- crates/clazel-webidl/README.md | 12 +- .../clazel-webidl/src/generated/callbacks.rs | 38 + .../src/generated/dictionaries.rs | 749 +++ crates/clazel-webidl/src/generated/enums.rs | 73 + .../clazel-webidl/src/generated/interfaces.rs | 5982 +++++++++++++++++ crates/clazel-webidl/src/generated/mod.rs | 87 + .../clazel-webidl/src/generated/namespaces.rs | 37 + .../clazel-webidl/src/generated/typedefs.rs | 50 + crates/clazel-webidl/src/lib.rs | 22 +- crates/clazel-webidl/src/model.rs | 454 ++ crates/clazel-webidl/tests/model.rs | 471 ++ xtask/src/bindings/emit.rs | 526 ++ xtask/src/bindings/lexer.rs | 285 + xtask/src/bindings/mod.rs | 158 + xtask/src/bindings/model.rs | 358 + xtask/src/bindings/parser.rs | 1489 ++++ xtask/src/bindings/resolve.rs | 686 ++ xtask/src/main.rs | 33 +- 19 files changed, 11507 insertions(+), 12 deletions(-) create mode 100644 crates/clazel-webidl/src/generated/callbacks.rs create mode 100644 crates/clazel-webidl/src/generated/dictionaries.rs create mode 100644 crates/clazel-webidl/src/generated/enums.rs create mode 100644 crates/clazel-webidl/src/generated/interfaces.rs create mode 100644 crates/clazel-webidl/src/generated/mod.rs create mode 100644 crates/clazel-webidl/src/generated/namespaces.rs create mode 100644 crates/clazel-webidl/src/generated/typedefs.rs create mode 100644 crates/clazel-webidl/src/model.rs create mode 100644 crates/clazel-webidl/tests/model.rs create mode 100644 xtask/src/bindings/emit.rs create mode 100644 xtask/src/bindings/lexer.rs create mode 100644 xtask/src/bindings/mod.rs create mode 100644 xtask/src/bindings/model.rs create mode 100644 xtask/src/bindings/parser.rs create mode 100644 xtask/src/bindings/resolve.rs diff --git a/crates/clazel-webidl/Cargo.toml b/crates/clazel-webidl/Cargo.toml index 92145035..827f0ad8 100644 --- a/crates/clazel-webidl/Cargo.toml +++ b/crates/clazel-webidl/Cargo.toml @@ -4,14 +4,13 @@ version = "0.0.0" edition.workspace = true license.workspace = true publish.workspace = true -description = "WebIDL bindings: generated bindings, WebIDL conversions and DOMException (phase-7.md items 7.12 and 7.13). Empty until then; it holds the vendored IDL." +description = "WebIDL bindings: generated bindings, WebIDL conversions and DOMException (phase-7.md items 7.12 and 7.13). Today it holds the vendored IDL and the generated interface model (data only)." -# No dependencies yet: phase-7.md item 7.1 only vendors this crate's test -# data and inputs. The implementation arrives with the items named in -# src/lib.rs. +# No dependencies: the generated model is plain data (src/model.rs). The +# engine glue arrives with the items named in src/lib.rs. # Verification tier (docs/VERIFICATION.md). `tier` is what is proven about -# the shipped code today (nothing: the crate is empty); `target-tier` is what +# the shipped code today (nothing: it is data and tests); `target-tier` is what # phase-7.md's "Crates" table sets. [package.metadata.clazel] tier = 0 diff --git a/crates/clazel-webidl/README.md b/crates/clazel-webidl/README.md index e32422cb..e6492b2a 100644 --- a/crates/clazel-webidl/README.md +++ b/crates/clazel-webidl/README.md @@ -4,5 +4,13 @@ Part of [Clazel](../../README.md). The generated WebIDL bindings, the WebIDL type conversions and `DOMException` for the JavaScript engine ([phase-7.md](../../docs/phases/phase-7.md) items 7.12 and 7.13). -Nothing is implemented yet (tier 0, target tier 0). Item 7.1 vendored the IDL -that the bindings generator reads: see `tests/data/webref-idl/SOURCE.md`. +Tier 0, target tier 0. Item 7.1 vendored the IDL that the bindings generator +reads: see `tests/data/webref-idl/SOURCE.md`. + +Item 7.12's first slice is in: `cargo xtask bindings` parses that IDL with our +own parser (`xtask/src/bindings/`, following the grammar of WebIDL §2), merges +partial interfaces, mixins and `includes`, and writes the resolved model as +plain data into `src/generated/` (the types are `src/model.rs`). `cargo xtask +check` fails if the committed files are stale. Not done yet: the JS-engine +glue (conversions, overload resolution, wrappers, `DOMException`), which needs +`clazel-js`'s embedding API (item 7.8) and is generated from this model. diff --git a/crates/clazel-webidl/src/generated/callbacks.rs b/crates/clazel-webidl/src/generated/callbacks.rs new file mode 100644 index 00000000..bc9df8c7 --- /dev/null +++ b/crates/clazel-webidl/src/generated/callbacks.rs @@ -0,0 +1,38 @@ +// @generated by `cargo xtask bindings` (xtask/src/bindings/) from +// crates/clazel-webidl/tests/data/webref-idl/ (the webref commit and the +// license are in SOURCE.md there). Do not edit: `cargo xtask check` fails if +// this differs from what the generator produces. +// +// What the generator derives (xtask/src/bindings/resolve.rs has the rules): +// - Every .idl file of that directory is parsed with our own parser, which +// follows the grammar of WebIDL §2; the definitions of all files are +// merged into one model. +// - Partial interfaces, dictionaries and namespaces are appended to their +// target, in file order (files sorted by name), then source order. +// - `A includes M;` appends M's members (and its partials') to A, each +// marked with the mixin's name. +// - `Exposed` and `SecureContext` written on a partial interface or on a +// mixin are copied onto the members it adds, unless a member has its own. +// - Definitions are sorted by name. A mixin has no table of its own: its +// members are in its includers. +// - A name that no vendored file defines is accepted only if it is in +// xtask/src/bindings/resolve.rs's EXTERNAL list; those are in EXTERNAL +// below, with no definition. + +//! Callback function types, sorted by name. + +use crate::model::*; + +/// Callback function types, sorted by name. +pub static CALLBACKS: &[Callback] = &[ + Callback { name: "BlobCallback", ext_attrs: &[], ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "blob", ty: TypeRef { ty: Type::Named("Blob"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }] }, + Callback { name: "CustomElementConstructor", ext_attrs: &[], ret: TypeRef { ty: Type::Named("HTMLElement"), nullable: false, ext_attrs: &[] }, args: &[] }, + Callback { name: "EventHandlerNonNull", ext_attrs: &[ExtAttr { name: "LegacyTreatNonObjectAsNull", value: ExtValue::None }], ret: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "event", ty: TypeRef { ty: Type::Named("Event"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }] }, + Callback { name: "FrameRequestCallback", ext_attrs: &[], ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "time", ty: TypeRef { ty: Type::Named("DOMHighResTimeStamp"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }] }, + Callback { name: "FunctionStringCallback", ext_attrs: &[], ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }] }, + Callback { name: "MutationCallback", ext_attrs: &[], ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "mutations", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("MutationRecord"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "observer", ty: TypeRef { ty: Type::Named("MutationObserver"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }] }, + Callback { name: "NavigationInterceptHandler", ext_attrs: &[], ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[] }, + Callback { name: "NavigationPrecommitHandler", ext_attrs: &[], ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "controller", ty: TypeRef { ty: Type::Named("NavigationPrecommitController"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }] }, + Callback { name: "OnBeforeUnloadEventHandlerNonNull", ext_attrs: &[ExtAttr { name: "LegacyTreatNonObjectAsNull", value: ExtValue::None }], ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "event", ty: TypeRef { ty: Type::Named("Event"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }] }, + Callback { name: "OnErrorEventHandlerNonNull", ext_attrs: &[ExtAttr { name: "LegacyTreatNonObjectAsNull", value: ExtValue::None }], ret: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "event", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Event"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "source", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "lineno", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "colno", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "error", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }] }, +]; diff --git a/crates/clazel-webidl/src/generated/dictionaries.rs b/crates/clazel-webidl/src/generated/dictionaries.rs new file mode 100644 index 00000000..68b3951e --- /dev/null +++ b/crates/clazel-webidl/src/generated/dictionaries.rs @@ -0,0 +1,749 @@ +// @generated by `cargo xtask bindings` (xtask/src/bindings/) from +// crates/clazel-webidl/tests/data/webref-idl/ (the webref commit and the +// license are in SOURCE.md there). Do not edit: `cargo xtask check` fails if +// this differs from what the generator produces. +// +// What the generator derives (xtask/src/bindings/resolve.rs has the rules): +// - Every .idl file of that directory is parsed with our own parser, which +// follows the grammar of WebIDL §2; the definitions of all files are +// merged into one model. +// - Partial interfaces, dictionaries and namespaces are appended to their +// target, in file order (files sorted by name), then source order. +// - `A includes M;` appends M's members (and its partials') to A, each +// marked with the mixin's name. +// - `Exposed` and `SecureContext` written on a partial interface or on a +// mixin are copied onto the members it adds, unless a member has its own. +// - Definitions are sorted by name. A mixin has no table of its own: its +// members are in its includers. +// - A name that no vendored file defines is accepted only if it is in +// xtask/src/bindings/resolve.rs's EXTERNAL list; those are in EXTERNAL +// below, with no definition. + +//! Dictionaries, sorted by name. + +use crate::model::*; + +/// Dictionaries, sorted by name. +pub static DICTIONARIES: &[Dictionary] = &[ + Dictionary { + name: "AddEventListenerOptions", + parent: Some("EventListenerOptions"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "passive", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "once", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "signal", ty: TypeRef { ty: Type::Named("AbortSignal"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "AssignedNodesOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "flatten", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "CSSStyleSheetInit", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "baseURL", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "media", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("MediaList"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "CanvasRenderingContext2DSettings", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "alpha", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(true)), ext_attrs: &[] }, + DictionaryMember { name: "desynchronized", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "colorSpace", ty: TypeRef { ty: Type::Named("PredefinedColorSpace"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("srgb")), ext_attrs: &[] }, + DictionaryMember { name: "toneMapping", ty: TypeRef { ty: Type::Named("CanvasToneMapping"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }, + DictionaryMember { name: "colorType", ty: TypeRef { ty: Type::Named("CanvasColorType"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("unorm8")), ext_attrs: &[] }, + DictionaryMember { name: "willReadFrequently", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "CanvasToneMapping", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "mode", ty: TypeRef { ty: Type::Named("CanvasToneMappingMode"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("standard")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "CloseWatcherOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "signal", ty: TypeRef { ty: Type::Named("AbortSignal"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "CommandEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "source", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "command", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "CompositionEventInit", + parent: Some("UIEventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "CustomEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "detail", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "DeferredRequestInit", + parent: Some("RequestInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "activateAfter", ty: TypeRef { ty: Type::Named("DOMHighResTimeStamp"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "DragEventInit", + parent: Some("MouseEventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "dataTransfer", ty: TypeRef { ty: Type::Named("DataTransfer"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ElementCreationOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "customElementRegistry", ty: TypeRef { ty: Type::Named("CustomElementRegistry"), nullable: true, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "is", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ElementDefinitionOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "extends", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ErrorEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "message", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "filename", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "lineno", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, + DictionaryMember { name: "colno", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, + DictionaryMember { name: "error", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "EventInit", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "bubbles", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "cancelable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "composed", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "EventListenerOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "capture", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "EventModifierInit", + parent: Some("UIEventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "ctrlKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "shiftKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "altKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "metaKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "modifierAltGraph", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "modifierCapsLock", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "modifierFn", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "modifierFnLock", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "modifierHyper", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "modifierNumLock", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "modifierScrollLock", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "modifierSuper", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "modifierSymbol", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "modifierSymbolLock", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "EventSourceInit", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "withCredentials", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "FocusEventInit", + parent: Some("UIEventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "relatedTarget", ty: TypeRef { ty: Type::Named("EventTarget"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "FocusOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "preventScroll", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "focusVisible", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "FormDataEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "formData", ty: TypeRef { ty: Type::Named("FormData"), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "GetHTMLOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "serializableShadowRoots", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "shadowRoots", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("ShadowRoot"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::EmptySequence), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "GetRootNodeOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "composed", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "HashChangeEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "oldURL", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "newURL", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ImageBitmapOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "imageOrientation", ty: TypeRef { ty: Type::Named("ImageOrientation"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("from-image")), ext_attrs: &[] }, + DictionaryMember { name: "premultiplyAlpha", ty: TypeRef { ty: Type::Named("PremultiplyAlpha"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("default")), ext_attrs: &[] }, + DictionaryMember { name: "colorSpaceConversion", ty: TypeRef { ty: Type::Named("ColorSpaceConversion"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("default")), ext_attrs: &[] }, + DictionaryMember { name: "resizeWidth", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, + DictionaryMember { name: "resizeHeight", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, + DictionaryMember { name: "resizeQuality", ty: TypeRef { ty: Type::Named("ResizeQuality"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("low")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ImageBitmapRenderingContextSettings", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "alpha", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(true)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ImageDataSettings", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "colorSpace", ty: TypeRef { ty: Type::Named("PredefinedColorSpace"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "pixelFormat", ty: TypeRef { ty: Type::Named("ImageDataPixelFormat"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("rgba-unorm8")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ImageEncodeOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("image/png")), ext_attrs: &[] }, + DictionaryMember { name: "quality", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ImportNodeOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "customElementRegistry", ty: TypeRef { ty: Type::Named("CustomElementRegistry"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "selfOnly", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "InputEventInit", + parent: Some("UIEventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "isComposing", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "inputType", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "KeyboardEventInit", + parent: Some("EventModifierInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "code", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "location", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, + DictionaryMember { name: "repeat", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "isComposing", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "charCode", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, + DictionaryMember { name: "keyCode", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "MessageEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "data", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "origin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "lastEventId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "source", ty: TypeRef { ty: Type::Named("MessageEventSource"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "ports", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("MessagePort"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::EmptySequence), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "MutationObserverInit", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "childList", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "attributes", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "characterData", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "subtree", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "attributeOldValue", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "characterDataOldValue", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "attributeFilter", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "NavigateEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "navigationType", ty: TypeRef { ty: Type::Named("NavigationType"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("push")), ext_attrs: &[] }, + DictionaryMember { name: "destination", ty: TypeRef { ty: Type::Named("NavigationDestination"), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + DictionaryMember { name: "canIntercept", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "userInitiated", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "hashChange", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "signal", ty: TypeRef { ty: Type::Named("AbortSignal"), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + DictionaryMember { name: "formData", ty: TypeRef { ty: Type::Named("FormData"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "downloadRequest", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "info", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "hasUAVisualTransition", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "sourceElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "NavigationCurrentEntryChangeEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "navigationType", ty: TypeRef { ty: Type::Named("NavigationType"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "from", ty: TypeRef { ty: Type::Named("NavigationHistoryEntry"), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "NavigationInterceptOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "precommitHandler", ty: TypeRef { ty: Type::Named("NavigationPrecommitHandler"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "handler", ty: TypeRef { ty: Type::Named("NavigationInterceptHandler"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "focusReset", ty: TypeRef { ty: Type::Named("NavigationFocusReset"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "scroll", ty: TypeRef { ty: Type::Named("NavigationScrollBehavior"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "NavigationNavigateOptions", + parent: Some("NavigationOptions"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "state", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "history", ty: TypeRef { ty: Type::Named("NavigationHistoryBehavior"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("auto")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "NavigationOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "info", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "NavigationReloadOptions", + parent: Some("NavigationOptions"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "state", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "NavigationResult", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "committed", ty: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("NavigationHistoryEntry"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "finished", ty: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("NavigationHistoryEntry"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "NavigationUpdateCurrentEntryOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "state", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "PageRevealEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "viewTransition", ty: TypeRef { ty: Type::Named("ViewTransition"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "PageSwapEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "activation", ty: TypeRef { ty: Type::Named("NavigationActivation"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "viewTransition", ty: TypeRef { ty: Type::Named("ViewTransition"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "PageTransitionEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "persisted", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ParseHTMLUnsafeOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "sanitizer", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Sanitizer"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerConfig"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerPresets"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "PopStateEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "state", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "hasUAVisualTransition", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ProgressEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "lengthComputable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "loaded", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, + DictionaryMember { name: "total", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "PromiseRejectionEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "promise", ty: TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + DictionaryMember { name: "reason", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "RequestInit", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "method", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "headers", ty: TypeRef { ty: Type::Named("HeadersInit"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "body", ty: TypeRef { ty: Type::Named("BodyInit"), nullable: true, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "referrer", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "referrerPolicy", ty: TypeRef { ty: Type::Named("ReferrerPolicy"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "mode", ty: TypeRef { ty: Type::Named("RequestMode"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "credentials", ty: TypeRef { ty: Type::Named("RequestCredentials"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "cache", ty: TypeRef { ty: Type::Named("RequestCache"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "redirect", ty: TypeRef { ty: Type::Named("RequestRedirect"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "integrity", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "keepalive", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "signal", ty: TypeRef { ty: Type::Named("AbortSignal"), nullable: true, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "duplex", ty: TypeRef { ty: Type::Named("RequestDuplex"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "priority", ty: TypeRef { ty: Type::Named("RequestPriority"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "window", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ResponseInit", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "status", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Integer(200)), ext_attrs: &[] }, + DictionaryMember { name: "statusText", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "headers", ty: TypeRef { ty: Type::Named("HeadersInit"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "SanitizerAttributeNamespace", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + DictionaryMember { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "SanitizerConfig", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "elements", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("SanitizerElementWithAttributes"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "removeElements", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("SanitizerElement"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "replaceWithChildrenElements", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("SanitizerElement"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "processingInstructions", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("SanitizerPI"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "removeProcessingInstructions", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("SanitizerPI"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "attributes", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("SanitizerAttribute"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "removeAttributes", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("SanitizerAttribute"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "comments", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "dataAttributes", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "javascriptURLs", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "SanitizerElementNamespace", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + DictionaryMember { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Str("http://www.w3.org/1999/xhtml")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "SanitizerElementNamespaceWithAttributes", + parent: Some("SanitizerElementNamespace"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "attributes", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("SanitizerAttribute"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "removeAttributes", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("SanitizerAttribute"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "SanitizerProcessingInstruction", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "target", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "SetHTMLOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "sanitizer", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Sanitizer"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerConfig"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerPresets"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("default")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "SetHTMLUnsafeOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "sanitizer", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Sanitizer"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerConfig"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerPresets"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "runScripts", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ShadowRootInit", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "mode", ty: TypeRef { ty: Type::Named("ShadowRootMode"), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + DictionaryMember { name: "delegatesFocus", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "serializable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "slotAssignment", ty: TypeRef { ty: Type::Named("SlotAssignmentMode"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("named")), ext_attrs: &[] }, + DictionaryMember { name: "clonable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "customElementRegistry", ty: TypeRef { ty: Type::Named("CustomElementRegistry"), nullable: true, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "SharedWorkerOptions", + parent: Some("WorkerOptions"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "extendedLifetime", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ShowPopoverOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "source", ty: TypeRef { ty: Type::Named("HTMLElement"), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "StaticRangeInit", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "startContainer", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + DictionaryMember { name: "startOffset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + DictionaryMember { name: "endContainer", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + DictionaryMember { name: "endOffset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, required: true, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "StorageEstimate", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "usage", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLongLong), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + DictionaryMember { name: "quota", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLongLong), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "StorageEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "oldValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "newValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "storageArea", ty: TypeRef { ty: Type::Named("Storage"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "StructuredSerializeOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "transfer", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::EmptySequence), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "SubmitEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "submitter", ty: TypeRef { ty: Type::Named("HTMLElement"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ToggleEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "oldState", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "newState", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "source", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "TogglePopoverOptions", + parent: Some("ShowPopoverOptions"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "force", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: None, ext_attrs: &[] }, + ], + }, + Dictionary { + name: "TrackEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "track", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("VideoTrack"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("AudioTrack"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TextTrack"), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "UIEventInit", + parent: Some("EventInit"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "view", ty: TypeRef { ty: Type::Named("Window"), nullable: true, ext_attrs: &[] }, required: false, default: Some(Value::Null), ext_attrs: &[] }, + DictionaryMember { name: "detail", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, + DictionaryMember { name: "which", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "ValidityStateFlags", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "valueMissing", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "typeMismatch", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "patternMismatch", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "tooLong", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "tooShort", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "rangeUnderflow", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "rangeOverflow", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "stepMismatch", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "badInput", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + DictionaryMember { name: "customError", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "WindowPostMessageOptions", + parent: Some("StructuredSerializeOptions"), + ext_attrs: &[], + members: &[ + DictionaryMember { name: "targetOrigin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("/")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "WorkerOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("")), ext_attrs: &[] }, + DictionaryMember { name: "type", ty: TypeRef { ty: Type::Named("WorkerType"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("classic")), ext_attrs: &[] }, + DictionaryMember { name: "credentials", ty: TypeRef { ty: Type::Named("RequestCredentials"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("same-origin")), ext_attrs: &[] }, + ], + }, + Dictionary { + name: "WorkletOptions", + parent: None, + ext_attrs: &[], + members: &[ + DictionaryMember { name: "credentials", ty: TypeRef { ty: Type::Named("RequestCredentials"), nullable: false, ext_attrs: &[] }, required: false, default: Some(Value::Str("same-origin")), ext_attrs: &[] }, + ], + }, +]; diff --git a/crates/clazel-webidl/src/generated/enums.rs b/crates/clazel-webidl/src/generated/enums.rs new file mode 100644 index 00000000..e4a8806e --- /dev/null +++ b/crates/clazel-webidl/src/generated/enums.rs @@ -0,0 +1,73 @@ +// @generated by `cargo xtask bindings` (xtask/src/bindings/) from +// crates/clazel-webidl/tests/data/webref-idl/ (the webref commit and the +// license are in SOURCE.md there). Do not edit: `cargo xtask check` fails if +// this differs from what the generator produces. +// +// What the generator derives (xtask/src/bindings/resolve.rs has the rules): +// - Every .idl file of that directory is parsed with our own parser, which +// follows the grammar of WebIDL §2; the definitions of all files are +// merged into one model. +// - Partial interfaces, dictionaries and namespaces are appended to their +// target, in file order (files sorted by name), then source order. +// - `A includes M;` appends M's members (and its partials') to A, each +// marked with the mixin's name. +// - `Exposed` and `SecureContext` written on a partial interface or on a +// mixin are copied onto the members it adds, unless a member has its own. +// - Definitions are sorted by name. A mixin has no table of its own: its +// members are in its includers. +// - A name that no vendored file defines is accepted only if it is in +// xtask/src/bindings/resolve.rs's EXTERNAL list; those are in EXTERNAL +// below, with no definition. + +//! Enums, sorted by name. + +use crate::model::*; + +/// Enums, sorted by name. +pub static ENUMS: &[Enumeration] = &[ + Enumeration { name: "CanPlayTypeResult", ext_attrs: &[], values: &["", "maybe", "probably"] }, + Enumeration { name: "CanvasColorType", ext_attrs: &[], values: &["unorm8", "float16"] }, + Enumeration { name: "CanvasDirection", ext_attrs: &[], values: &["ltr", "rtl", "inherit"] }, + Enumeration { name: "CanvasFillRule", ext_attrs: &[], values: &["nonzero", "evenodd"] }, + Enumeration { name: "CanvasFontKerning", ext_attrs: &[], values: &["auto", "normal", "none"] }, + Enumeration { name: "CanvasFontStretch", ext_attrs: &[], values: &["ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"] }, + Enumeration { name: "CanvasFontVariantCaps", ext_attrs: &[], values: &["normal", "small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase", "titling-caps"] }, + Enumeration { name: "CanvasLineCap", ext_attrs: &[], values: &["butt", "round", "square"] }, + Enumeration { name: "CanvasLineJoin", ext_attrs: &[], values: &["round", "bevel", "miter"] }, + Enumeration { name: "CanvasTextAlign", ext_attrs: &[], values: &["start", "end", "left", "right", "center"] }, + Enumeration { name: "CanvasTextBaseline", ext_attrs: &[], values: &["top", "hanging", "middle", "alphabetic", "ideographic", "bottom"] }, + Enumeration { name: "CanvasTextRendering", ext_attrs: &[], values: &["auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision"] }, + Enumeration { name: "CanvasToneMappingMode", ext_attrs: &[], values: &["standard", "extended"] }, + Enumeration { name: "ColorSpaceConversion", ext_attrs: &[], values: &["none", "default"] }, + Enumeration { name: "DOMParserSupportedType", ext_attrs: &[], values: &["text/html", "text/xml", "application/xml", "application/xhtml+xml", "image/svg+xml"] }, + Enumeration { name: "DocumentReadyState", ext_attrs: &[], values: &["loading", "interactive", "complete"] }, + Enumeration { name: "DocumentVisibilityState", ext_attrs: &[], values: &["visible", "hidden"] }, + Enumeration { name: "ImageDataPixelFormat", ext_attrs: &[], values: &["rgba-unorm8", "rgba-float16"] }, + Enumeration { name: "ImageOrientation", ext_attrs: &[], values: &["from-image", "flipY"] }, + Enumeration { name: "ImageSmoothingQuality", ext_attrs: &[], values: &["low", "medium", "high"] }, + Enumeration { name: "NavigationFocusReset", ext_attrs: &[], values: &["after-transition", "manual"] }, + Enumeration { name: "NavigationHistoryBehavior", ext_attrs: &[], values: &["auto", "push", "replace"] }, + Enumeration { name: "NavigationScrollBehavior", ext_attrs: &[], values: &["after-transition", "manual"] }, + Enumeration { name: "NavigationType", ext_attrs: &[], values: &["push", "replace", "reload", "traverse"] }, + Enumeration { name: "OffscreenRenderingContextId", ext_attrs: &[], values: &["2d", "bitmaprenderer", "webgl", "webgl2", "webgpu"] }, + Enumeration { name: "PredefinedColorSpace", ext_attrs: &[], values: &["srgb", "srgb-linear", "display-p3", "display-p3-linear"] }, + Enumeration { name: "PremultiplyAlpha", ext_attrs: &[], values: &["none", "premultiply", "default"] }, + Enumeration { name: "RequestCache", ext_attrs: &[], values: &["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"] }, + Enumeration { name: "RequestCredentials", ext_attrs: &[], values: &["omit", "same-origin", "include"] }, + Enumeration { name: "RequestDestination", ext_attrs: &[], values: &["", "audio", "audioworklet", "document", "embed", "font", "frame", "iframe", "image", "json", "manifest", "object", "paintworklet", "report", "script", "sharedworker", "style", "text", "track", "video", "worker", "xslt"] }, + Enumeration { name: "RequestDuplex", ext_attrs: &[], values: &["half"] }, + Enumeration { name: "RequestMode", ext_attrs: &[], values: &["navigate", "same-origin", "no-cors", "cors"] }, + Enumeration { name: "RequestPriority", ext_attrs: &[], values: &["high", "low", "auto"] }, + Enumeration { name: "RequestRedirect", ext_attrs: &[], values: &["follow", "error", "manual"] }, + Enumeration { name: "ResizeQuality", ext_attrs: &[], values: &["pixelated", "low", "medium", "high"] }, + Enumeration { name: "ResponseType", ext_attrs: &[], values: &["basic", "cors", "default", "error", "opaque", "opaqueredirect"] }, + Enumeration { name: "SanitizerPresets", ext_attrs: &[], values: &["default"] }, + Enumeration { name: "ScrollRestoration", ext_attrs: &[], values: &["auto", "manual"] }, + Enumeration { name: "SelectionMode", ext_attrs: &[], values: &["select", "start", "end", "preserve"] }, + Enumeration { name: "ShadowRootMode", ext_attrs: &[], values: &["open", "closed"] }, + Enumeration { name: "SlotAssignmentMode", ext_attrs: &[], values: &["manual", "named"] }, + Enumeration { name: "TextTrackKind", ext_attrs: &[], values: &["subtitles", "captions", "descriptions", "chapters", "metadata"] }, + Enumeration { name: "TextTrackMode", ext_attrs: &[], values: &["disabled", "hidden", "showing"] }, + Enumeration { name: "WorkerType", ext_attrs: &[], values: &["classic", "module"] }, + Enumeration { name: "XMLHttpRequestResponseType", ext_attrs: &[], values: &["", "arraybuffer", "blob", "document", "json", "text"] }, +]; diff --git a/crates/clazel-webidl/src/generated/interfaces.rs b/crates/clazel-webidl/src/generated/interfaces.rs new file mode 100644 index 00000000..dc5fc39c --- /dev/null +++ b/crates/clazel-webidl/src/generated/interfaces.rs @@ -0,0 +1,5982 @@ +// @generated by `cargo xtask bindings` (xtask/src/bindings/) from +// crates/clazel-webidl/tests/data/webref-idl/ (the webref commit and the +// license are in SOURCE.md there). Do not edit: `cargo xtask check` fails if +// this differs from what the generator produces. +// +// What the generator derives (xtask/src/bindings/resolve.rs has the rules): +// - Every .idl file of that directory is parsed with our own parser, which +// follows the grammar of WebIDL §2; the definitions of all files are +// merged into one model. +// - Partial interfaces, dictionaries and namespaces are appended to their +// target, in file order (files sorted by name), then source order. +// - `A includes M;` appends M's members (and its partials') to A, each +// marked with the mixin's name. +// - `Exposed` and `SecureContext` written on a partial interface or on a +// mixin are copied onto the members it adds, unless a member has its own. +// - Definitions are sorted by name. A mixin has no table of its own: its +// members are in its includers. +// - A name that no vendored file defines is accepted only if it is in +// xtask/src/bindings/resolve.rs's EXTERNAL list; those are in EXTERNAL +// below, with no definition. + +//! Interfaces and callback interfaces, sorted by name. + +use crate::model::*; + +/// Interfaces and callback interfaces, sorted by name. +pub static INTERFACES: &[Interface] = &[ + Interface { + name: "AbortController", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Wildcard }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "signal", ty: TypeRef { ty: Type::Named("AbortSignal"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("abort"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "reason", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "AbortSignal", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Wildcard }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "aborted", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "reason", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onabort", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("abort"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Named("AbortSignal"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "reason", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("timeout"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Named("AbortSignal"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "milliseconds", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLongLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }], mixin: None, ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("any"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Named("AbortSignal"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "signals", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("AbortSignal"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("throwIfAborted"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "AbstractRange", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "startOffset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "endOffset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "collapsed", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Attr", + parent: Some("Node"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "namespaceURI", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "prefix", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "ownerElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "specified", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "AudioTrack", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "kind", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "label", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "language", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "enabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "AudioTrackList", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onaddtrack", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onremovetrack", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("AudioTrack"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getTrackById"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("AudioTrack"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "BarProp", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "visible", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "BeforeUnloadEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "returnValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "BroadcastChannel", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onmessage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onmessageerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("postMessage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("close"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CDATASection", + parent: Some("Text"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "CSSGroupingRule", + parent: Some("CSSRule"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "cssRules", ty: TypeRef { ty: Type::Named("CSSRuleList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("insertRule"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "rule", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteRule"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CSSImportRule", + parent: Some("CSSRule"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "href", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "media", ty: TypeRef { ty: Type::Named("MediaList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("mediaText") }] }, + Attribute { name: "styleSheet", ty: TypeRef { ty: Type::Named("CSSStyleSheet"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "layerName", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "supportsText", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "CSSMarginRule", + parent: Some("CSSRule"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "style", ty: TypeRef { ty: Type::Named("CSSMarginDescriptors"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("cssText") }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "CSSNamespaceRule", + parent: Some("CSSRule"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "namespaceURI", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "prefix", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "CSSPageDescriptors", + parent: Some("CSSStyleDeclaration"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "margin", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "marginTop", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "marginRight", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "marginBottom", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "marginLeft", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "margin-top", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "margin-right", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "margin-bottom", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "margin-left", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "size", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "pageOrientation", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "page-orientation", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "marks", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "bleed", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "CSSPageRule", + parent: Some("CSSGroupingRule"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "selectorText", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "style", ty: TypeRef { ty: Type::Named("CSSPageDescriptors"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("cssText") }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "CSSRule", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[ + Constant { name: "STYLE_RULE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "CHARSET_RULE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "IMPORT_RULE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + Constant { name: "MEDIA_RULE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(4), mixin: None, ext_attrs: &[] }, + Constant { name: "FONT_FACE_RULE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(5), mixin: None, ext_attrs: &[] }, + Constant { name: "PAGE_RULE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(6), mixin: None, ext_attrs: &[] }, + Constant { name: "MARGIN_RULE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(9), mixin: None, ext_attrs: &[] }, + Constant { name: "NAMESPACE_RULE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(10), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "cssText", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "parentRule", ty: TypeRef { ty: Type::Named("CSSRule"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "parentStyleSheet", ty: TypeRef { ty: Type::Named("CSSStyleSheet"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "CSSRuleList", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("CSSRule"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CSSStyleDeclaration", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "cssText", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "parentRule", ty: TypeRef { ty: Type::Named("CSSRule"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getPropertyValue"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "property", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getPropertyPriority"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "property", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setProperty"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "property", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, Argument { name: "priority", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("removeProperty"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "property", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CSSStyleProperties", + parent: Some("CSSStyleDeclaration"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "cssFloat", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "CSSStyleRule", + parent: Some("CSSGroupingRule"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "selectorText", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "style", ty: TypeRef { ty: Type::Named("CSSStyleProperties"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("cssText") }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "CSSStyleSheet", + parent: Some("StyleSheet"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("CSSStyleSheetInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "ownerRule", ty: TypeRef { ty: Type::Named("CSSRule"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "cssRules", ty: TypeRef { ty: Type::Named("CSSRuleList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "rules", ty: TypeRef { ty: Type::Named("CSSRuleList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("insertRule"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "rule", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteRule"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("replace"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("CSSStyleSheet"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "text", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("replaceSync"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "text", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("addRule"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "selector", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("undefined")), ext_attrs: &[] }, Argument { name: "style", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("undefined")), ext_attrs: &[] }, Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("removeRule"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CanvasGradient", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("addColorStop"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "offset", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "color", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CanvasPattern", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("setTransform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "transform", ty: TypeRef { ty: Type::Named("DOMMatrix2DInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CanvasRenderingContext2D", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["CanvasSettings", "CanvasState", "CanvasTransform", "CanvasCompositing", "CanvasImageSmoothing", "CanvasFillStrokeStyles", "CanvasShadowStyles", "CanvasFilters", "CanvasRect", "CanvasDrawPath", "CanvasUserInterface", "CanvasText", "CanvasDrawImage", "CanvasImageData", "CanvasPathDrawingStyles", "CanvasTextDrawingStyles", "CanvasPath"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "canvas", ty: TypeRef { ty: Type::Named("HTMLCanvasElement"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "globalAlpha", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasCompositing"), ext_attrs: &[] }, + Attribute { name: "globalCompositeOperation", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasCompositing"), ext_attrs: &[] }, + Attribute { name: "imageSmoothingEnabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasImageSmoothing"), ext_attrs: &[] }, + Attribute { name: "imageSmoothingQuality", ty: TypeRef { ty: Type::Named("ImageSmoothingQuality"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasImageSmoothing"), ext_attrs: &[] }, + Attribute { name: "strokeStyle", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("CanvasGradient"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("CanvasPattern"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Attribute { name: "fillStyle", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("CanvasGradient"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("CanvasPattern"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Attribute { name: "shadowOffsetX", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasShadowStyles"), ext_attrs: &[] }, + Attribute { name: "shadowOffsetY", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasShadowStyles"), ext_attrs: &[] }, + Attribute { name: "shadowBlur", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasShadowStyles"), ext_attrs: &[] }, + Attribute { name: "shadowColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasShadowStyles"), ext_attrs: &[] }, + Attribute { name: "filter", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasFilters"), ext_attrs: &[] }, + Attribute { name: "lineWidth", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "lineCap", ty: TypeRef { ty: Type::Named("CanvasLineCap"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "lineJoin", ty: TypeRef { ty: Type::Named("CanvasLineJoin"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "miterLimit", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "lineDashOffset", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "lang", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "font", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "textAlign", ty: TypeRef { ty: Type::Named("CanvasTextAlign"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "textBaseline", ty: TypeRef { ty: Type::Named("CanvasTextBaseline"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "direction", ty: TypeRef { ty: Type::Named("CanvasDirection"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "letterSpacing", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "fontKerning", ty: TypeRef { ty: Type::Named("CanvasFontKerning"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "fontStretch", ty: TypeRef { ty: Type::Named("CanvasFontStretch"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "fontVariantCaps", ty: TypeRef { ty: Type::Named("CanvasFontVariantCaps"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "textRendering", ty: TypeRef { ty: Type::Named("CanvasTextRendering"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "wordSpacing", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("getContextAttributes"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanvasRenderingContext2DSettings"), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasSettings"), ext_attrs: &[] }, + Operation { name: Some("save"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasState"), ext_attrs: &[] }, + Operation { name: Some("restore"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasState"), ext_attrs: &[] }, + Operation { name: Some("reset"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasState"), ext_attrs: &[] }, + Operation { name: Some("isContextLost"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasState"), ext_attrs: &[] }, + Operation { name: Some("scale"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("rotate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "angle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("translate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("transform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "a", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "b", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "c", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "d", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "e", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "f", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("getTransform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("DOMMatrix"), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasTransform"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("setTransform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "a", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "b", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "c", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "d", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "e", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "f", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("setTransform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "transform", ty: TypeRef { ty: Type::Named("DOMMatrix2DInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("resetTransform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("createLinearGradient"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanvasGradient"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x0", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y0", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x1", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y1", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Operation { name: Some("createRadialGradient"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanvasGradient"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x0", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y0", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "r0", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x1", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y1", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "r1", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Operation { name: Some("createConicGradient"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanvasGradient"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "startAngle", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Operation { name: Some("createPattern"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanvasPattern"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("CanvasImageSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "repetition", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }], mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Operation { name: Some("clearRect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasRect"), ext_attrs: &[] }, + Operation { name: Some("fillRect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasRect"), ext_attrs: &[] }, + Operation { name: Some("strokeRect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasRect"), ext_attrs: &[] }, + Operation { name: Some("beginPath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("fill"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("fill"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("stroke"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("stroke"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("clip"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("clip"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("isPointInPath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("isPointInPath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("isPointInStroke"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("isPointInStroke"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("drawFocusIfNeeded"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "element", ty: TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasUserInterface"), ext_attrs: &[] }, + Operation { name: Some("drawFocusIfNeeded"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "element", ty: TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasUserInterface"), ext_attrs: &[] }, + Operation { name: Some("fillText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "maxWidth", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasText"), ext_attrs: &[] }, + Operation { name: Some("strokeText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "maxWidth", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasText"), ext_attrs: &[] }, + Operation { name: Some("measureText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("TextMetrics"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasText"), ext_attrs: &[] }, + Operation { name: Some("drawImage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("CanvasImageSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawImage"), ext_attrs: &[] }, + Operation { name: Some("drawImage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("CanvasImageSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dw", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dh", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawImage"), ext_attrs: &[] }, + Operation { name: Some("drawImage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("CanvasImageSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sw", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sh", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dw", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dh", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawImage"), ext_attrs: &[] }, + Operation { name: Some("createImageData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "sw", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "sh", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "settings", ty: TypeRef { ty: Type::Named("ImageDataSettings"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("CanvasImageData"), ext_attrs: &[] }, + Operation { name: Some("createImageData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "imageData", ty: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasImageData"), ext_attrs: &[] }, + Operation { name: Some("getImageData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "sx", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "sy", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "sw", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "sh", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "settings", ty: TypeRef { ty: Type::Named("ImageDataSettings"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("CanvasImageData"), ext_attrs: &[] }, + Operation { name: Some("putImageData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "imageData", ty: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dx", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dy", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }], mixin: Some("CanvasImageData"), ext_attrs: &[] }, + Operation { name: Some("putImageData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "imageData", ty: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dx", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dy", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dirtyX", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dirtyY", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dirtyWidth", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dirtyHeight", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }], mixin: Some("CanvasImageData"), ext_attrs: &[] }, + Operation { name: Some("setLineDash"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "segments", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Operation { name: Some("getLineDash"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Operation { name: Some("closePath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("moveTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("lineTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("quadraticCurveTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "cpx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cpy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("bezierCurveTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "cp1x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cp1y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cp2x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cp2y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("arcTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x1", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y1", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x2", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y2", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radius", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("rect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("roundRect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radii", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("DOMPointInit"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("DOMPointInit"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("arc"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radius", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "startAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "endAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "counterclockwise", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("ellipse"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radiusX", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radiusY", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "rotation", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "startAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "endAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "counterclockwise", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CharacterData", + parent: Some("Node"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["NonDocumentTypeChildNode", "ChildNode"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "previousElementSibling", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[] }, + Attribute { name: "nextElementSibling", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("substringData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "offset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "count", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("appendData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("insertData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "offset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "offset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "count", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("replaceData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "offset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "count", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("beforeHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("afterHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("replaceWithHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("streamBeforeHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamAfterHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamReplaceWithHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("beforeHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("afterHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("replaceWithHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("streamBeforeHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamAfterHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamReplaceWithHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("before"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("after"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("replaceWith"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("remove"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CloseWatcher", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("CloseWatcherOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "oncancel", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onclose", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("requestClose"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("close"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("destroy"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CommandEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("CommandEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "source", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "command", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Comment", + parent: Some("CharacterData"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "CompositionEvent", + parent: Some("UIEvent"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("CompositionEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "data", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("initCompositionEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "typeArg", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "bubblesArg", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "cancelableArg", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "viewArg", ty: TypeRef { ty: Type::Named("WindowProxy"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "dataArg", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CustomElementRegistry", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("define"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "constructor", ty: TypeRef { ty: Type::Named("CustomElementConstructor"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("ElementDefinitionOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("get"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("CustomElementConstructor"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getName"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "constructor", ty: TypeRef { ty: Type::Named("CustomElementConstructor"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("whenDefined"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("CustomElementConstructor"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("upgrade"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "root", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("initialize"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "root", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CustomEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Wildcard }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("CustomEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "detail", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("initCustomEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "bubbles", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "cancelable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "detail", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "CustomStateSet", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: Some(Collection { is_map: false, readonly: false, key: None, value: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, ext_attrs: &[] }), + }, + Interface { + name: "DOMImplementation", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("createDocumentType"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("DocumentType"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "publicId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "systemId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createDocument"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("XMLDocument"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, Argument { name: "doctype", ty: TypeRef { ty: Type::Named("DocumentType"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createHTMLDocument"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Document"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "title", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("hasFeature"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "DOMParser", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("parseFromString"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Document"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "string", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "type", ty: TypeRef { ty: Type::Named("DOMParserSupportedType"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "DOMStringList", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("contains"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "string", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "DOMStringMap", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyOverrideBuiltIns", value: ExtValue::None }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: None, kind: OperationKind::Setter, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: None, kind: OperationKind::Deleter, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "DOMTokenList", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: true, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("contains"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "token", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("add"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "tokens", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("remove"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "tokens", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("toggle"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "token", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "force", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("replace"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "token", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "newToken", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("supports"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "token", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: Some(Iterable { is_async: false, key: None, value: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[], ext_attrs: &[] }), + collection: None, + }, + Interface { + name: "DataTransfer", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "dropEffect", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "effectAllowed", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "items", ty: TypeRef { ty: Type::Named("DataTransferItemList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "types", ty: TypeRef { ty: Type::FrozenArray(&TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "files", ty: TypeRef { ty: Type::Named("FileList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("setDragImage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "format", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "format", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("clearData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "format", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "DataTransferItem", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "kind", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("getAsString"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "callback", ty: TypeRef { ty: Type::Named("FunctionStringCallback"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAsFile"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("File"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "DataTransferItemList", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("DataTransferItem"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("add"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("DataTransferItem"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("add"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("DataTransferItem"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Named("File"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("remove"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("clear"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "DedicatedWorkerGlobalScope", + parent: Some("WorkerGlobalScope"), + callback: false, + ext_attrs: &[ExtAttr { name: "Global", value: ExtValue::IdentList(&["Worker", "DedicatedWorker"]) }, ExtAttr { name: "Exposed", value: ExtValue::Ident("DedicatedWorker") }], + includes: &["AnimationFrameProvider", "MessageEventTarget"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "onmessage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("MessageEventTarget"), ext_attrs: &[] }, + Attribute { name: "onmessageerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("MessageEventTarget"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("postMessage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "transfer", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("postMessage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("StructuredSerializeOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("close"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("requestAnimationFrame"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "callback", ty: TypeRef { ty: Type::Named("FrameRequestCallback"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("AnimationFrameProvider"), ext_attrs: &[] }, + Operation { name: Some("cancelAnimationFrame"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "handle", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("AnimationFrameProvider"), ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Document", + parent: Some("Node"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["NonElementParentNode", "DocumentOrShadowRoot", "ParentNode", "XPathEvaluatorBase", "GlobalEventHandlers"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "implementation", ty: TypeRef { ty: Type::Named("DOMImplementation"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "URL", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "documentURI", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "compatMode", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "characterSet", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "charset", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "inputEncoding", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "contentType", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "doctype", ty: TypeRef { ty: Type::Named("DocumentType"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "documentElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "location", ty: TypeRef { ty: Type::Named("Location"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "PutForwards", value: ExtValue::Ident("href") }, ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "domain", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "referrer", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "cookie", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "lastModified", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "readyState", ty: TypeRef { ty: Type::Named("DocumentReadyState"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "title", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "dir", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "body", ty: TypeRef { ty: Type::Named("HTMLElement"), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "head", ty: TypeRef { ty: Type::Named("HTMLHeadElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "images", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "embeds", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "plugins", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "links", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "forms", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "scripts", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "currentScript", ty: TypeRef { ty: Type::Named("HTMLOrSVGScriptElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "defaultView", ty: TypeRef { ty: Type::Named("WindowProxy"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "designMode", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "hidden", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "visibilityState", ty: TypeRef { ty: Type::Named("DocumentVisibilityState"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onreadystatechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyLenientThis", value: ExtValue::None }] }, + Attribute { name: "onvisibilitychange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "fgColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "linkColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "vlinkColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "alinkColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "bgColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "anchors", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "applets", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "all", ty: TypeRef { ty: Type::Named("HTMLAllCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "customElementRegistry", ty: TypeRef { ty: Type::Named("CustomElementRegistry"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("DocumentOrShadowRoot"), ext_attrs: &[] }, + Attribute { name: "styleSheets", ty: TypeRef { ty: Type::Named("StyleSheetList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("DocumentOrShadowRoot"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "adoptedStyleSheets", ty: TypeRef { ty: Type::ObservableArray(&TypeRef { ty: Type::Named("CSSStyleSheet"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("DocumentOrShadowRoot"), ext_attrs: &[] }, + Attribute { name: "activeElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("DocumentOrShadowRoot"), ext_attrs: &[] }, + Attribute { name: "children", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "firstElementChild", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[] }, + Attribute { name: "lastElementChild", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[] }, + Attribute { name: "childElementCount", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[] }, + Attribute { name: "onabort", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onauxclick", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforeinput", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforematch", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforetoggle", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onblur", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncancel", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncanplay", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncanplaythrough", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onclick", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onclose", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncommand", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncontextlost", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncontextmenu", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncontextrestored", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncopy", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncuechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncut", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondblclick", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondrag", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragenter", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragleave", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragover", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragstart", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondrop", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondurationchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onemptied", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onended", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onerror", ty: TypeRef { ty: Type::Named("OnErrorEventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onfocus", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onformdata", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oninput", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oninvalid", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onkeydown", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onkeypress", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onkeyup", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onload", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onloadeddata", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onloadedmetadata", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onloadstart", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmousedown", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseenter", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[ExtAttr { name: "LegacyLenientThis", value: ExtValue::None }] }, + Attribute { name: "onmouseleave", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[ExtAttr { name: "LegacyLenientThis", value: ExtValue::None }] }, + Attribute { name: "onmousemove", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseout", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseover", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseup", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpaste", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpause", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onplay", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onplaying", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onprogress", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onratechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onreset", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onresize", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onscroll", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onscrollend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onsecuritypolicyviolation", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onseeked", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onseeking", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onselect", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onslotchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onstalled", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onsubmit", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onsuspend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ontimeupdate", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ontoggle", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onvolumechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwaiting", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkitanimationend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkitanimationiteration", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkitanimationstart", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkittransitionend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwheel", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("getElementsByTagName"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getElementsByTagNameNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getElementsByClassName"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "classNames", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("createElement"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("ElementCreationOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createElementNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("ElementCreationOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createDocumentFragment"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("DocumentFragment"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createTextNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Text"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createCDATASection"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CDATASection"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createComment"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Comment"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createProcessingInstruction"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ProcessingInstruction"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "target", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("importNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("ImportNodeOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("adoptNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("createAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createAttributeNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Event"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "interface", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createRange"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Range"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createNodeIterator"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("NodeIterator"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "root", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "whatToShow", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(4294967295)), ext_attrs: &[] }, Argument { name: "filter", ty: TypeRef { ty: Type::Named("NodeFilter"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createTreeWalker"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("TreeWalker"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "root", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "whatToShow", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(4294967295)), ext_attrs: &[] }, Argument { name: "filter", ty: TypeRef { ty: Type::Named("NodeFilter"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("parseHTMLUnsafe"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Named("Document"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("ParseHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("parseHTML"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Named("Document"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getElementsByName"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "elementName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("open"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Document"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "unused1", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "unused2", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("open"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WindowProxy"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "features", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("close"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("write"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "text", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("writeln"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "text", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("hasFocus"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("execCommand"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "commandId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "showUI", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("queryCommandEnabled"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "commandId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("queryCommandIndeterm"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "commandId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("queryCommandState"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "commandId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("queryCommandSupported"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "commandId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("queryCommandValue"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "commandId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("clear"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("captureEvents"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("releaseEvents"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getElementById"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "elementId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("NonElementParentNode"), ext_attrs: &[] }, + Operation { name: Some("prepend"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("append"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("replaceChildren"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("moveBefore"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "child", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("querySelector"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "selectors", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[] }, + Operation { name: Some("querySelectorAll"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "selectors", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createExpression"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("XPathExpression"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "expression", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "resolver", ty: TypeRef { ty: Type::Named("XPathNSResolver"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: Some("XPathEvaluatorBase"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createNSResolver"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodeResolver", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("XPathEvaluatorBase"), ext_attrs: &[] }, + Operation { name: Some("evaluate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("XPathResult"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "expression", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "contextNode", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "resolver", ty: TypeRef { ty: Type::Named("XPathNSResolver"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, Argument { name: "result", ty: TypeRef { ty: Type::Named("XPathResult"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: Some("XPathEvaluatorBase"), ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "DocumentFragment", + parent: Some("Node"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["NonElementParentNode", "ParentNode"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "children", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "firstElementChild", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[] }, + Attribute { name: "lastElementChild", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[] }, + Attribute { name: "childElementCount", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("getElementById"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "elementId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("NonElementParentNode"), ext_attrs: &[] }, + Operation { name: Some("prepend"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("append"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("replaceChildren"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("moveBefore"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "child", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("querySelector"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "selectors", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[] }, + Operation { name: Some("querySelectorAll"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "selectors", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "DocumentType", + parent: Some("Node"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["ChildNode"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "publicId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "systemId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("before"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("after"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("replaceWith"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("remove"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "DragEvent", + parent: Some("MouseEvent"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("DragEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "dataTransfer", ty: TypeRef { ty: Type::Named("DataTransfer"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Element", + parent: Some("Node"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["ParentNode", "NonDocumentTypeChildNode", "ChildNode", "Slottable"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "namespaceURI", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "prefix", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "tagName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "className", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "classList", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }] }, + Attribute { name: "slot", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Attribute { name: "attributes", ty: TypeRef { ty: Type::Named("NamedNodeMap"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "shadowRoot", ty: TypeRef { ty: Type::Named("ShadowRoot"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "customElementRegistry", ty: TypeRef { ty: Type::Named("CustomElementRegistry"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "innerHTML", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "outerHTML", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "children", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "firstElementChild", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[] }, + Attribute { name: "lastElementChild", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[] }, + Attribute { name: "childElementCount", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ParentNode"), ext_attrs: &[] }, + Attribute { name: "previousElementSibling", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[] }, + Attribute { name: "nextElementSibling", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[] }, + Attribute { name: "assignedSlot", ty: TypeRef { ty: Type::Named("HTMLSlotElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("Slottable"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("hasAttributes"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAttributeNames"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAttributeNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedType"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("setAttributeNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedType"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("removeAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("removeAttributeNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("toggleAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "force", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("hasAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("hasAttributeNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAttributeNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAttributeNodeNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setAttributeNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "attr", ty: TypeRef { ty: Type::Named("Attr"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("setAttributeNodeNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "attr", ty: TypeRef { ty: Type::Named("Attr"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("removeAttributeNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "attr", ty: TypeRef { ty: Type::Named("Attr"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("attachShadow"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ShadowRoot"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "init", ty: TypeRef { ty: Type::Named("ShadowRootInit"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("closest"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "selectors", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("matches"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "selectors", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("webkitMatchesSelector"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "selectors", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getElementsByTagName"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getElementsByTagNameNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getElementsByClassName"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "classNames", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("insertAdjacentElement"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "where", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "element", ty: TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("insertAdjacentText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "where", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("appendHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("prependHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("streamHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamAppendHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamPrependHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("setHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("appendHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("prependHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("streamHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamAppendHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamPrependHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("getHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("GetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("insertAdjacentHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "position", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "string", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("prepend"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("append"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("replaceChildren"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("moveBefore"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "child", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("querySelector"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "selectors", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[] }, + Operation { name: Some("querySelectorAll"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "selectors", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("ParentNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("beforeHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("afterHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("replaceWithHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("streamBeforeHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamAfterHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamReplaceWithHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("beforeHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("afterHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("replaceWithHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("streamBeforeHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamAfterHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamReplaceWithHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("NonDocumentTypeChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("before"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("after"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("replaceWith"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + Operation { name: Some("remove"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("ChildNode"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Unscopable", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "ElementInternals", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["ARIAMixin"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "shadowRoot", ty: TypeRef { ty: Type::Named("ShadowRoot"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "willValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validity", ty: TypeRef { ty: Type::Named("ValidityState"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validationMessage", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "labels", ty: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "states", ty: TypeRef { ty: Type::Named("CustomStateSet"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("setFormValue"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "value", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("File"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("FormData"), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "state", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("File"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("FormData"), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "flags", ty: TypeRef { ty: Type::Named("ValidityStateFlags"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }, Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "anchor", ty: TypeRef { ty: Type::Named("HTMLElement"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("checkValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "ErrorEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Wildcard }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("ErrorEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "message", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "filename", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "lineno", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "colno", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "error", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Event", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Wildcard }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("EventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[ + Constant { name: "NONE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(0), mixin: None, ext_attrs: &[] }, + Constant { name: "CAPTURING_PHASE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "AT_TARGET", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "BUBBLING_PHASE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "target", ty: TypeRef { ty: Type::Named("EventTarget"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "srcElement", ty: TypeRef { ty: Type::Named("EventTarget"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "currentTarget", ty: TypeRef { ty: Type::Named("EventTarget"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "eventPhase", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "cancelBubble", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "bubbles", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "cancelable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "returnValue", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "defaultPrevented", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "composed", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "isTrusted", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "timeStamp", ty: TypeRef { ty: Type::Named("DOMHighResTimeStamp"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("composedPath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("EventTarget"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("stopPropagation"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("stopImmediatePropagation"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("preventDefault"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("initEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "bubbles", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "cancelable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "EventListener", + parent: None, + callback: true, + ext_attrs: &[], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("handleEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "event", ty: TypeRef { ty: Type::Named("Event"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "EventSource", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventSourceInitDict", ty: TypeRef { ty: Type::Named("EventSourceInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[ + Constant { name: "CONNECTING", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(0), mixin: None, ext_attrs: &[] }, + Constant { name: "OPEN", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "CLOSED", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "withCredentials", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "readyState", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onopen", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onmessage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("close"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "EventTarget", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Wildcard }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("addEventListener"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "callback", ty: TypeRef { ty: Type::Named("EventListener"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("AddEventListenerOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("removeEventListener"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "callback", ty: TypeRef { ty: Type::Named("EventListener"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("EventListenerOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("dispatchEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "event", ty: TypeRef { ty: Type::Named("Event"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "External", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("AddSearchProvider"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("IsSearchProviderInstalled"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "FetchLaterResult", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "activated", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "FocusEvent", + parent: Some("UIEvent"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("FocusEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "relatedTarget", ty: TypeRef { ty: Type::Named("EventTarget"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "FormData", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "submitter", ty: TypeRef { ty: Type::Named("HTMLElement"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("append"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("append"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "blobValue", ty: TypeRef { ty: Type::Named("Blob"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "filename", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("delete"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("get"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("FormDataEntryValue"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAll"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("FormDataEntryValue"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("has"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("set"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("set"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "blobValue", ty: TypeRef { ty: Type::Named("Blob"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "filename", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: Some(Iterable { is_async: false, key: Some(TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }), value: TypeRef { ty: Type::Named("FormDataEntryValue"), nullable: false, ext_attrs: &[] }, args: &[], ext_attrs: &[] }), + collection: None, + }, + Interface { + name: "FormDataEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("FormDataEventInit"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "formData", ty: TypeRef { ty: Type::Named("FormData"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLAllCollection", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyUnenumerableNamedProperties", value: ExtValue::None }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("namedItem"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("item"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "nameOrIndex", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLAnchorElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["HyperlinkElementUtils", "HTMLHyperlinkElementUtils"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "download", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "ping", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "rel", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "relList", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("rel")) }] }, + Attribute { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "referrerPolicy", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "coords", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "charset", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "rev", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "shape", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "origin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[] }, + Attribute { name: "protocol", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "username", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "password", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "host", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "hostname", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "port", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "pathname", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "search", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "hash", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "hreflang", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "href", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: true, mixin: Some("HTMLHyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "target", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HTMLHyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLAreaElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["HyperlinkElementUtils", "HTMLHyperlinkElementUtils"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "alt", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "coords", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "shape", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "download", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "ping", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "rel", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "relList", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("rel")) }] }, + Attribute { name: "referrerPolicy", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "noHref", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "origin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[] }, + Attribute { name: "protocol", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "username", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "password", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "host", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "hostname", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "port", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "pathname", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "search", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "hash", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "hreflang", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "href", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: true, mixin: Some("HTMLHyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "target", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HTMLHyperlinkElementUtils"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLAudioElement", + parent: Some("HTMLMediaElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyFactoryFunction", value: ExtValue::NamedArgs("Audio", &[Argument { name: "src", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }]) }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLBRElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "clear", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLBaseElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "href", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "target", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLBodyElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["WindowEventHandlers"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "link", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "vLink", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "aLink", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "bgColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "background", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "onafterprint", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforeprint", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforeunload", ty: TypeRef { ty: Type::Named("OnBeforeUnloadEventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onhashchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onlanguagechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmessage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmessageerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onoffline", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ononline", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpagehide", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpagereveal", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpageshow", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpageswap", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpopstate", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onrejectionhandled", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onstorage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onunhandledrejection", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onunload", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLButtonElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["PopoverTargetAttributes"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "command", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "commandForElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("commandfor")) }] }, + Attribute { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "formAction", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "formEnctype", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "formMethod", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "formNoValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "formTarget", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "willValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validity", ty: TypeRef { ty: Type::Named("ValidityState"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validationMessage", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "labels", ty: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "popoverTargetElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("PopoverTargetAttributes"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("popovertarget")) }] }, + Attribute { name: "popoverTargetAction", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("PopoverTargetAttributes"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("checkValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setCustomValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "error", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLCanvasElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("getContext"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("RenderingContext"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "contextId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("toDataURL"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("image/png")), ext_attrs: &[] }, Argument { name: "quality", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("toBlob"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "callback", ty: TypeRef { ty: Type::Named("BlobCallback"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("image/png")), ext_attrs: &[] }, Argument { name: "quality", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("transferControlToOffscreen"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("OffscreenCanvas"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLCollection", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyUnenumerableNamedProperties", value: ExtValue::None }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("namedItem"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLDListElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "compact", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLDataElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLDataListElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "options", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLDetailsElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "open", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLDialogElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "open", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "returnValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "closedBy", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("show"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("showModal"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("close"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "returnValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("requestClose"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "returnValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLDirectoryElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "compact", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLDivElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLElement", + parent: Some("Element"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["ElementCSSInlineStyle", "GlobalEventHandlers", "ElementContentEditable", "HTMLOrSVGOrMathMLElement"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "title", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "lang", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "translate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "dir", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "hidden", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "inert", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "accessKey", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "accessKeyLabel", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "draggable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "spellcheck", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "writingSuggestions", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "autocapitalize", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "autocorrect", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "innerText", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "outerText", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "popover", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "headingOffset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }, ExtAttr { name: "ReflectRange", value: ExtValue::LiteralList(&[Value::Integer(0), Value::Integer(8)]) }] }, + Attribute { name: "headingReset", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "style", ty: TypeRef { ty: Type::Named("CSSStyleProperties"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ElementCSSInlineStyle"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("cssText") }] }, + Attribute { name: "onabort", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onauxclick", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforeinput", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforematch", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforetoggle", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onblur", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncancel", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncanplay", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncanplaythrough", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onclick", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onclose", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncommand", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncontextlost", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncontextmenu", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncontextrestored", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncopy", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncuechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncut", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondblclick", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondrag", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragenter", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragleave", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragover", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragstart", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondrop", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondurationchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onemptied", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onended", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onerror", ty: TypeRef { ty: Type::Named("OnErrorEventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onfocus", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onformdata", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oninput", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oninvalid", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onkeydown", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onkeypress", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onkeyup", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onload", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onloadeddata", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onloadedmetadata", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onloadstart", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmousedown", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseenter", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[ExtAttr { name: "LegacyLenientThis", value: ExtValue::None }] }, + Attribute { name: "onmouseleave", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[ExtAttr { name: "LegacyLenientThis", value: ExtValue::None }] }, + Attribute { name: "onmousemove", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseout", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseover", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseup", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpaste", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpause", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onplay", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onplaying", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onprogress", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onratechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onreset", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onresize", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onscroll", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onscrollend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onsecuritypolicyviolation", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onseeked", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onseeking", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onselect", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onslotchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onstalled", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onsubmit", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onsuspend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ontimeupdate", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ontoggle", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onvolumechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwaiting", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkitanimationend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkitanimationiteration", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkitanimationstart", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkittransitionend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwheel", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "contentEditable", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("ElementContentEditable"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "enterKeyHint", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("ElementContentEditable"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "isContentEditable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("ElementContentEditable"), ext_attrs: &[] }, + Attribute { name: "inputMode", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("ElementContentEditable"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "dataset", ty: TypeRef { ty: Type::Named("DOMStringMap"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("HTMLOrSVGOrMathMLElement"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "nonce", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HTMLOrSVGOrMathMLElement"), ext_attrs: &[] }, + Attribute { name: "autofocus", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HTMLOrSVGOrMathMLElement"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "tabIndex", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("HTMLOrSVGOrMathMLElement"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("click"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("attachInternals"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ElementInternals"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("showPopover"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("ShowPopoverOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("hidePopover"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("togglePopover"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TogglePopoverOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("focus"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("FocusOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("HTMLOrSVGOrMathMLElement"), ext_attrs: &[] }, + Operation { name: Some("blur"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("HTMLOrSVGOrMathMLElement"), ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLEmbedElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "src", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "hspace", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "vspace", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("getSVGDocument"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Document"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLFieldSetElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "elements", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "willValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validity", ty: TypeRef { ty: Type::Named("ValidityState"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "validationMessage", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("checkValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setCustomValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "error", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLFontElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "color", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "face", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "size", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLFormControlsCollection", + parent: Some("HTMLCollection"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("namedItem"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("RadioNodeList"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLFormElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyOverrideBuiltIns", value: ExtValue::None }, ExtAttr { name: "LegacyUnenumerableNamedProperties", value: ExtValue::None }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "acceptCharset", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("accept-charset")) }] }, + Attribute { name: "action", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "autocomplete", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "enctype", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "encoding", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "method", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "noValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "target", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "rel", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "relList", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("rel")) }] }, + Attribute { name: "elements", ty: TypeRef { ty: Type::Named("HTMLFormControlsCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("RadioNodeList"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("submit"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("requestSubmit"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "submitter", ty: TypeRef { ty: Type::Named("HTMLElement"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reset"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("checkValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLFrameElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "scrolling", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "src", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "frameBorder", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "longDesc", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "noResize", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "contentDocument", ty: TypeRef { ty: Type::Named("Document"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "contentWindow", ty: TypeRef { ty: Type::Named("WindowProxy"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "marginHeight", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "marginWidth", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLFrameSetElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["WindowEventHandlers"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "cols", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "rows", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "onafterprint", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforeprint", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforeunload", ty: TypeRef { ty: Type::Named("OnBeforeUnloadEventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onhashchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onlanguagechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmessage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmessageerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onoffline", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ononline", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpagehide", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpagereveal", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpageshow", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpageswap", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpopstate", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onrejectionhandled", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onstorage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onunhandledrejection", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onunload", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLHRElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "color", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "noShade", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "size", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLHeadElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLHeadingElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLHtmlElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "version", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLIFrameElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "src", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "srcdoc", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "sandbox", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "allow", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "allowFullscreen", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "referrerPolicy", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "loading", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "contentDocument", ty: TypeRef { ty: Type::Named("Document"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "contentWindow", ty: TypeRef { ty: Type::Named("WindowProxy"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "scrolling", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "frameBorder", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "longDesc", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "marginHeight", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "marginWidth", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("getSVGDocument"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Document"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLImageElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyFactoryFunction", value: ExtValue::NamedArgs("Image", &[Argument { name: "width", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "height", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }]) }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "alt", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "src", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "srcset", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "sizes", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "crossOrigin", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "useMap", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "isMap", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "controls", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "naturalWidth", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "naturalHeight", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "complete", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "currentSrc", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "referrerPolicy", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "decoding", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "loading", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "fetchPriority", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "lowsrc", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "hspace", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "vspace", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "longDesc", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "border", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("decode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLInputElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["PopoverTargetAttributes"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "accept", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "alpha", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "alt", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "autocomplete", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "defaultChecked", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("checked")) }] }, + Attribute { name: "checked", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "colorSpace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "dirName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "files", ty: TypeRef { ty: Type::Named("FileList"), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "formAction", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "formEnctype", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "formMethod", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "formNoValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "formTarget", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "indeterminate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "list", ty: TypeRef { ty: Type::Named("HTMLDataListElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "max", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "maxLength", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectNonNegative", value: ExtValue::None }] }, + Attribute { name: "min", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "minLength", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectNonNegative", value: ExtValue::None }] }, + Attribute { name: "multiple", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "pattern", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "placeholder", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "readOnly", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "required", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "size", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "src", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "step", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "defaultValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("value")) }] }, + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "valueAsDate", ty: TypeRef { ty: Type::Simple(Simple::Object), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "valueAsNumber", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "willValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validity", ty: TypeRef { ty: Type::Named("ValidityState"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validationMessage", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "labels", ty: TypeRef { ty: Type::Named("NodeList"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "selectionStart", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "selectionEnd", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "selectionDirection", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "useMap", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "hspace", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "vspace", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "popoverTargetElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("PopoverTargetAttributes"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("popovertarget")) }] }, + Attribute { name: "popoverTargetAction", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("PopoverTargetAttributes"), ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("stepUp"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "n", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(1)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("stepDown"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "n", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(1)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("checkValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setCustomValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "error", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("select"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setRangeText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "replacement", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setRangeText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "replacement", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "start", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "end", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "selectionMode", ty: TypeRef { ty: Type::Named("SelectionMode"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("preserve")), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setSelectionRange"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "start", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "end", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "direction", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("showPicker"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLLIElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLLabelElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "htmlFor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("for")) }] }, + Attribute { name: "control", ty: TypeRef { ty: Type::Named("HTMLElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLLegendElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLLinkElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["LinkStyle"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "href", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "crossOrigin", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "rel", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "as", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "relList", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("rel")) }] }, + Attribute { name: "media", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "integrity", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "hreflang", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "sizes", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "imageSrcset", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "imageSizes", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "referrerPolicy", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "blocking", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "fetchPriority", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "charset", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "rev", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "target", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "sheet", ty: TypeRef { ty: Type::Named("CSSStyleSheet"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("LinkStyle"), ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLMapElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "areas", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLMarqueeElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "behavior", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "bgColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "direction", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "hspace", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "loop", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "scrollAmount", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }, ExtAttr { name: "ReflectDefault", value: ExtValue::Literal(Value::Integer(6)) }] }, + Attribute { name: "scrollDelay", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }, ExtAttr { name: "ReflectDefault", value: ExtValue::Literal(Value::Integer(85)) }] }, + Attribute { name: "trueSpeed", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "vspace", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("start"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("stop"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLMediaElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[ + Constant { name: "NETWORK_EMPTY", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(0), mixin: None, ext_attrs: &[] }, + Constant { name: "NETWORK_IDLE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "NETWORK_LOADING", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "NETWORK_NO_SOURCE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + Constant { name: "HAVE_NOTHING", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(0), mixin: None, ext_attrs: &[] }, + Constant { name: "HAVE_METADATA", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "HAVE_CURRENT_DATA", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "HAVE_FUTURE_DATA", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + Constant { name: "HAVE_ENOUGH_DATA", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(4), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "error", ty: TypeRef { ty: Type::Named("MediaError"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "src", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "srcObject", ty: TypeRef { ty: Type::Named("MediaProvider"), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "currentSrc", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "crossOrigin", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "networkState", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "preload", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "buffered", ty: TypeRef { ty: Type::Named("TimeRanges"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "readyState", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "seeking", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "currentTime", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "duration", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "paused", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "defaultPlaybackRate", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "playbackRate", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "preservesPitch", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "played", ty: TypeRef { ty: Type::Named("TimeRanges"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "seekable", ty: TypeRef { ty: Type::Named("TimeRanges"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "ended", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "autoplay", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "loop", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "controls", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "volume", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "muted", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "defaultMuted", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("muted")) }] }, + Attribute { name: "loading", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "audioTracks", ty: TypeRef { ty: Type::Named("AudioTrackList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "videoTracks", ty: TypeRef { ty: Type::Named("VideoTrackList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "textTracks", ty: TypeRef { ty: Type::Named("TextTrackList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("load"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("canPlayType"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanPlayTypeResult"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("fastSeek"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "time", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getStartDate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("play"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("pause"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("addTextTrack"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("TextTrack"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "kind", ty: TypeRef { ty: Type::Named("TextTrackKind"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "label", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }, Argument { name: "language", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLMenuElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "compact", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLMetaElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "httpEquiv", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("http-equiv")) }] }, + Attribute { name: "content", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "media", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "scheme", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLMeterElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "min", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "max", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "low", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "high", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "optimum", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "labels", ty: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLModElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "cite", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "dateTime", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLOListElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "reversed", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "start", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }, ExtAttr { name: "ReflectDefault", value: ExtValue::Literal(Value::Integer(1)) }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "compact", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLObjectElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "data", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "contentDocument", ty: TypeRef { ty: Type::Named("Document"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "contentWindow", ty: TypeRef { ty: Type::Named("WindowProxy"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "willValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validity", ty: TypeRef { ty: Type::Named("ValidityState"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validationMessage", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "archive", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "code", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "declare", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "hspace", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "standby", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "vspace", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "codeBase", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "codeType", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "useMap", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "border", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("getSVGDocument"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Document"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("checkValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setCustomValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "error", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLOptGroupElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "label", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLOptionElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyFactoryFunction", value: ExtValue::NamedArgs("Option", &[Argument { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "defaultSelected", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "selected", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }]) }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "label", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "defaultSelected", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("selected")) }] }, + Attribute { name: "selected", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "index", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLOptionsCollection", + parent: Some("HTMLCollection"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "selectedIndex", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: None, kind: OperationKind::Setter, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "option", ty: TypeRef { ty: Type::Named("HTMLOptionElement"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("add"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "element", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("HTMLOptionElement"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("HTMLOptGroupElement"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "before", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("HTMLElement"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("remove"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLOutputElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "htmlFor", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("for")) }] }, + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "defaultValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "willValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validity", ty: TypeRef { ty: Type::Named("ValidityState"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validationMessage", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "labels", ty: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("checkValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setCustomValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "error", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLParagraphElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLParamElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "valueType", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLPictureElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLPreElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLProgressElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "max", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectPositive", value: ExtValue::None }, ExtAttr { name: "ReflectDefault", value: ExtValue::Literal(Value::Decimal("1.0")) }] }, + Attribute { name: "position", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "labels", ty: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLQuoteElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "cite", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLScriptElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "src", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedScriptURL"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "noModule", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "async", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "defer", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "blocking", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "crossOrigin", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "referrerPolicy", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "integrity", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "fetchPriority", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "innerText", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedScript"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "textContent", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedScript"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "text", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedScript"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "charset", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "event", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "htmlFor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("for")) }] }, + ], + operations: &[ + Operation { name: Some("supports"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLSelectElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "autocomplete", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "multiple", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "required", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "size", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }, ExtAttr { name: "ReflectDefault", value: ExtValue::Literal(Value::Integer(0)) }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "options", ty: TypeRef { ty: Type::Named("HTMLOptionsCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "selectedOptions", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "selectedIndex", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "willValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validity", ty: TypeRef { ty: Type::Named("ValidityState"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validationMessage", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "labels", ty: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("HTMLOptionElement"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("namedItem"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLOptionElement"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("add"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "element", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("HTMLOptionElement"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("HTMLOptGroupElement"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "before", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("HTMLElement"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("remove"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("remove"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: None, kind: OperationKind::Setter, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "option", ty: TypeRef { ty: Type::Named("HTMLOptionElement"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("checkValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setCustomValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "error", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("showPicker"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLSelectedContentElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLSlotElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("assignedNodes"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("AssignedNodesOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("assignedElements"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("AssignedNodesOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("assign"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodes", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("Text"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLSourceElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "src", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "srcset", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "sizes", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "media", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLSpanElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLStyleElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["LinkStyle"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "media", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "blocking", ty: TypeRef { ty: Type::Named("DOMTokenList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("value") }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "sheet", ty: TypeRef { ty: Type::Named("CSSStyleSheet"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("LinkStyle"), ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTableCaptionElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTableCellElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "colSpan", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }, ExtAttr { name: "ReflectDefault", value: ExtValue::Literal(Value::Integer(1)) }, ExtAttr { name: "ReflectRange", value: ExtValue::LiteralList(&[Value::Integer(1), Value::Integer(1000)]) }] }, + Attribute { name: "rowSpan", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }, ExtAttr { name: "ReflectDefault", value: ExtValue::Literal(Value::Integer(1)) }, ExtAttr { name: "ReflectRange", value: ExtValue::LiteralList(&[Value::Integer(0), Value::Integer(65534)]) }] }, + Attribute { name: "headers", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "cellIndex", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "scope", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "abbr", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "axis", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "ch", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("char")) }] }, + Attribute { name: "chOff", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("charoff")) }] }, + Attribute { name: "noWrap", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "vAlign", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "bgColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTableColElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "span", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }, ExtAttr { name: "ReflectDefault", value: ExtValue::Literal(Value::Integer(1)) }, ExtAttr { name: "ReflectRange", value: ExtValue::LiteralList(&[Value::Integer(1), Value::Integer(1000)]) }] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "ch", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("char")) }] }, + Attribute { name: "chOff", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("charoff")) }] }, + Attribute { name: "vAlign", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTableElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "caption", ty: TypeRef { ty: Type::Named("HTMLTableCaptionElement"), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "tHead", ty: TypeRef { ty: Type::Named("HTMLTableSectionElement"), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "tFoot", ty: TypeRef { ty: Type::Named("HTMLTableSectionElement"), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "tBodies", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "rows", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "border", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "frame", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "rules", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "summary", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "bgColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "cellPadding", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "cellSpacing", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("createCaption"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLTableCaptionElement"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteCaption"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("createTHead"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLTableSectionElement"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteTHead"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("createTFoot"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLTableSectionElement"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteTFoot"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("createTBody"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLTableSectionElement"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("insertRow"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLTableRowElement"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(-1)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteRow"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTableRowElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "rowIndex", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "sectionRowIndex", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "cells", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "ch", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("char")) }] }, + Attribute { name: "chOff", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("charoff")) }] }, + Attribute { name: "vAlign", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "bgColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("insertCell"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLTableCellElement"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(-1)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteCell"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTableSectionElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "rows", ty: TypeRef { ty: Type::Named("HTMLCollection"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "align", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "ch", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("char")) }] }, + Attribute { name: "chOff", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("charoff")) }] }, + Attribute { name: "vAlign", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("insertRow"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("HTMLTableRowElement"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(-1)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteRow"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTemplateElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "content", ty: TypeRef { ty: Type::Named("DocumentFragment"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "htmlFor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::Literal(Value::Str("for")) }] }, + Attribute { name: "shadowRootMode", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "shadowRootDelegatesFocus", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "shadowRootSerializable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "shadowRootSlotAssignment", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "shadowRootClonable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "shadowRootCustomElementRegistry", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTextAreaElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "autocomplete", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectSetter", value: ExtValue::None }] }, + Attribute { name: "cols", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectPositiveWithFallback", value: ExtValue::None }, ExtAttr { name: "ReflectDefault", value: ExtValue::Literal(Value::Integer(20)) }] }, + Attribute { name: "dirName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "form", ty: TypeRef { ty: Type::Named("HTMLFormElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "maxLength", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectNonNegative", value: ExtValue::None }] }, + Attribute { name: "minLength", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectNonNegative", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "placeholder", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "readOnly", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "required", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "rows", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectPositiveWithFallback", value: ExtValue::None }, ExtAttr { name: "ReflectDefault", value: ExtValue::Literal(Value::Integer(2)) }] }, + Attribute { name: "wrap", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "defaultValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "textLength", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "willValidate", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validity", ty: TypeRef { ty: Type::Named("ValidityState"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "validationMessage", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "labels", ty: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "selectionStart", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "selectionEnd", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "selectionDirection", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("checkValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setCustomValidity"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "error", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("select"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setRangeText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "replacement", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setRangeText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "replacement", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "start", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "end", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "selectionMode", ty: TypeRef { ty: Type::Named("SelectionMode"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("preserve")), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setSelectionRange"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "start", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "end", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "direction", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTimeElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "dateTime", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTitleElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLTrackElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[ + Constant { name: "NONE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(0), mixin: None, ext_attrs: &[] }, + Constant { name: "LOADING", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "LOADED", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "ERROR", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "kind", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "src", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "srclang", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "label", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "default", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "readyState", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "track", ty: TypeRef { ty: Type::Named("TextTrack"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLUListElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "compact", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLUnknownElement", + parent: Some("HTMLElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HTMLVideoElement", + parent: Some("HTMLMediaElement"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[ExtAttr { name: "HTMLConstructor", value: ExtValue::None }] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + Attribute { name: "videoWidth", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "videoHeight", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "poster", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "ReflectURL", value: ExtValue::None }] }, + Attribute { name: "playsInline", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "Reflect", value: ExtValue::None }] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "HashChangeEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("HashChangeEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "oldURL", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "newURL", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Headers", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "init", ty: TypeRef { ty: Type::Named("HeadersInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("append"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("delete"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("get"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getSetCookie"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("has"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("set"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: Some(Iterable { is_async: false, key: Some(TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }), value: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, args: &[], ext_attrs: &[] }), + collection: None, + }, + Interface { + name: "History", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "scrollRestoration", ty: TypeRef { ty: Type::Named("ScrollRestoration"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "state", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("go"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "delta", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("back"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("forward"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("pushState"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "unused", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("replaceState"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "unused", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "ImageBitmap", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }, ExtAttr { name: "Serializable", value: ExtValue::None }, ExtAttr { name: "Transferable", value: ExtValue::None }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("close"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "ImageBitmapRenderingContext", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "canvas", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("HTMLCanvasElement"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("OffscreenCanvas"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("transferFromImageBitmap"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "bitmap", ty: TypeRef { ty: Type::Named("ImageBitmap"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "ImageData", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }, ExtAttr { name: "Serializable", value: ExtValue::None }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "sw", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sh", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "settings", ty: TypeRef { ty: Type::Named("ImageDataSettings"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + Constructor { args: &[Argument { name: "data", ty: TypeRef { ty: Type::Named("ImageDataArray"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sw", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sh", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "settings", ty: TypeRef { ty: Type::Named("ImageDataSettings"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "data", ty: TypeRef { ty: Type::Named("ImageDataArray"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "pixelFormat", ty: TypeRef { ty: Type::Named("ImageDataPixelFormat"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "colorSpace", ty: TypeRef { ty: Type::Named("PredefinedColorSpace"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "InputEvent", + parent: Some("UIEvent"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("InputEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "data", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "isComposing", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "inputType", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "KeyboardEvent", + parent: Some("UIEvent"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("KeyboardEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[ + Constant { name: "DOM_KEY_LOCATION_STANDARD", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(0), mixin: None, ext_attrs: &[] }, + Constant { name: "DOM_KEY_LOCATION_LEFT", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "DOM_KEY_LOCATION_RIGHT", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "DOM_KEY_LOCATION_NUMPAD", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "code", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "location", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "ctrlKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "shiftKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "altKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "metaKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "repeat", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "isComposing", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "charCode", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "keyCode", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("getModifierState"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "keyArg", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("initKeyboardEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "typeArg", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "bubblesArg", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "cancelableArg", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "viewArg", ty: TypeRef { ty: Type::Named("Window"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "keyArg", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }, Argument { name: "locationArg", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, Argument { name: "ctrlKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "altKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "shiftKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "metaKey", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Location", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "href", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: true, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "origin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "protocol", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "host", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "hostname", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "port", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "pathname", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "search", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "hash", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "ancestorOrigins", ty: TypeRef { ty: Type::Named("DOMStringList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("assign"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Operation { name: Some("replace"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Operation { name: Some("reload"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "MediaError", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[ + Constant { name: "MEDIA_ERR_ABORTED", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "MEDIA_ERR_NETWORK", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "MEDIA_ERR_DECODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + Constant { name: "MEDIA_ERR_SRC_NOT_SUPPORTED", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(4), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "code", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "message", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "MediaList", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "mediaText", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: true, mixin: None, ext_attrs: &[] }, + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("CSSOMString"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("appendMedium"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "medium", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteMedium"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "medium", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "MessageChannel", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "port1", ty: TypeRef { ty: Type::Named("MessagePort"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "port2", ty: TypeRef { ty: Type::Named("MessagePort"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "MessageEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker", "AudioWorklet"]) }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("MessageEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "data", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "origin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "lastEventId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "source", ty: TypeRef { ty: Type::Named("MessageEventSource"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "ports", ty: TypeRef { ty: Type::FrozenArray(&TypeRef { ty: Type::Named("MessagePort"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("initMessageEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "bubbles", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "cancelable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "origin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }, Argument { name: "lastEventId", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }, Argument { name: "source", ty: TypeRef { ty: Type::Named("MessageEventSource"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "ports", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("MessagePort"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptySequence), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "MessagePort", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker", "AudioWorklet"]) }, ExtAttr { name: "Transferable", value: ExtValue::None }], + includes: &["MessageEventTarget"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "onmessage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("MessageEventTarget"), ext_attrs: &[] }, + Attribute { name: "onmessageerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("MessageEventTarget"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("postMessage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "transfer", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("postMessage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("StructuredSerializeOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("start"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("close"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "MimeType", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "description", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "suffixes", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "enabledPlugin", ty: TypeRef { ty: Type::Named("Plugin"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "MimeTypeArray", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyUnenumerableNamedProperties", value: ExtValue::None }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("MimeType"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("namedItem"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("MimeType"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "MutationObserver", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "callback", ty: TypeRef { ty: Type::Named("MutationCallback"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("observe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "target", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("MutationObserverInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("disconnect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("takeRecords"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("MutationRecord"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "MutationRecord", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "target", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "addedNodes", ty: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "removedNodes", ty: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "previousSibling", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "nextSibling", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "attributeName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "attributeNamespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "oldValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "NamedNodeMap", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyUnenumerableNamedProperties", value: ExtValue::None }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("Attr"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getNamedItem"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("Attr"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getNamedItemNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setNamedItem"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "attr", ty: TypeRef { ty: Type::Named("Attr"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("setNamedItemNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "attr", ty: TypeRef { ty: Type::Named("Attr"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("removeNamedItem"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "qualifiedName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("removeNamedItemNS"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Attr"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "NavigateEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("NavigateEventInit"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "navigationType", ty: TypeRef { ty: Type::Named("NavigationType"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "destination", ty: TypeRef { ty: Type::Named("NavigationDestination"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "canIntercept", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "userInitiated", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "hashChange", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "signal", ty: TypeRef { ty: Type::Named("AbortSignal"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "formData", ty: TypeRef { ty: Type::Named("FormData"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "downloadRequest", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "info", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "hasUAVisualTransition", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "sourceElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("intercept"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("NavigationInterceptOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("scroll"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Navigation", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "currentEntry", ty: TypeRef { ty: Type::Named("NavigationHistoryEntry"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "transition", ty: TypeRef { ty: Type::Named("NavigationTransition"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "activation", ty: TypeRef { ty: Type::Named("NavigationActivation"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "canGoBack", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "canGoForward", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onnavigate", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onnavigatesuccess", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onnavigateerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "oncurrententrychange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("entries"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Named("NavigationHistoryEntry"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("updateCurrentEntry"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("NavigationUpdateCurrentEntryOptions"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("navigate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("NavigationResult"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("NavigationNavigateOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reload"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("NavigationResult"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("NavigationReloadOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("traverseTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("NavigationResult"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("NavigationOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("back"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("NavigationResult"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("NavigationOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("forward"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("NavigationResult"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("NavigationOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "NavigationActivation", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "from", ty: TypeRef { ty: Type::Named("NavigationHistoryEntry"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "entry", ty: TypeRef { ty: Type::Named("NavigationHistoryEntry"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "navigationType", ty: TypeRef { ty: Type::Named("NavigationType"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "NavigationCurrentEntryChangeEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("NavigationCurrentEntryChangeEventInit"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "navigationType", ty: TypeRef { ty: Type::Named("NavigationType"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "from", ty: TypeRef { ty: Type::Named("NavigationHistoryEntry"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "NavigationDestination", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "index", ty: TypeRef { ty: Type::Simple(Simple::LongLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "sameDocument", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("getState"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "NavigationHistoryEntry", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "index", ty: TypeRef { ty: Type::Simple(Simple::LongLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "sameDocument", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "ondispose", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("getState"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "NavigationPrecommitController", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("redirect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("NavigationNavigateOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("addHandler"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "handler", ty: TypeRef { ty: Type::Named("NavigationInterceptHandler"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "NavigationTransition", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "navigationType", ty: TypeRef { ty: Type::Named("NavigationType"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "from", ty: TypeRef { ty: Type::Named("NavigationHistoryEntry"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "to", ty: TypeRef { ty: Type::Named("NavigationDestination"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "committed", ty: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "finished", ty: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Navigator", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["NavigatorID", "NavigatorLanguage", "NavigatorOnLine", "NavigatorContentUtils", "NavigatorCookies", "NavigatorPlugins", "NavigatorConcurrentHardware", "NavigatorStorage"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "userActivation", ty: TypeRef { ty: Type::Named("UserActivation"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "appCodeName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "appName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "appVersion", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "platform", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "product", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "productSub", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + Attribute { name: "userAgent", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "vendor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + Attribute { name: "vendorSub", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + Attribute { name: "oscpu", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + Attribute { name: "language", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorLanguage"), ext_attrs: &[] }, + Attribute { name: "languages", ty: TypeRef { ty: Type::FrozenArray(&TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorLanguage"), ext_attrs: &[] }, + Attribute { name: "onLine", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorOnLine"), ext_attrs: &[] }, + Attribute { name: "cookieEnabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorCookies"), ext_attrs: &[] }, + Attribute { name: "plugins", ty: TypeRef { ty: Type::Named("PluginArray"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorPlugins"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "mimeTypes", ty: TypeRef { ty: Type::Named("MimeTypeArray"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorPlugins"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "pdfViewerEnabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorPlugins"), ext_attrs: &[] }, + Attribute { name: "hardwareConcurrency", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLongLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorConcurrentHardware"), ext_attrs: &[] }, + Attribute { name: "storage", ty: TypeRef { ty: Type::Named("StorageManager"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorStorage"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "SecureContext", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("taintEnabled"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("NavigatorID"), ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + Operation { name: Some("registerProtocolHandler"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "scheme", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("NavigatorContentUtils"), ext_attrs: &[ExtAttr { name: "SecureContext", value: ExtValue::None }] }, + Operation { name: Some("unregisterProtocolHandler"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "scheme", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("NavigatorContentUtils"), ext_attrs: &[ExtAttr { name: "SecureContext", value: ExtValue::None }] }, + Operation { name: Some("javaEnabled"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("NavigatorPlugins"), ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Node", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[ + Constant { name: "ELEMENT_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "ATTRIBUTE_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "TEXT_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + Constant { name: "CDATA_SECTION_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(4), mixin: None, ext_attrs: &[] }, + Constant { name: "ENTITY_REFERENCE_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(5), mixin: None, ext_attrs: &[] }, + Constant { name: "ENTITY_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(6), mixin: None, ext_attrs: &[] }, + Constant { name: "PROCESSING_INSTRUCTION_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(7), mixin: None, ext_attrs: &[] }, + Constant { name: "COMMENT_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(8), mixin: None, ext_attrs: &[] }, + Constant { name: "DOCUMENT_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(9), mixin: None, ext_attrs: &[] }, + Constant { name: "DOCUMENT_TYPE_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(10), mixin: None, ext_attrs: &[] }, + Constant { name: "DOCUMENT_FRAGMENT_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(11), mixin: None, ext_attrs: &[] }, + Constant { name: "NOTATION_NODE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(12), mixin: None, ext_attrs: &[] }, + Constant { name: "DOCUMENT_POSITION_DISCONNECTED", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "DOCUMENT_POSITION_PRECEDING", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "DOCUMENT_POSITION_FOLLOWING", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(4), mixin: None, ext_attrs: &[] }, + Constant { name: "DOCUMENT_POSITION_CONTAINS", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(8), mixin: None, ext_attrs: &[] }, + Constant { name: "DOCUMENT_POSITION_CONTAINED_BY", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(16), mixin: None, ext_attrs: &[] }, + Constant { name: "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(32), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "nodeType", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "nodeName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "baseURI", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "isConnected", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "ownerDocument", ty: TypeRef { ty: Type::Named("Document"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "parentNode", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "parentElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "childNodes", ty: TypeRef { ty: Type::Named("NodeList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "firstChild", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "lastChild", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "previousSibling", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "nextSibling", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "nodeValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "textContent", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("getRootNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("GetRootNodeOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("hasChildNodes"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("normalize"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("cloneNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "subtree", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("isEqualNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "otherNode", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("isSameNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "otherNode", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("compareDocumentPosition"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "other", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("contains"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "other", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("lookupPrefix"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("lookupNamespaceURI"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "prefix", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("isDefaultNamespace"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespace", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("insertBefore"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "child", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("appendChild"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("replaceChild"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "child", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("removeChild"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "child", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "NodeFilter", + parent: None, + callback: true, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[ + Constant { name: "FILTER_ACCEPT", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "FILTER_REJECT", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "FILTER_SKIP", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_ALL", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(4294967295), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_ELEMENT", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_ATTRIBUTE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_TEXT", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(4), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_CDATA_SECTION", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(8), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_ENTITY_REFERENCE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(16), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_ENTITY", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(32), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_PROCESSING_INSTRUCTION", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(64), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_COMMENT", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(128), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_DOCUMENT", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(256), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_DOCUMENT_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(512), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_DOCUMENT_FRAGMENT", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(1024), mixin: None, ext_attrs: &[] }, + Constant { name: "SHOW_NOTATION", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, value: Value::Integer(2048), mixin: None, ext_attrs: &[] }, + ], + attributes: &[], + operations: &[ + Operation { name: Some("acceptNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "NodeIterator", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "root", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "referenceNode", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "pointerBeforeReferenceNode", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "whatToShow", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "filter", ty: TypeRef { ty: Type::Named("NodeFilter"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("nextNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("previousNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("detach"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "NodeList", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: Some(Iterable { is_async: false, key: None, value: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[], ext_attrs: &[] }), + collection: None, + }, + Interface { + name: "NodeRange", + parent: Some("AbstractRange"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "startContainer", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "endContainer", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "NotRestoredReasonDetails", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "reason", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("toJSON"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "Default", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "NotRestoredReasons", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "src", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "reasons", ty: TypeRef { ty: Type::FrozenArray(&TypeRef { ty: Type::Named("NotRestoredReasonDetails"), nullable: false, ext_attrs: &[] }), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "children", ty: TypeRef { ty: Type::FrozenArray(&TypeRef { ty: Type::Named("NotRestoredReasons"), nullable: false, ext_attrs: &[] }), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("toJSON"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "Default", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "OffscreenCanvas", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }, ExtAttr { name: "Transferable", value: ExtValue::None }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "width", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLongLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "height", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLongLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLongLong), nullable: false, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "height", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLongLong), nullable: false, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "oncontextlost", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "oncontextrestored", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("getContext"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("OffscreenRenderingContext"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "contextId", ty: TypeRef { ty: Type::Named("OffscreenRenderingContextId"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("transferToImageBitmap"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ImageBitmap"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("convertToBlob"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("Blob"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("ImageEncodeOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "OffscreenCanvasRenderingContext2D", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &["CanvasSettings", "CanvasState", "CanvasTransform", "CanvasCompositing", "CanvasImageSmoothing", "CanvasFillStrokeStyles", "CanvasShadowStyles", "CanvasFilters", "CanvasRect", "CanvasDrawPath", "CanvasText", "CanvasDrawImage", "CanvasImageData", "CanvasPathDrawingStyles", "CanvasTextDrawingStyles", "CanvasPath"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "canvas", ty: TypeRef { ty: Type::Named("OffscreenCanvas"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "globalAlpha", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasCompositing"), ext_attrs: &[] }, + Attribute { name: "globalCompositeOperation", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasCompositing"), ext_attrs: &[] }, + Attribute { name: "imageSmoothingEnabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasImageSmoothing"), ext_attrs: &[] }, + Attribute { name: "imageSmoothingQuality", ty: TypeRef { ty: Type::Named("ImageSmoothingQuality"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasImageSmoothing"), ext_attrs: &[] }, + Attribute { name: "strokeStyle", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("CanvasGradient"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("CanvasPattern"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Attribute { name: "fillStyle", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("CanvasGradient"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("CanvasPattern"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Attribute { name: "shadowOffsetX", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasShadowStyles"), ext_attrs: &[] }, + Attribute { name: "shadowOffsetY", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasShadowStyles"), ext_attrs: &[] }, + Attribute { name: "shadowBlur", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasShadowStyles"), ext_attrs: &[] }, + Attribute { name: "shadowColor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasShadowStyles"), ext_attrs: &[] }, + Attribute { name: "filter", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasFilters"), ext_attrs: &[] }, + Attribute { name: "lineWidth", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "lineCap", ty: TypeRef { ty: Type::Named("CanvasLineCap"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "lineJoin", ty: TypeRef { ty: Type::Named("CanvasLineJoin"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "miterLimit", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "lineDashOffset", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "lang", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "font", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "textAlign", ty: TypeRef { ty: Type::Named("CanvasTextAlign"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "textBaseline", ty: TypeRef { ty: Type::Named("CanvasTextBaseline"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "direction", ty: TypeRef { ty: Type::Named("CanvasDirection"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "letterSpacing", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "fontKerning", ty: TypeRef { ty: Type::Named("CanvasFontKerning"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "fontStretch", ty: TypeRef { ty: Type::Named("CanvasFontStretch"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "fontVariantCaps", ty: TypeRef { ty: Type::Named("CanvasFontVariantCaps"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "textRendering", ty: TypeRef { ty: Type::Named("CanvasTextRendering"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + Attribute { name: "wordSpacing", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("CanvasTextDrawingStyles"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("getContextAttributes"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanvasRenderingContext2DSettings"), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasSettings"), ext_attrs: &[] }, + Operation { name: Some("save"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasState"), ext_attrs: &[] }, + Operation { name: Some("restore"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasState"), ext_attrs: &[] }, + Operation { name: Some("reset"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasState"), ext_attrs: &[] }, + Operation { name: Some("isContextLost"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasState"), ext_attrs: &[] }, + Operation { name: Some("scale"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("rotate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "angle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("translate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("transform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "a", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "b", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "c", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "d", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "e", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "f", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("getTransform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("DOMMatrix"), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasTransform"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("setTransform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "a", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "b", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "c", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "d", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "e", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "f", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("setTransform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "transform", ty: TypeRef { ty: Type::Named("DOMMatrix2DInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("resetTransform"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasTransform"), ext_attrs: &[] }, + Operation { name: Some("createLinearGradient"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanvasGradient"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x0", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y0", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x1", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y1", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Operation { name: Some("createRadialGradient"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanvasGradient"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x0", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y0", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "r0", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x1", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y1", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "r1", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Operation { name: Some("createConicGradient"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanvasGradient"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "startAngle", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Operation { name: Some("createPattern"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CanvasPattern"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("CanvasImageSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "repetition", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }], mixin: Some("CanvasFillStrokeStyles"), ext_attrs: &[] }, + Operation { name: Some("clearRect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasRect"), ext_attrs: &[] }, + Operation { name: Some("fillRect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasRect"), ext_attrs: &[] }, + Operation { name: Some("strokeRect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasRect"), ext_attrs: &[] }, + Operation { name: Some("beginPath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("fill"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("fill"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("stroke"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("stroke"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("clip"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("clip"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("isPointInPath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("isPointInPath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "fillRule", ty: TypeRef { ty: Type::Named("CanvasFillRule"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("nonzero")), ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("isPointInStroke"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("isPointInStroke"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawPath"), ext_attrs: &[] }, + Operation { name: Some("fillText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "maxWidth", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasText"), ext_attrs: &[] }, + Operation { name: Some("strokeText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "maxWidth", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasText"), ext_attrs: &[] }, + Operation { name: Some("measureText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("TextMetrics"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "text", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasText"), ext_attrs: &[] }, + Operation { name: Some("drawImage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("CanvasImageSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawImage"), ext_attrs: &[] }, + Operation { name: Some("drawImage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("CanvasImageSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dw", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dh", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawImage"), ext_attrs: &[] }, + Operation { name: Some("drawImage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("CanvasImageSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sw", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sh", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dw", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dh", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasDrawImage"), ext_attrs: &[] }, + Operation { name: Some("createImageData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "sw", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "sh", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "settings", ty: TypeRef { ty: Type::Named("ImageDataSettings"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("CanvasImageData"), ext_attrs: &[] }, + Operation { name: Some("createImageData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "imageData", ty: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasImageData"), ext_attrs: &[] }, + Operation { name: Some("getImageData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "sx", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "sy", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "sw", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "sh", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "settings", ty: TypeRef { ty: Type::Named("ImageDataSettings"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("CanvasImageData"), ext_attrs: &[] }, + Operation { name: Some("putImageData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "imageData", ty: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dx", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dy", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }], mixin: Some("CanvasImageData"), ext_attrs: &[] }, + Operation { name: Some("putImageData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "imageData", ty: TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "dx", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dy", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dirtyX", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dirtyY", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dirtyWidth", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }, Argument { name: "dirtyHeight", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "EnforceRange", value: ExtValue::None }] }], mixin: Some("CanvasImageData"), ext_attrs: &[] }, + Operation { name: Some("setLineDash"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "segments", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Operation { name: Some("getLineDash"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasPathDrawingStyles"), ext_attrs: &[] }, + Operation { name: Some("closePath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("moveTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("lineTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("quadraticCurveTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "cpx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cpy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("bezierCurveTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "cp1x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cp1y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cp2x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cp2y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("arcTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x1", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y1", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x2", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y2", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radius", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("rect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("roundRect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radii", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("DOMPointInit"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("DOMPointInit"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("arc"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radius", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "startAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "endAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "counterclockwise", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("ellipse"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radiusX", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radiusY", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "rotation", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "startAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "endAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "counterclockwise", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Origin", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Wildcard }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "opaque", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("from"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Named("Origin"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("isSameOrigin"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "other", ty: TypeRef { ty: Type::Named("Origin"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("isSameSite"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "other", ty: TypeRef { ty: Type::Named("Origin"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "PageRevealEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("PageRevealEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "viewTransition", ty: TypeRef { ty: Type::Named("ViewTransition"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "PageSwapEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("PageSwapEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "activation", ty: TypeRef { ty: Type::Named("NavigationActivation"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "viewTransition", ty: TypeRef { ty: Type::Named("ViewTransition"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "PageTransitionEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("PageTransitionEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "persisted", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Path2D", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &["CanvasPath"], + constructors: &[ + Constructor { args: &[Argument { name: "path", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("addPath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "path", ty: TypeRef { ty: Type::Named("Path2D"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "transform", ty: TypeRef { ty: Type::Named("DOMMatrix2DInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("closePath"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("moveTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("lineTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("quadraticCurveTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "cpx", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cpy", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("bezierCurveTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "cp1x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cp1y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cp2x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "cp2y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("arcTo"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x1", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y1", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "x2", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y2", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radius", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("rect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("roundRect"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "w", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "h", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radii", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("DOMPointInit"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("DOMPointInit"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("arc"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radius", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "startAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "endAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "counterclockwise", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + Operation { name: Some("ellipse"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "x", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "y", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radiusX", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "radiusY", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "rotation", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "startAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "endAngle", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "counterclockwise", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: Some("CanvasPath"), ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Plugin", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyUnenumerableNamedProperties", value: ExtValue::None }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "description", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "filename", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("MimeType"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("namedItem"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("MimeType"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "PluginArray", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyUnenumerableNamedProperties", value: ExtValue::None }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("refresh"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("Plugin"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("namedItem"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("Plugin"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "PopStateEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("PopStateEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "state", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "hasUAVisualTransition", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "ProcessingInstruction", + parent: Some("CharacterData"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["LinkStyle"], + constructors: &[ + Constructor { args: &[Argument { name: "target", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "target", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "sheet", ty: TypeRef { ty: Type::Named("CSSStyleSheet"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("LinkStyle"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("hasAttributes"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAttributeNames"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("removeAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("toggleAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "force", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("hasAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "ProgressEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("ProgressEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "lengthComputable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "loaded", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "total", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "PromiseRejectionEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Wildcard }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("PromiseRejectionEventInit"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "promise", ty: TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "reason", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "RadioNodeList", + parent: Some("NodeList"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Range", + parent: Some("NodeRange"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[ + Constant { name: "START_TO_START", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(0), mixin: None, ext_attrs: &[] }, + Constant { name: "START_TO_END", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "END_TO_END", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "END_TO_START", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "commonAncestorContainer", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("setStart"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "offset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setEnd"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "offset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setStartBefore"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setStartAfter"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setEndBefore"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setEndAfter"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("collapse"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "toStart", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("selectNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("selectNodeContents"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("compareBoundaryPoints"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Short), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "how", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sourceRange", ty: TypeRef { ty: Type::Named("Range"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("deleteContents"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("extractContents"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("DocumentFragment"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("cloneContents"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("DocumentFragment"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("insertNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("surroundContents"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "newParent", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("cloneRange"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Range"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("detach"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("isPointInRange"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "offset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("comparePoint"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Short), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "offset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("intersectsNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "node", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: None, kind: OperationKind::Stringifier, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("createContextualFragment"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("DocumentFragment"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "string", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Request", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &["Body"], + constructors: &[ + Constructor { args: &[Argument { name: "input", ty: TypeRef { ty: Type::Named("RequestInfo"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "init", ty: TypeRef { ty: Type::Named("RequestInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "method", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "headers", ty: TypeRef { ty: Type::Named("Headers"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "destination", ty: TypeRef { ty: Type::Named("RequestDestination"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "referrer", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "referrerPolicy", ty: TypeRef { ty: Type::Named("ReferrerPolicy"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "mode", ty: TypeRef { ty: Type::Named("RequestMode"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "credentials", ty: TypeRef { ty: Type::Named("RequestCredentials"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "cache", ty: TypeRef { ty: Type::Named("RequestCache"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "redirect", ty: TypeRef { ty: Type::Named("RequestRedirect"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "integrity", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "keepalive", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "isReloadNavigation", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "isHistoryNavigation", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "signal", ty: TypeRef { ty: Type::Named("AbortSignal"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "duplex", ty: TypeRef { ty: Type::Named("RequestDuplex"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "body", ty: TypeRef { ty: Type::Named("ReadableStream"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("Body"), ext_attrs: &[] }, + Attribute { name: "bodyUsed", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("Body"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("clone"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Request"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("arrayBuffer"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Buffer("ArrayBuffer"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("blob"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("Blob"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("bytes"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Buffer("Uint8Array"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("formData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("FormData"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("json"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("text"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("textStream"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ReadableStream"), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Response", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &["Body"], + constructors: &[ + Constructor { args: &[Argument { name: "body", ty: TypeRef { ty: Type::Named("BodyInit"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "init", ty: TypeRef { ty: Type::Named("ResponseInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "type", ty: TypeRef { ty: Type::Named("ResponseType"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "redirected", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "status", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "ok", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "statusText", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "headers", ty: TypeRef { ty: Type::Named("Headers"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "body", ty: TypeRef { ty: Type::Named("ReadableStream"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("Body"), ext_attrs: &[] }, + Attribute { name: "bodyUsed", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("Body"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("error"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Named("Response"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("redirect"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Named("Response"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "status", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(302)), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("json"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Named("Response"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "init", ty: TypeRef { ty: Type::Named("ResponseInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("clone"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Response"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("arrayBuffer"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Buffer("ArrayBuffer"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("blob"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("Blob"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("bytes"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Buffer("Uint8Array"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("formData"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("FormData"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("json"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("text"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("textStream"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("ReadableStream"), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("Body"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Sanitizer", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "configuration", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SanitizerConfig"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerPresets"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("default")), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("get"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("SanitizerConfig"), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("allowElement"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "element", ty: TypeRef { ty: Type::Named("SanitizerElementWithAttributes"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("removeElement"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "element", ty: TypeRef { ty: Type::Named("SanitizerElement"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("replaceElementWithChildren"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "element", ty: TypeRef { ty: Type::Named("SanitizerElement"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("allowProcessingInstruction"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "pi", ty: TypeRef { ty: Type::Named("SanitizerPI"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("removeProcessingInstruction"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "pi", ty: TypeRef { ty: Type::Named("SanitizerPI"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("allowAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "attribute", ty: TypeRef { ty: Type::Named("SanitizerAttribute"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("removeAttribute"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "attribute", ty: TypeRef { ty: Type::Named("SanitizerAttribute"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setComments"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "allow", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setDataAttributes"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "allow", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setJavascriptURLs"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "allow", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("removeUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "ShadowRoot", + parent: Some("DocumentFragment"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["DocumentOrShadowRoot"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "mode", ty: TypeRef { ty: Type::Named("ShadowRootMode"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "delegatesFocus", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "serializable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "slotAssignment", ty: TypeRef { ty: Type::Named("SlotAssignmentMode"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "clonable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "host", ty: TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onslotchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "innerHTML", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }]), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Attribute { name: "customElementRegistry", ty: TypeRef { ty: Type::Named("CustomElementRegistry"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("DocumentOrShadowRoot"), ext_attrs: &[] }, + Attribute { name: "styleSheets", ty: TypeRef { ty: Type::Named("StyleSheetList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("DocumentOrShadowRoot"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "adoptedStyleSheets", ty: TypeRef { ty: Type::ObservableArray(&TypeRef { ty: Type::Named("CSSStyleSheet"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("DocumentOrShadowRoot"), ext_attrs: &[] }, + Attribute { name: "activeElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("DocumentOrShadowRoot"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("setHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("appendHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("prependHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("streamHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamAppendHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamPrependHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("SetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("setHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("appendHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("prependHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "html", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedHTML"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("streamHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }, ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamAppendHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("streamPrependHTMLUnsafe"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WritableStream"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("SetHTMLUnsafeOptions"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedHTMLParserOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("getHTML"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "options", ty: TypeRef { ty: Type::Named("GetHTMLOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "SharedWorker", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["AbstractWorker"], + constructors: &[ + Constructor { args: &[Argument { name: "scriptURL", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedScriptURL"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SharedWorkerOptions"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "port", ty: TypeRef { ty: Type::Named("MessagePort"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("AbstractWorker"), ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "SharedWorkerGlobalScope", + parent: Some("WorkerGlobalScope"), + callback: false, + ext_attrs: &[ExtAttr { name: "Global", value: ExtValue::IdentList(&["Worker", "SharedWorker"]) }, ExtAttr { name: "Exposed", value: ExtValue::Ident("SharedWorker") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "onconnect", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("close"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "StaticRange", + parent: Some("NodeRange"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "init", ty: TypeRef { ty: Type::Named("StaticRangeInit"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Storage", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("key"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getItem"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setItem"), kind: OperationKind::Setter, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("removeItem"), kind: OperationKind::Deleter, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("clear"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "StorageEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("StorageEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "oldValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "newValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "storageArea", ty: TypeRef { ty: Type::Named("Storage"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("initStorageEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "bubbles", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "cancelable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "key", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "oldValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "newValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }, Argument { name: "storageArea", ty: TypeRef { ty: Type::Named("Storage"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "StorageManager", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "SecureContext", value: ExtValue::None }, ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("persisted"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("persist"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + Operation { name: Some("estimate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("StorageEstimate"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "StyleSheet", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "type", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "href", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "ownerNode", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("ProcessingInstruction"), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "parentStyleSheet", ty: TypeRef { ty: Type::Named("CSSStyleSheet"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "title", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "media", ty: TypeRef { ty: Type::Named("MediaList"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "PutForwards", value: ExtValue::Ident("mediaText") }] }, + Attribute { name: "disabled", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "StyleSheetList", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("item"), kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("CSSStyleSheet"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "SubmitEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("SubmitEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "submitter", ty: TypeRef { ty: Type::Named("HTMLElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Text", + parent: Some("CharacterData"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["Slottable"], + constructors: &[ + Constructor { args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "wholeText", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "assignedSlot", ty: TypeRef { ty: Type::Named("HTMLSlotElement"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("Slottable"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("splitText"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Text"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "offset", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "TextEvent", + parent: Some("UIEvent"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("initTextEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "bubbles", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "cancelable", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "view", ty: TypeRef { ty: Type::Named("Window"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("undefined")), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "TextMetrics", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "Worker"]) }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "width", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "actualBoundingBoxLeft", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "actualBoundingBoxRight", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "fontBoundingBoxAscent", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "fontBoundingBoxDescent", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "actualBoundingBoxAscent", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "actualBoundingBoxDescent", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "emHeightAscent", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "emHeightDescent", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "hangingBaseline", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "alphabeticBaseline", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "ideographicBaseline", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "TextTrack", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "kind", ty: TypeRef { ty: Type::Named("TextTrackKind"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "label", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "language", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "inBandMetadataTrackDispatchType", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "mode", ty: TypeRef { ty: Type::Named("TextTrackMode"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "cues", ty: TypeRef { ty: Type::Named("TextTrackCueList"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "activeCues", ty: TypeRef { ty: Type::Named("TextTrackCueList"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "oncuechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("addCue"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "cue", ty: TypeRef { ty: Type::Named("TextTrackCue"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("removeCue"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "cue", ty: TypeRef { ty: Type::Named("TextTrackCue"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "TextTrackCue", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "track", ty: TypeRef { ty: Type::Named("TextTrack"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "startTime", ty: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "endTime", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "pauseOnExit", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onenter", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onexit", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "TextTrackCueList", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("TextTrackCue"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getCueById"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("TextTrackCue"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "TextTrackList", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onaddtrack", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onremovetrack", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("TextTrack"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getTrackById"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("TextTrack"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "TimeRanges", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("start"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("end"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Double), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "ToggleEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("ToggleEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "oldState", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "newState", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "source", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "TrackEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("TrackEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "track", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("VideoTrack"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("AudioTrack"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TextTrack"), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "TreeWalker", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "root", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "whatToShow", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "filter", ty: TypeRef { ty: Type::Named("NodeFilter"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "currentNode", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("parentNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("firstChild"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("lastChild"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("previousSibling"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("nextSibling"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("previousNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("nextNode"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "UIEvent", + parent: Some("Event"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "eventInitDict", ty: TypeRef { ty: Type::Named("UIEventInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "view", ty: TypeRef { ty: Type::Named("Window"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "detail", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "which", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("initUIEvent"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "typeArg", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "bubblesArg", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "cancelableArg", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Bool(false)), ext_attrs: &[] }, Argument { name: "viewArg", ty: TypeRef { ty: Type::Named("Window"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "detailArg", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "URL", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Wildcard }, ExtAttr { name: "LegacyWindowAlias", value: ExtValue::Ident("webkitURL") }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "base", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "href", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: true, mixin: None, ext_attrs: &[] }, + Attribute { name: "origin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "protocol", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "username", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "password", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "host", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "hostname", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "port", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "pathname", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "search", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "searchParams", ty: TypeRef { ty: Type::Named("URLSearchParams"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "hash", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("parse"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Named("URL"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "base", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("canParse"), kind: OperationKind::Static, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "base", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("toJSON"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "URLSearchParams", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Wildcard }], + includes: &[], + constructors: &[ + Constructor { args: &[Argument { name: "init", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Record(&TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, &TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "size", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("append"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("delete"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("get"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAll"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("has"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("set"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("sort"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: None, kind: OperationKind::Stringifier, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: Some(Iterable { is_async: false, key: Some(TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }), value: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, args: &[], ext_attrs: &[] }), + collection: None, + }, + Interface { + name: "UserActivation", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "hasBeenActive", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "isActive", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "ValidityState", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "valueMissing", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "typeMismatch", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "patternMismatch", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "tooLong", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "tooShort", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "rangeUnderflow", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "rangeOverflow", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "stepMismatch", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "badInput", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "customError", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "valid", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "VideoTrack", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "kind", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "label", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "language", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "selected", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "VideoTrackList", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "selectedIndex", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onaddtrack", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onremovetrack", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Named("VideoTrack"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getTrackById"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("VideoTrack"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "id", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "VisibilityStateEntry", + parent: Some("PerformanceEntry"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window"]) }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "entryType", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "startTime", ty: TypeRef { ty: Type::Named("DOMHighResTimeStamp"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "duration", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "Window", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Global", value: ExtValue::Ident("Window") }, ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "LegacyUnenumerableNamedProperties", value: ExtValue::None }], + includes: &["GlobalEventHandlers", "WindowEventHandlers", "WindowOrWorkerGlobalScope", "AnimationFrameProvider", "WindowSessionStorage", "WindowLocalStorage"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "window", ty: TypeRef { ty: Type::Named("WindowProxy"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "self", ty: TypeRef { ty: Type::Named("WindowProxy"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "document", ty: TypeRef { ty: Type::Named("Document"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "location", ty: TypeRef { ty: Type::Named("Location"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "PutForwards", value: ExtValue::Ident("href") }, ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "history", ty: TypeRef { ty: Type::Named("History"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "navigation", ty: TypeRef { ty: Type::Named("Navigation"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "customElements", ty: TypeRef { ty: Type::Named("CustomElementRegistry"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "locationbar", ty: TypeRef { ty: Type::Named("BarProp"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "menubar", ty: TypeRef { ty: Type::Named("BarProp"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "personalbar", ty: TypeRef { ty: Type::Named("BarProp"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "scrollbars", ty: TypeRef { ty: Type::Named("BarProp"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "statusbar", ty: TypeRef { ty: Type::Named("BarProp"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "toolbar", ty: TypeRef { ty: Type::Named("BarProp"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "status", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "closed", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "frames", ty: TypeRef { ty: Type::Named("WindowProxy"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "length", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "top", ty: TypeRef { ty: Type::Named("WindowProxy"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "LegacyUnforgeable", value: ExtValue::None }] }, + Attribute { name: "opener", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "parent", ty: TypeRef { ty: Type::Named("WindowProxy"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "frameElement", ty: TypeRef { ty: Type::Named("Element"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "navigator", ty: TypeRef { ty: Type::Named("Navigator"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "clientInformation", ty: TypeRef { ty: Type::Named("Navigator"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "originAgentCluster", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "event", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Event"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "external", ty: TypeRef { ty: Type::Named("External"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }, ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "onabort", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onauxclick", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforeinput", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforematch", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforetoggle", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onblur", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncancel", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncanplay", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncanplaythrough", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onclick", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onclose", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncommand", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncontextlost", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncontextmenu", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncontextrestored", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncopy", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncuechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oncut", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondblclick", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondrag", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragenter", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragleave", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragover", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondragstart", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondrop", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ondurationchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onemptied", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onended", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onerror", ty: TypeRef { ty: Type::Named("OnErrorEventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onfocus", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onformdata", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oninput", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "oninvalid", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onkeydown", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onkeypress", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onkeyup", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onload", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onloadeddata", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onloadedmetadata", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onloadstart", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmousedown", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseenter", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[ExtAttr { name: "LegacyLenientThis", value: ExtValue::None }] }, + Attribute { name: "onmouseleave", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[ExtAttr { name: "LegacyLenientThis", value: ExtValue::None }] }, + Attribute { name: "onmousemove", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseout", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseover", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmouseup", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpaste", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpause", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onplay", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onplaying", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onprogress", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onratechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onreset", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onresize", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onscroll", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onscrollend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onsecuritypolicyviolation", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onseeked", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onseeking", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onselect", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onslotchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onstalled", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onsubmit", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onsuspend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ontimeupdate", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ontoggle", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onvolumechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwaiting", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkitanimationend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkitanimationiteration", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkitanimationstart", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwebkittransitionend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onwheel", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("GlobalEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onafterprint", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforeprint", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onbeforeunload", ty: TypeRef { ty: Type::Named("OnBeforeUnloadEventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onhashchange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onlanguagechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmessage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onmessageerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onoffline", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "ononline", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpagehide", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpagereveal", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpageshow", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpageswap", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onpopstate", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onrejectionhandled", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onstorage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onunhandledrejection", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "onunload", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowEventHandlers"), ext_attrs: &[] }, + Attribute { name: "origin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "isSecureContext", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Attribute { name: "crossOriginIsolated", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Attribute { name: "sessionStorage", ty: TypeRef { ty: Type::Named("Storage"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowSessionStorage"), ext_attrs: &[] }, + Attribute { name: "localStorage", ty: TypeRef { ty: Type::Named("Storage"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowLocalStorage"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("close"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("stop"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("focus"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("blur"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("open"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("WindowProxy"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }, Argument { name: "target", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("_blank")), ext_attrs: &[] }, Argument { name: "features", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: None, kind: OperationKind::Getter, ret: TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("alert"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("alert"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("confirm"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("prompt"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }, Argument { name: "default", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Str("")), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("print"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("postMessage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "targetOrigin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "transfer", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptySequence), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("postMessage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("WindowPostMessageOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getComputedStyle"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CSSStyleProperties"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "elt", ty: TypeRef { ty: Type::Named("Element"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "pseudoElt", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("fetchLater"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("FetchLaterResult"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "input", ty: TypeRef { ty: Type::Named("RequestInfo"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "init", ty: TypeRef { ty: Type::Named("DeferredRequestInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }, ExtAttr { name: "SecureContext", value: ExtValue::None }] }, + Operation { name: Some("captureEvents"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("releaseEvents"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportError"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "e", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("btoa"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("atob"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("setTimeout"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "handler", ty: TypeRef { ty: Type::Named("TimerHandler"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "timeout", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, Argument { name: "arguments", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("clearTimeout"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "id", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("setInterval"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "handler", ty: TypeRef { ty: Type::Named("TimerHandler"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "timeout", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, Argument { name: "arguments", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("clearInterval"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "id", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("queueMicrotask"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "callback", ty: TypeRef { ty: Type::Named("VoidFunction"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("createImageBitmap"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("ImageBitmap"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("ImageBitmapSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("ImageBitmapOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("createImageBitmap"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("ImageBitmap"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("ImageBitmapSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sx", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sy", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sw", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sh", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("ImageBitmapOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("structuredClone"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("StructuredSerializeOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("fetch"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("Response"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "input", ty: TypeRef { ty: Type::Named("RequestInfo"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "init", ty: TypeRef { ty: Type::Named("RequestInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("requestAnimationFrame"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "callback", ty: TypeRef { ty: Type::Named("FrameRequestCallback"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("AnimationFrameProvider"), ext_attrs: &[] }, + Operation { name: Some("cancelAnimationFrame"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "handle", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("AnimationFrameProvider"), ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Worker", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "DedicatedWorker", "SharedWorker"]) }], + includes: &["AbstractWorker", "MessageEventTarget"], + constructors: &[ + Constructor { args: &[Argument { name: "scriptURL", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedScriptURL"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("WorkerOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[ + Attribute { name: "onerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("AbstractWorker"), ext_attrs: &[] }, + Attribute { name: "onmessage", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("MessageEventTarget"), ext_attrs: &[] }, + Attribute { name: "onmessageerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: Some("MessageEventTarget"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("terminate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("postMessage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "transfer", ty: TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::Object), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("postMessage"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "message", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("StructuredSerializeOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "WorkerGlobalScope", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Worker") }], + includes: &["WindowOrWorkerGlobalScope"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "self", ty: TypeRef { ty: Type::Named("WorkerGlobalScope"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "location", ty: TypeRef { ty: Type::Named("WorkerLocation"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "navigator", ty: TypeRef { ty: Type::Named("WorkerNavigator"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onerror", ty: TypeRef { ty: Type::Named("OnErrorEventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onlanguagechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onoffline", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "ononline", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onrejectionhandled", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onunhandledrejection", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "origin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[ExtAttr { name: "Replaceable", value: ExtValue::None }] }, + Attribute { name: "isSecureContext", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Attribute { name: "crossOriginIsolated", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("importScripts"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "urls", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("TrustedScriptURL"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reportError"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "e", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("btoa"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("atob"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "data", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("setTimeout"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "handler", ty: TypeRef { ty: Type::Named("TimerHandler"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "timeout", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, Argument { name: "arguments", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("clearTimeout"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "id", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("setInterval"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "handler", ty: TypeRef { ty: Type::Named("TimerHandler"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "timeout", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, Argument { name: "arguments", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: true, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("clearInterval"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "id", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("queueMicrotask"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "callback", ty: TypeRef { ty: Type::Named("VoidFunction"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("createImageBitmap"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("ImageBitmap"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("ImageBitmapSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("ImageBitmapOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("createImageBitmap"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("ImageBitmap"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "image", ty: TypeRef { ty: Type::Named("ImageBitmapSource"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sx", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sy", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sw", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "sh", ty: TypeRef { ty: Type::Simple(Simple::Long), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("ImageBitmapOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("structuredClone"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("StructuredSerializeOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[] }, + Operation { name: Some("fetch"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Named("Response"), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "input", ty: TypeRef { ty: Type::Named("RequestInfo"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "init", ty: TypeRef { ty: Type::Named("RequestInit"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: Some("WindowOrWorkerGlobalScope"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "WorkerLocation", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Worker") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "href", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: true, mixin: None, ext_attrs: &[] }, + Attribute { name: "origin", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "protocol", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "host", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "hostname", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "port", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "pathname", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "search", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "hash", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "WorkerNavigator", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Worker") }], + includes: &["NavigatorID", "NavigatorLanguage", "NavigatorOnLine", "NavigatorConcurrentHardware", "NavigatorStorage"], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "appCodeName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "appName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "appVersion", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "platform", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "product", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "productSub", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + Attribute { name: "userAgent", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[] }, + Attribute { name: "vendor", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + Attribute { name: "vendorSub", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + Attribute { name: "oscpu", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorID"), ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + Attribute { name: "language", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorLanguage"), ext_attrs: &[] }, + Attribute { name: "languages", ty: TypeRef { ty: Type::FrozenArray(&TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorLanguage"), ext_attrs: &[] }, + Attribute { name: "onLine", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorOnLine"), ext_attrs: &[] }, + Attribute { name: "hardwareConcurrency", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLongLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorConcurrentHardware"), ext_attrs: &[] }, + Attribute { name: "storage", ty: TypeRef { ty: Type::Named("StorageManager"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: Some("NavigatorStorage"), ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }, ExtAttr { name: "SecureContext", value: ExtValue::None }] }, + ], + operations: &[ + Operation { name: Some("taintEnabled"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, args: &[], mixin: Some("NavigatorID"), ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "Worklet", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }, ExtAttr { name: "SecureContext", value: ExtValue::None }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("addModule"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Promise(&TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "moduleURL", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "options", ty: TypeRef { ty: Type::Named("WorkletOptions"), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::EmptyDictionary), ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "WorkletGlobalScope", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Worklet") }, ExtAttr { name: "SecureContext", value: ExtValue::None }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "XMLDocument", + parent: Some("Document"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "XMLHttpRequest", + parent: Some("XMLHttpRequestEventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "DedicatedWorker", "SharedWorker"]) }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[ + Constant { name: "UNSENT", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(0), mixin: None, ext_attrs: &[] }, + Constant { name: "OPENED", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "HEADERS_RECEIVED", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "LOADING", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + Constant { name: "DONE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(4), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "onreadystatechange", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "readyState", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "timeout", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "withCredentials", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "upload", ty: TypeRef { ty: Type::Named("XMLHttpRequestUpload"), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "SameObject", value: ExtValue::None }] }, + Attribute { name: "responseURL", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "status", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "statusText", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "responseType", ty: TypeRef { ty: Type::Named("XMLHttpRequestResponseType"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "response", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "responseText", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "responseXML", ty: TypeRef { ty: Type::Named("Document"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }] }, + ], + operations: &[ + Operation { name: Some("open"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "method", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("open"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "method", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "url", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "async", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "username", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "password", ty: TypeRef { ty: Type::Simple(Simple::UsvString), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("setRequestHeader"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("send"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "body", ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Document"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("XMLHttpRequestBodyInit"), nullable: false, ext_attrs: &[] }]), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("abort"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getResponseHeader"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "name", ty: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getAllResponseHeaders"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("overrideMimeType"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "mime", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "XMLHttpRequestEventTarget", + parent: Some("EventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "DedicatedWorker", "SharedWorker"]) }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[ + Attribute { name: "onloadstart", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onprogress", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onabort", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onerror", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onload", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "ontimeout", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "onloadend", ty: TypeRef { ty: Type::Named("EventHandler"), nullable: false, ext_attrs: &[] }, readonly: false, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "XMLHttpRequestUpload", + parent: Some("XMLHttpRequestEventTarget"), + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::IdentList(&["Window", "DedicatedWorker", "SharedWorker"]) }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[], + iterable: None, + collection: None, + }, + Interface { + name: "XMLSerializer", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("serializeToString"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "root", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "XPathEvaluator", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &["XPathEvaluatorBase"], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("createExpression"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("XPathExpression"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "expression", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "resolver", ty: TypeRef { ty: Type::Named("XPathNSResolver"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: Some("XPathEvaluatorBase"), ext_attrs: &[ExtAttr { name: "NewObject", value: ExtValue::None }] }, + Operation { name: Some("createNSResolver"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "nodeResolver", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: Some("XPathEvaluatorBase"), ext_attrs: &[] }, + Operation { name: Some("evaluate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("XPathResult"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "expression", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "contextNode", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "resolver", ty: TypeRef { ty: Type::Named("XPathNSResolver"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }, Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, Argument { name: "result", ty: TypeRef { ty: Type::Named("XPathResult"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: Some("XPathEvaluatorBase"), ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "XPathExpression", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("evaluate"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("XPathResult"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "contextNode", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "type", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Integer(0)), ext_attrs: &[] }, Argument { name: "result", ty: TypeRef { ty: Type::Named("XPathResult"), nullable: true, ext_attrs: &[] }, optional: true, variadic: false, default: Some(Value::Null), ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "XPathNSResolver", + parent: None, + callback: true, + ext_attrs: &[], + includes: &[], + constructors: &[], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("lookupNamespaceURI"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "prefix", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: true, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "XPathResult", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[], + constants: &[ + Constant { name: "ANY_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(0), mixin: None, ext_attrs: &[] }, + Constant { name: "NUMBER_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(1), mixin: None, ext_attrs: &[] }, + Constant { name: "STRING_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(2), mixin: None, ext_attrs: &[] }, + Constant { name: "BOOLEAN_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(3), mixin: None, ext_attrs: &[] }, + Constant { name: "UNORDERED_NODE_ITERATOR_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(4), mixin: None, ext_attrs: &[] }, + Constant { name: "ORDERED_NODE_ITERATOR_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(5), mixin: None, ext_attrs: &[] }, + Constant { name: "UNORDERED_NODE_SNAPSHOT_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(6), mixin: None, ext_attrs: &[] }, + Constant { name: "ORDERED_NODE_SNAPSHOT_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(7), mixin: None, ext_attrs: &[] }, + Constant { name: "ANY_UNORDERED_NODE_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(8), mixin: None, ext_attrs: &[] }, + Constant { name: "FIRST_ORDERED_NODE_TYPE", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, value: Value::Integer(9), mixin: None, ext_attrs: &[] }, + ], + attributes: &[ + Attribute { name: "resultType", ty: TypeRef { ty: Type::Simple(Simple::UnsignedShort), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "numberValue", ty: TypeRef { ty: Type::Simple(Simple::UnrestrictedDouble), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "stringValue", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "booleanValue", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "singleNodeValue", ty: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "invalidIteratorState", ty: TypeRef { ty: Type::Simple(Simple::Boolean), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + Attribute { name: "snapshotLength", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, readonly: true, inherit: false, is_static: false, stringifier: false, mixin: None, ext_attrs: &[] }, + ], + operations: &[ + Operation { name: Some("iterateNext"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("snapshotItem"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Node"), nullable: true, ext_attrs: &[] }, args: &[Argument { name: "index", ty: TypeRef { ty: Type::Simple(Simple::UnsignedLong), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, + Interface { + name: "XSLTProcessor", + parent: None, + callback: false, + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + includes: &[], + constructors: &[ + Constructor { args: &[], ext_attrs: &[] }, + ], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("importStylesheet"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "style", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("transformToFragment"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("DocumentFragment"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "source", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "output", ty: TypeRef { ty: Type::Named("Document"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("transformToDocument"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("Document"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "source", ty: TypeRef { ty: Type::Named("Node"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[ExtAttr { name: "CEReactions", value: ExtValue::None }] }, + Operation { name: Some("setParameter"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespaceURI", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }, Argument { name: "value", ty: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("getParameter"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Any), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespaceURI", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("removeParameter"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "namespaceURI", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[ExtAttr { name: "LegacyNullToEmptyString", value: ExtValue::None }] }, Argument { name: "localName", ty: TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + Operation { name: Some("clearParameters"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + Operation { name: Some("reset"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Simple(Simple::Undefined), nullable: false, ext_attrs: &[] }, args: &[], mixin: None, ext_attrs: &[] }, + ], + iterable: None, + collection: None, + }, +]; diff --git a/crates/clazel-webidl/src/generated/mod.rs b/crates/clazel-webidl/src/generated/mod.rs new file mode 100644 index 00000000..790064dd --- /dev/null +++ b/crates/clazel-webidl/src/generated/mod.rs @@ -0,0 +1,87 @@ +//! The resolved interface model of the vendored WebIDL (item 7.12): plain data of +//! the types in [`crate::model`], one table per kind of definition, sorted by name. +//! +// @generated by `cargo xtask bindings` (xtask/src/bindings/) from +// crates/clazel-webidl/tests/data/webref-idl/ (the webref commit and the +// license are in SOURCE.md there). Do not edit: `cargo xtask check` fails if +// this differs from what the generator produces. +// +// What the generator derives (xtask/src/bindings/resolve.rs has the rules): +// - Every .idl file of that directory is parsed with our own parser, which +// follows the grammar of WebIDL §2; the definitions of all files are +// merged into one model. +// - Partial interfaces, dictionaries and namespaces are appended to their +// target, in file order (files sorted by name), then source order. +// - `A includes M;` appends M's members (and its partials') to A, each +// marked with the mixin's name. +// - `Exposed` and `SecureContext` written on a partial interface or on a +// mixin are copied onto the members it adds, unless a member has its own. +// - Definitions are sorted by name. A mixin has no table of its own: its +// members are in its includers. +// - A name that no vendored file defines is accepted only if it is in +// xtask/src/bindings/resolve.rs's EXTERNAL list; those are in EXTERNAL +// below, with no definition. + +use crate::model::{External, ForeignIncludes}; + +mod callbacks; +pub use callbacks::CALLBACKS; +mod dictionaries; +pub use dictionaries::DICTIONARIES; +mod enums; +pub use enums::ENUMS; +mod interfaces; +pub use interfaces::INTERFACES; +mod namespaces; +pub use namespaces::NAMESPACES; +mod typedefs; +pub use typedefs::TYPEDEFS; + +/// Names the IDL refers to that no vendored file defines, with the standard that does. +/// They have no entry in any table. Only the names the files use are listed. +pub static EXTERNAL: &[External] = &[ + External { name: "ARIAMixin", defined_by: "WAI-ARIA (an interface mixin)" }, + External { name: "Blob", defined_by: "File API" }, + External { name: "BufferSource", defined_by: "WebIDL" }, + External { name: "CSSMarginDescriptors", defined_by: "CSS Paged Media" }, + External { name: "CSSOMString", defined_by: "CSSOM (an implementation-defined string type: DOMString or USVString)" }, + External { name: "DOMHighResTimeStamp", defined_by: "High Resolution Time" }, + External { name: "DOMMatrix", defined_by: "Geometry Interfaces" }, + External { name: "DOMMatrix2DInit", defined_by: "Geometry Interfaces" }, + External { name: "DOMPointInit", defined_by: "Geometry Interfaces" }, + External { name: "File", defined_by: "File API" }, + External { name: "FileList", defined_by: "File API" }, + External { name: "Function", defined_by: "WebIDL" }, + External { name: "GPUCanvasContext", defined_by: "WebGPU" }, + External { name: "MathMLElement", defined_by: "MathML Core" }, + External { name: "MediaSource", defined_by: "Media Source Extensions" }, + External { name: "MediaStream", defined_by: "Media Capture and Streams" }, + External { name: "MouseEvent", defined_by: "UI Events (not in the vendored `uievents.idl`)" }, + External { name: "MouseEventInit", defined_by: "UI Events (not in the vendored `uievents.idl`)" }, + External { name: "PerformanceEntry", defined_by: "Performance Timeline" }, + External { name: "ReadableStream", defined_by: "Streams" }, + External { name: "ReferrerPolicy", defined_by: "Referrer Policy" }, + External { name: "SVGElement", defined_by: "SVG 2" }, + External { name: "SVGImageElement", defined_by: "SVG 2" }, + External { name: "SVGScriptElement", defined_by: "SVG 2" }, + External { name: "ServiceWorker", defined_by: "Service Workers" }, + External { name: "TrustedHTML", defined_by: "Trusted Types" }, + External { name: "TrustedHTMLParserOptions", defined_by: "Trusted Types" }, + External { name: "TrustedScript", defined_by: "Trusted Types" }, + External { name: "TrustedScriptURL", defined_by: "Trusted Types" }, + External { name: "TrustedType", defined_by: "Trusted Types" }, + External { name: "VideoFrame", defined_by: "WebCodecs" }, + External { name: "ViewTransition", defined_by: "CSS View Transitions" }, + External { name: "VoidFunction", defined_by: "WebIDL" }, + External { name: "WebGL2RenderingContext", defined_by: "WebGL" }, + External { name: "WebGLRenderingContext", defined_by: "WebGL" }, + External { name: "WindowProxy", defined_by: "HTML (WindowProxy is defined in prose, not in `html.idl`)" }, + External { name: "WritableStream", defined_by: "Streams" }, +]; + +/// `includes` statements whose interface is in [`EXTERNAL`]; the interface is not in +/// [`INTERFACES`], so its members from these mixins are not in the model. +pub static FOREIGN_INCLUDES: &[ForeignIncludes] = &[ + ForeignIncludes { interface: "SVGElement", mixin: "ElementCSSInlineStyle" }, + ForeignIncludes { interface: "MathMLElement", mixin: "ElementCSSInlineStyle" }, +]; diff --git a/crates/clazel-webidl/src/generated/namespaces.rs b/crates/clazel-webidl/src/generated/namespaces.rs new file mode 100644 index 00000000..69a0140c --- /dev/null +++ b/crates/clazel-webidl/src/generated/namespaces.rs @@ -0,0 +1,37 @@ +// @generated by `cargo xtask bindings` (xtask/src/bindings/) from +// crates/clazel-webidl/tests/data/webref-idl/ (the webref commit and the +// license are in SOURCE.md there). Do not edit: `cargo xtask check` fails if +// this differs from what the generator produces. +// +// What the generator derives (xtask/src/bindings/resolve.rs has the rules): +// - Every .idl file of that directory is parsed with our own parser, which +// follows the grammar of WebIDL §2; the definitions of all files are +// merged into one model. +// - Partial interfaces, dictionaries and namespaces are appended to their +// target, in file order (files sorted by name), then source order. +// - `A includes M;` appends M's members (and its partials') to A, each +// marked with the mixin's name. +// - `Exposed` and `SecureContext` written on a partial interface or on a +// mixin are copied onto the members it adds, unless a member has its own. +// - Definitions are sorted by name. A mixin has no table of its own: its +// members are in its includers. +// - A name that no vendored file defines is accepted only if it is in +// xtask/src/bindings/resolve.rs's EXTERNAL list; those are in EXTERNAL +// below, with no definition. + +//! Namespaces, sorted by name. + +use crate::model::*; + +/// Namespaces, sorted by name. +pub static NAMESPACES: &[Namespace] = &[ + Namespace { + name: "CSS", + ext_attrs: &[ExtAttr { name: "Exposed", value: ExtValue::Ident("Window") }], + constants: &[], + attributes: &[], + operations: &[ + Operation { name: Some("escape"), kind: OperationKind::Regular, ret: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, args: &[Argument { name: "ident", ty: TypeRef { ty: Type::Named("CSSOMString"), nullable: false, ext_attrs: &[] }, optional: false, variadic: false, default: None, ext_attrs: &[] }], mixin: None, ext_attrs: &[] }, + ], + }, +]; diff --git a/crates/clazel-webidl/src/generated/typedefs.rs b/crates/clazel-webidl/src/generated/typedefs.rs new file mode 100644 index 00000000..296f2c22 --- /dev/null +++ b/crates/clazel-webidl/src/generated/typedefs.rs @@ -0,0 +1,50 @@ +// @generated by `cargo xtask bindings` (xtask/src/bindings/) from +// crates/clazel-webidl/tests/data/webref-idl/ (the webref commit and the +// license are in SOURCE.md there). Do not edit: `cargo xtask check` fails if +// this differs from what the generator produces. +// +// What the generator derives (xtask/src/bindings/resolve.rs has the rules): +// - Every .idl file of that directory is parsed with our own parser, which +// follows the grammar of WebIDL §2; the definitions of all files are +// merged into one model. +// - Partial interfaces, dictionaries and namespaces are appended to their +// target, in file order (files sorted by name), then source order. +// - `A includes M;` appends M's members (and its partials') to A, each +// marked with the mixin's name. +// - `Exposed` and `SecureContext` written on a partial interface or on a +// mixin are copied onto the members it adds, unless a member has its own. +// - Definitions are sorted by name. A mixin has no table of its own: its +// members are in its includers. +// - A name that no vendored file defines is accepted only if it is in +// xtask/src/bindings/resolve.rs's EXTERNAL list; those are in EXTERNAL +// below, with no definition. + +//! Typedefs, sorted by name. + +use crate::model::*; + +/// Typedefs, sorted by name. +pub static TYPEDEFS: &[Typedef] = &[ + Typedef { name: "BodyInit", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("ReadableStream"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("XMLHttpRequestBodyInit"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "CanvasImageSource", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("HTMLOrSVGImageElement"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("HTMLVideoElement"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("HTMLCanvasElement"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("ImageBitmap"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("OffscreenCanvas"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("VideoFrame"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "EventHandler", ext_attrs: &[], ty: TypeRef { ty: Type::Named("EventHandlerNonNull"), nullable: true, ext_attrs: &[] } }, + Typedef { name: "FormDataEntryValue", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("File"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "HTMLOrSVGImageElement", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("HTMLImageElement"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SVGImageElement"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "HTMLOrSVGScriptElement", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("HTMLScriptElement"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SVGScriptElement"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "HeadersInit", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Sequence(&TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Record(&TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }, &TypeRef { ty: Type::Simple(Simple::ByteString), nullable: false, ext_attrs: &[] }), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "ImageBitmapSource", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("CanvasImageSource"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("Blob"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("ImageData"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "ImageDataArray", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Buffer("Uint8ClampedArray"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Buffer("Float16Array"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "MediaProvider", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("MediaStream"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("MediaSource"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("Blob"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "MessageEventSource", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("WindowProxy"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("MessagePort"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("ServiceWorker"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "OffscreenRenderingContext", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("OffscreenCanvasRenderingContext2D"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("ImageBitmapRenderingContext"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("WebGLRenderingContext"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("WebGL2RenderingContext"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("GPUCanvasContext"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "OnBeforeUnloadEventHandler", ext_attrs: &[], ty: TypeRef { ty: Type::Named("OnBeforeUnloadEventHandlerNonNull"), nullable: true, ext_attrs: &[] } }, + Typedef { name: "OnErrorEventHandler", ext_attrs: &[], ty: TypeRef { ty: Type::Named("OnErrorEventHandlerNonNull"), nullable: true, ext_attrs: &[] } }, + Typedef { name: "RenderingContext", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("CanvasRenderingContext2D"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("ImageBitmapRenderingContext"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("WebGLRenderingContext"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("WebGL2RenderingContext"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("GPUCanvasContext"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "RequestInfo", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Request"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "SanitizerAttribute", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerAttributeNamespace"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "SanitizerElement", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerElementNamespace"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "SanitizerElementWithAttributes", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerElementNamespaceWithAttributes"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "SanitizerPI", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("SanitizerProcessingInstruction"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "TimerHandler", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Simple(Simple::DomString), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("Function"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("TrustedScript"), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, + Typedef { name: "XMLHttpRequestBodyInit", ext_attrs: &[], ty: TypeRef { ty: Type::Union(&[TypeRef { ty: Type::Named("Blob"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("BufferSource"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("FormData"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Named("URLSearchParams"), nullable: false, ext_attrs: &[] }, TypeRef { ty: Type::Simple(Simple::UsvString), nullable: false, ext_attrs: &[] }]), nullable: false, ext_attrs: &[] } }, +]; diff --git a/crates/clazel-webidl/src/lib.rs b/crates/clazel-webidl/src/lib.rs index 26f6fd33..92ddba57 100644 --- a/crates/clazel-webidl/src/lib.rs +++ b/crates/clazel-webidl/src/lib.rs @@ -1,5 +1,19 @@ -//! WebIDL bindings (phase-7.md item 7.12). +//! WebIDL bindings (phase-7.md item 7.12), first slice: the interface model. //! -//! Empty: item 7.1 vendors the IDL files the generator (`cargo xtask -//! bindings`, item 7.12) will read. The generated bindings, the WebIDL -//! conversions and `DOMException` arrive with items 7.12 and 7.13. +//! [`generated`] holds the resolved model of the vendored IDL (the DOM, HTML, +//! Fetch, XHR, URL and Storage standards, UI Events and CSSOM, in +//! `tests/data/webref-idl/`) as plain data of the types in [`model`]: +//! interfaces with their inheritance, members, argument and return types and +//! extended attributes, namespaces, dictionaries with their members and +//! defaults, enums, typedefs and callbacks. `cargo xtask bindings` writes it +//! with our own IDL parser (`xtask/src/bindings/`), and `cargo xtask check` +//! fails if it is stale. +//! +//! Not here yet: the JS-engine glue (conversions, overload resolution, +//! wrappers, `DOMException`). It needs `clazel-js`'s embedding API (item 7.8) +//! and is generated from this model. + +pub mod model; + +#[rustfmt::skip] +pub mod generated; diff --git a/crates/clazel-webidl/src/model.rs b/crates/clazel-webidl/src/model.rs new file mode 100644 index 00000000..eb24e72c --- /dev/null +++ b/crates/clazel-webidl/src/model.rs @@ -0,0 +1,454 @@ +//! The resolved WebIDL model as plain `'static` data (phase-7.md item 7.12). +//! +//! `cargo xtask bindings` (`xtask/src/bindings/`) parses the vendored IDL +//! with the grammar of WebIDL §2, merges partial interfaces, mixins and +//! `includes` (`xtask/src/bindings/resolve.rs` lists the rules), and writes +//! the result into [`crate::generated`] as values of these types. The types +//! hold no behaviour: the binding glue that the embedding API of `clazel-js` +//! (item 7.8) allows is generated from this data later. + +/// An extended attribute: `[Name]`, `[Name=Ident]`, `[Name=(A, B)]`, +/// `[Name=*]`, `[Name(args)]`, `[Name=Ident(args)]` or `[Name=literal]` +/// (WebIDL §2.2). +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct ExtAttr { + /// Its name. + pub name: &'static str, + /// What follows the name. + pub value: ExtValue, +} + +/// What follows an extended attribute's name. +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum ExtValue { + /// `[Name]`. + None, + /// `[Name=Ident]`. + Ident(&'static str), + /// `[Name=(A, B)]`. + IdentList(&'static [&'static str]), + /// `[Name=*]`. + Wildcard, + /// `[Name=1]`, `[Name=1.5]` or `[Name="s"]`. + Literal(Value), + /// `[Name=(0, 8)]`: literals. + LiteralList(&'static [Value]), + /// `[Name(args)]`. + Args(&'static [Argument]), + /// `[Name=Ident(args)]`. + NamedArgs(&'static str, &'static [Argument]), +} + +/// A type that the grammar spells with keywords alone. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Simple { + /// `any`. + Any, + /// `undefined`. + Undefined, + /// `boolean`. + Boolean, + /// `byte`. + Byte, + /// `octet`. + Octet, + /// `bigint`. + Bigint, + /// `object`. + Object, + /// `symbol`. + Symbol, + /// `short`. + Short, + /// `unsigned short`. + UnsignedShort, + /// `long`. + Long, + /// `unsigned long`. + UnsignedLong, + /// `long long`. + LongLong, + /// `unsigned long long`. + UnsignedLongLong, + /// `float`. + Float, + /// `unrestricted float`. + UnrestrictedFloat, + /// `double`. + Double, + /// `unrestricted double`. + UnrestrictedDouble, + /// `ByteString`. + ByteString, + /// `DOMString`. + DomString, + /// `USVString`. + UsvString, +} + +/// A type without its nullability and extended attributes. +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum Type { + /// A keyword type. + Simple(Simple), + /// A buffer-related type (`ArrayBuffer`, `Uint8Array`, ...), by name. + Buffer(&'static str), + /// An identifier: an interface, dictionary, enum, typedef or callback, + /// or a name in [`crate::generated::EXTERNAL`]. + Named(&'static str), + /// `sequence`. + Sequence(&'static TypeRef), + /// `FrozenArray`. + FrozenArray(&'static TypeRef), + /// `ObservableArray`. + ObservableArray(&'static TypeRef), + /// `record`. + Record(&'static TypeRef, &'static TypeRef), + /// `Promise`. + Promise(&'static TypeRef), + /// `(A or B or ...)`. + Union(&'static [TypeRef]), +} + +/// A type with its nullability and the extended attributes written on it. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct TypeRef { + /// The type. + pub ty: Type, + /// Followed by `?`. + pub nullable: bool, + /// `[Clamp] long` and the like. + pub ext_attrs: &'static [ExtAttr], +} + +/// A literal: a constant's value or a default. +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum Value { + /// `true` or `false`. + Bool(bool), + /// An integer, in the value its lexeme has (`0x10` is 16). + Integer(i128), + /// A decimal, as written. + Decimal(&'static str), + /// `Infinity`. + Infinity, + /// `-Infinity`. + NegInfinity, + /// `NaN`. + NaN, + /// A string, without the quotes. + Str(&'static str), + /// `[]`. + EmptySequence, + /// `{}`. + EmptyDictionary, + /// `null`. + Null, + /// `undefined`. + Undefined, +} + +/// An operation's or constructor's argument. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Argument { + /// Its name. + pub name: &'static str, + /// Its type. + pub ty: TypeRef, + /// `optional`. + pub optional: bool, + /// `...`. + pub variadic: bool, + /// `= value`. + pub default: Option, + /// Extended attributes on the argument. + pub ext_attrs: &'static [ExtAttr], +} + +/// `const T NAME = value;`. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Constant { + /// Its name. + pub name: &'static str, + /// Its type. + pub ty: TypeRef, + /// Its value. + pub value: Value, + /// The mixin it came from, if it came through `includes`. + pub mixin: Option<&'static str>, + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], +} + +/// An attribute. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Attribute { + /// Its name. + pub name: &'static str, + /// Its type. + pub ty: TypeRef, + /// `readonly`. + pub readonly: bool, + /// `inherit`. + pub inherit: bool, + /// `static`. + pub is_static: bool, + /// `stringifier attribute`. + pub stringifier: bool, + /// The mixin it came from, if it came through `includes`. + pub mixin: Option<&'static str>, + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], +} + +/// What kind of operation. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum OperationKind { + /// A regular operation. + Regular, + /// `static`. + Static, + /// `getter`. + Getter, + /// `setter`. + Setter, + /// `deleter`. + Deleter, + /// `stringifier;`. + Stringifier, +} + +/// An operation. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Operation { + /// Its name; special operations may have none. + pub name: Option<&'static str>, + /// Its kind. + pub kind: OperationKind, + /// Its return type. + pub ret: TypeRef, + /// Its arguments. + pub args: &'static [Argument], + /// The mixin it came from, if it came through `includes`. + pub mixin: Option<&'static str>, + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], +} + +/// `constructor(...)`. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Constructor { + /// Its arguments. + pub args: &'static [Argument], + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], +} + +/// `iterable<...>` or `async iterable<...>`. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Iterable { + /// `async iterable`. + pub is_async: bool, + /// The key type of the pair form. + pub key: Option, + /// The value type. + pub value: TypeRef, + /// The arguments of `async iterable<...>(...)`. + pub args: &'static [Argument], + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], +} + +/// `maplike` or `setlike`. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Collection { + /// `maplike` (else `setlike`). + pub is_map: bool, + /// `readonly`. + pub readonly: bool, + /// The key type of a maplike. + pub key: Option, + /// The value type (the element type of a setlike). + pub value: TypeRef, + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], +} + +/// A resolved interface or callback interface: its own members, then those of +/// its partial interfaces, then those of the mixins it includes (each of +/// those marked with its mixin). +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Interface { + /// Its name. + pub name: &'static str, + /// The interface it inherits from. + pub parent: Option<&'static str>, + /// `callback interface`. + pub callback: bool, + /// Its own extended attributes. + pub ext_attrs: &'static [ExtAttr], + /// The mixins it includes, in order (a name in + /// [`crate::generated::EXTERNAL`] has no members here). + pub includes: &'static [&'static str], + /// `constructor(...)` declarations. + pub constructors: &'static [Constructor], + /// Constants. + pub constants: &'static [Constant], + /// Attributes, static ones included. + pub attributes: &'static [Attribute], + /// Operations, special, static and stringifier ones included. + pub operations: &'static [Operation], + /// Its `iterable` or `async iterable`. + pub iterable: Option, + /// Its `maplike` or `setlike`. + pub collection: Option, +} + +/// A resolved namespace. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Namespace { + /// Its name. + pub name: &'static str, + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], + /// Constants. + pub constants: &'static [Constant], + /// Readonly attributes. + pub attributes: &'static [Attribute], + /// Operations. + pub operations: &'static [Operation], +} + +/// A dictionary member. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct DictionaryMember { + /// Its name. + pub name: &'static str, + /// Its type. + pub ty: TypeRef, + /// `required`. + pub required: bool, + /// `= value`. + pub default: Option, + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], +} + +/// A resolved dictionary: its own members, then those of its partials. The +/// members of its parent are not copied in. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Dictionary { + /// Its name. + pub name: &'static str, + /// The dictionary it inherits from. + pub parent: Option<&'static str>, + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], + /// Its members. + pub members: &'static [DictionaryMember], +} + +/// An enum. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Enumeration { + /// Its name. + pub name: &'static str, + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], + /// Its values, in order. + pub values: &'static [&'static str], +} + +/// A typedef. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Typedef { + /// Its name. + pub name: &'static str, + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], + /// The type it names. + pub ty: TypeRef, +} + +/// A callback function type: `callback Name = Return (args);`. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Callback { + /// Its name. + pub name: &'static str, + /// Its extended attributes. + pub ext_attrs: &'static [ExtAttr], + /// Its return type. + pub ret: TypeRef, + /// Its arguments. + pub args: &'static [Argument], +} + +/// A name the IDL refers to that another standard defines, whose IDL is not +/// vendored. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct External { + /// Its name. + pub name: &'static str, + /// The standard that defines it. + pub defined_by: &'static str, +} + +/// An `includes` statement whose interface another standard defines: the +/// statement is kept, the interface is not in the model. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ForeignIncludes { + /// The interface (in [`crate::generated::EXTERNAL`]). + pub interface: &'static str, + /// The mixin it includes. + pub mixin: &'static str, +} + +/// The first extended attribute named `name` in `attrs`. +#[must_use] +pub fn ext_attr(attrs: &'static [ExtAttr], name: &str) -> Option<&'static ExtAttr> { + attrs.iter().find(|a| a.name == name) +} + +/// Find the item named `name` in a table sorted by name. +fn find(table: &'static [T], name: &str, key: impl Fn(&T) -> &str) -> Option<&'static T> { + table + .binary_search_by(|item| key(item).cmp(name)) + .ok() + .and_then(|i| table.get(i)) +} + +/// The interface (or callback interface) named `name`. +#[must_use] +pub fn interface(name: &str) -> Option<&'static Interface> { + find(crate::generated::INTERFACES, name, |i| i.name) +} + +/// The namespace named `name`. +#[must_use] +pub fn namespace(name: &str) -> Option<&'static Namespace> { + find(crate::generated::NAMESPACES, name, |i| i.name) +} + +/// The dictionary named `name`. +#[must_use] +pub fn dictionary(name: &str) -> Option<&'static Dictionary> { + find(crate::generated::DICTIONARIES, name, |i| i.name) +} + +/// The enum named `name`. +#[must_use] +pub fn enumeration(name: &str) -> Option<&'static Enumeration> { + find(crate::generated::ENUMS, name, |i| i.name) +} + +/// The typedef named `name`. +#[must_use] +pub fn typedef(name: &str) -> Option<&'static Typedef> { + find(crate::generated::TYPEDEFS, name, |i| i.name) +} + +/// The callback function type named `name`. +#[must_use] +pub fn callback(name: &str) -> Option<&'static Callback> { + find(crate::generated::CALLBACKS, name, |i| i.name) +} diff --git a/crates/clazel-webidl/tests/model.rs b/crates/clazel-webidl/tests/model.rs new file mode 100644 index 00000000..e8ac52b0 --- /dev/null +++ b/crates/clazel-webidl/tests/model.rs @@ -0,0 +1,471 @@ +//! Tests of the generated interface model (`src/generated/`) against facts of +//! the standards, which these tests state independently of the generator. + +use clazel_webidl::generated::{ + CALLBACKS, DICTIONARIES, ENUMS, EXTERNAL, FOREIGN_INCLUDES, INTERFACES, NAMESPACES, TYPEDEFS, +}; +use clazel_webidl::model::{ + Argument, ExtAttr, ExtValue, Simple, Type, TypeRef, Value, callback, dictionary, enumeration, + ext_attr, interface, namespace, typedef, +}; + +type T = Result<(), String>; + +fn need(o: Option, what: &str) -> Result { + o.ok_or_else(|| format!("missing {what}")) +} + +fn check(cond: bool, msg: &str) -> T { + if cond { Ok(()) } else { Err(msg.to_owned()) } +} + +fn sorted_and_unique(names: Vec<&str>) -> bool { + names.windows(2).all(|w| match w { + [a, b] => a < b, + _ => true, + }) +} + +/// The counts the PR reports; a change to the vendored IDL or to the +/// generator changes them, and this test is where that is noticed. +#[test] +fn counts() -> T { + check(INTERFACES.len() == 233, "interfaces")?; + check( + INTERFACES.iter().filter(|i| i.callback).count() == 3, + "callback interfaces", + )?; + check(NAMESPACES.len() == 1, "namespaces")?; + check(DICTIONARIES.len() == 73, "dictionaries")?; + check( + DICTIONARIES.iter().map(|d| d.members.len()).sum::() == 210, + "dictionary members", + )?; + check(ENUMS.len() == 45, "enums")?; + check( + ENUMS.iter().map(|e| e.values.len()).sum::() == 173, + "enum values", + )?; + check(TYPEDEFS.len() == 22, "typedefs")?; + check(CALLBACKS.len() == 10, "callbacks")?; + check(EXTERNAL.len() == 37, "external names")?; + check( + INTERFACES.iter().map(|i| i.attributes.len()).sum::() + == 1512 - namespace_members()?.0, + "attributes", + )?; + check( + INTERFACES.iter().map(|i| i.operations.len()).sum::() + == 731 - namespace_members()?.1, + "operations", + )?; + check( + INTERFACES.iter().map(|i| i.constants.len()).sum::() == 89 - namespace_members()?.2, + "constants", + )?; + check( + INTERFACES + .iter() + .map(|i| i.constructors.len()) + .sum::() + == 131, + "constructors", + )?; + check( + INTERFACES.iter().filter(|i| i.iterable.is_some()).count() == 5, + "iterables", + )?; + check( + INTERFACES.iter().filter(|i| i.collection.is_some()).count() == 1, + "maplike and setlike", + )?; + check( + FOREIGN_INCLUDES.len() == 2, + "includes of foreign interfaces", + ) +} + +/// Attributes, operations and constants of the namespaces. +fn namespace_members() -> Result<(usize, usize, usize), String> { + Ok(( + NAMESPACES.iter().map(|n| n.attributes.len()).sum(), + NAMESPACES.iter().map(|n| n.operations.len()).sum(), + NAMESPACES.iter().map(|n| n.constants.len()).sum(), + )) +} + +#[test] +fn tables_are_sorted_so_lookups_can_bisect() -> T { + check( + sorted_and_unique(INTERFACES.iter().map(|i| i.name).collect()), + "interfaces", + )?; + check( + sorted_and_unique(NAMESPACES.iter().map(|i| i.name).collect()), + "namespaces", + )?; + check( + sorted_and_unique(DICTIONARIES.iter().map(|i| i.name).collect()), + "dictionaries", + )?; + check( + sorted_and_unique(ENUMS.iter().map(|i| i.name).collect()), + "enums", + )?; + check( + sorted_and_unique(TYPEDEFS.iter().map(|i| i.name).collect()), + "typedefs", + )?; + check( + sorted_and_unique(CALLBACKS.iter().map(|i| i.name).collect()), + "callbacks", + )?; + check( + sorted_and_unique(EXTERNAL.iter().map(|i| i.name).collect()), + "external", + )?; + for i in INTERFACES { + check(interface(i.name).is_some_and(|f| f.name == i.name), i.name)?; + } + check(interface("NoSuchInterface").is_none(), "absent name") +} + +struct Names; + +impl Names { + fn defined(name: &str) -> bool { + interface(name).is_some() + || dictionary(name).is_some() + || enumeration(name).is_some() + || typedef(name).is_some() + || callback(name).is_some() + || EXTERNAL.iter().any(|e| e.name == name) + } +} + +fn walk_ext(attrs: &[ExtAttr], bad: &mut Vec) { + for a in attrs { + match a.value { + ExtValue::Args(args) | ExtValue::NamedArgs(_, args) => walk_args(args, bad), + _ => {} + } + } +} + +fn walk_args(args: &[Argument], bad: &mut Vec) { + for a in args { + walk_ext(a.ext_attrs, bad); + walk_ty(&a.ty, bad); + } +} + +fn walk_ty(t: &TypeRef, bad: &mut Vec) { + walk_ext(t.ext_attrs, bad); + match t.ty { + Type::Simple(_) | Type::Buffer(_) => {} + Type::Named(n) => { + if !Names::defined(n) { + bad.push(n.to_owned()); + } + } + Type::Sequence(i) | Type::FrozenArray(i) | Type::ObservableArray(i) | Type::Promise(i) => { + walk_ty(i, bad); + } + Type::Record(k, v) => { + walk_ty(k, bad); + walk_ty(v, bad); + } + Type::Union(members) => members.iter().for_each(|m| walk_ty(m, bad)), + } +} + +/// Every name the model uses resolves inside the model or is external, +/// checked here over the generated data and not over the parser's output. +#[test] +fn every_reference_resolves() -> T { + let mut bad = Vec::new(); + for i in INTERFACES { + if let Some(p) = i.parent { + let defined = interface(p).is_some_and(|p| !p.callback); + check( + defined || EXTERNAL.iter().any(|e| e.name == p), + &format!("{}: parent {p}", i.name), + )?; + } + walk_ext(i.ext_attrs, &mut bad); + for c in i.constructors { + walk_args(c.args, &mut bad); + } + for a in i.attributes { + walk_ty(&a.ty, &mut bad); + walk_ext(a.ext_attrs, &mut bad); + } + for o in i.operations { + walk_ty(&o.ret, &mut bad); + walk_args(o.args, &mut bad); + walk_ext(o.ext_attrs, &mut bad); + } + for c in i.constants { + walk_ty(&c.ty, &mut bad); + } + if let Some(it) = i.iterable { + it.key + .iter() + .chain([&it.value]) + .for_each(|t| walk_ty(t, &mut bad)); + } + if let Some(c) = i.collection { + c.key + .iter() + .chain([&c.value]) + .for_each(|t| walk_ty(t, &mut bad)); + } + } + for d in DICTIONARIES { + if let Some(p) = d.parent { + let defined = dictionary(p).is_some(); + check( + defined || EXTERNAL.iter().any(|e| e.name == p), + &format!("{}: parent {p}", d.name), + )?; + } + for m in d.members { + walk_ty(&m.ty, &mut bad); + } + } + for t in TYPEDEFS { + walk_ty(&t.ty, &mut bad); + } + for c in CALLBACKS { + walk_ty(&c.ret, &mut bad); + walk_args(c.args, &mut bad); + } + for n in NAMESPACES { + for o in n.operations { + walk_ty(&o.ret, &mut bad); + walk_args(o.args, &mut bad); + } + } + check(bad.is_empty(), &format!("unresolved: {bad:?}")) +} + +#[test] +fn includes_name_a_mixin_with_members_or_an_external_one() -> T { + for i in INTERFACES { + for m in i.includes { + let has_members = i + .attributes + .iter() + .map(|a| a.mixin) + .chain(i.operations.iter().map(|o| o.mixin)) + .chain(i.constants.iter().map(|c| c.mixin)) + .any(|x| x == Some(*m)); + check( + has_members || EXTERNAL.iter().any(|e| e.name == *m), + &format!("{} includes {m}", i.name), + )?; + } + // A member marked with a mixin names one the interface includes. + for mixin in i + .attributes + .iter() + .filter_map(|a| a.mixin) + .chain(i.operations.iter().filter_map(|o| o.mixin)) + { + check(i.includes.contains(&mixin), &format!("{}: {mixin}", i.name))?; + } + } + Ok(()) +} + +#[test] +fn inheritance_and_mixins() -> T { + let node = need(interface("Node"), "Node")?; + check(node.parent == Some("EventTarget"), "Node : EventTarget")?; + let element = need(interface("Element"), "Element")?; + check(element.parent == Some("Node"), "Element : Node")?; + for m in [ + "ParentNode", + "ChildNode", + "NonDocumentTypeChildNode", + "Slottable", + ] { + check(element.includes.contains(&m), m)?; + } + let append = need( + element.operations.iter().find(|o| o.name == Some("append")), + "Element.append", + )?; + check( + append.mixin == Some("ParentNode"), + "append comes from ParentNode", + )?; + check( + append.args.len() == 1 && append.args.iter().all(|a| a.variadic), + "append(...nodes)", + )?; + // The mixin's own [CEReactions, Unscopable] are the member's. + check( + ext_attr(append.ext_attrs, "CEReactions").is_some(), + "append is [CEReactions]", + )?; + check( + ext_attr(append.ext_attrs, "Unscopable").is_some(), + "append is [Unscopable]", + )?; + let event_target = need(interface("EventTarget"), "EventTarget")?; + check( + event_target.parent.is_none() && event_target.constructors.len() == 1, + "EventTarget()", + ) +} + +#[test] +fn partial_interfaces_from_several_files_are_merged() -> T { + let window = need(interface("Window"), "Window")?; + let has = |n: &str| { + window.attributes.iter().any(|a| a.name == n) + || window.operations.iter().any(|o| o.name == Some(n)) + }; + // dom.idl (partial interface Window), cssom.idl and html.idl. + check(has("event"), "Window.event (DOM)")?; + check(has("getComputedStyle"), "Window.getComputedStyle (CSSOM)")?; + check(has("document"), "Window.document (HTML)")?; + check( + window.includes.contains(&"GlobalEventHandlers"), + "Window includes GlobalEventHandlers", + )?; + // `[Replaceable]` of `Window.event` (dom.idl) is the member's own. + let event = need( + window.attributes.iter().find(|a| a.name == "event"), + "event", + )?; + check( + ext_attr(event.ext_attrs, "Replaceable").is_some(), + "[Replaceable] event", + ) +} + +#[test] +fn extended_attributes_item_7_12_lists() -> T { + let event = need(interface("Event"), "Event")?; + let is_trusted = need( + event.attributes.iter().find(|a| a.name == "isTrusted"), + "isTrusted", + )?; + check( + ext_attr(is_trusted.ext_attrs, "LegacyUnforgeable").is_some(), + "[LegacyUnforgeable]", + )?; + let document = need(interface("Document"), "Document")?; + let implementation = need( + document + .attributes + .iter() + .find(|a| a.name == "implementation"), + "Document.implementation", + )?; + check( + ext_attr(implementation.ext_attrs, "SameObject").is_some(), + "[SameObject]", + )?; + let window = need(interface("Window"), "Window")?; + let location = need( + window.attributes.iter().find(|a| a.name == "location"), + "Window.location", + )?; + check( + ext_attr(location.ext_attrs, "PutForwards").map(|a| a.value) + == Some(ExtValue::Ident("href")), + "[PutForwards=href]", + )?; + let collection = need(interface("HTMLCollection"), "HTMLCollection")?; + check( + ext_attr(collection.ext_attrs, "LegacyUnenumerableNamedProperties").is_some(), + "[LegacyUnenumerableNamedProperties]", + )?; + check( + ext_attr(collection.ext_attrs, "Exposed").map(|a| a.value) + == Some(ExtValue::Ident("Window")), + "[Exposed=Window]", + ) +} + +#[test] +fn types_and_defaults() -> T { + let ctor = need(interface("Event"), "Event")? + .constructors + .first() + .copied(); + let ctor = need(ctor, "Event()")?; + check(ctor.args.len() == 2, "Event(type, eventInitDict)")?; + let init = need(ctor.args.get(1), "eventInitDict")?; + check( + init.optional && init.default == Some(Value::EmptyDictionary), + "optional EventInit = {}", + )?; + check(init.ty.ty == Type::Named("EventInit"), "EventInit")?; + let event_init = need(dictionary("EventInit"), "EventInit")?; + check(event_init.members.len() == 3, "EventInit has 3 members")?; + check( + event_init + .members + .iter() + .all(|m| m.default == Some(Value::Bool(false))), + "every EventInit member defaults to false", + )?; + let custom = need(dictionary("CustomEventInit"), "CustomEventInit")?; + check( + custom.parent == Some("EventInit"), + "CustomEventInit : EventInit", + )?; + let detail = need(custom.members.first(), "detail")?; + check( + detail.default == Some(Value::Null) && detail.ty.ty == Type::Simple(Simple::Any), + "any detail = null", + )?; + // A required member, and a nullable union. + let init = need(dictionary("ShadowRootInit"), "ShadowRootInit")?; + check( + init.members.iter().any(|m| m.name == "mode" && m.required), + "required mode", + )?; + let el = need(interface("Element"), "Element")?; + let get = need( + el.operations + .iter() + .find(|o| o.name == Some("getAttribute")), + "getAttribute", + )?; + check( + get.ret.nullable && get.ret.ty == Type::Simple(Simple::DomString), + "DOMString? getAttribute", + ) +} + +#[test] +fn enums_callbacks_typedefs_namespaces_and_iterables() -> T { + let mode = need(enumeration("ShadowRootMode"), "ShadowRootMode")?; + check(mode.values == ["open", "closed"], "ShadowRootMode values")?; + let listener = need(interface("EventListener"), "EventListener")?; + check( + listener.callback && listener.operations.len() == 1, + "callback interface EventListener", + )?; + let cb = need(callback("EventHandlerNonNull"), "EventHandlerNonNull")?; + check( + cb.ret.ty == Type::Simple(Simple::Any), + "EventHandlerNonNull returns any", + )?; + check(typedef("EventHandler").is_some(), "typedef EventHandler")?; + check( + namespace("CSS").is_some_and(|n| n.operations.iter().any(|o| o.name == Some("escape"))), + "namespace CSS", + )?; + let params = need(interface("URLSearchParams"), "URLSearchParams")?; + let it = need(params.iterable, "URLSearchParams iterable")?; + check( + !it.is_async && it.key.is_some(), + "iterable", + ) +} diff --git a/xtask/src/bindings/emit.rs b/xtask/src/bindings/emit.rs new file mode 100644 index 00000000..aa92614b --- /dev/null +++ b/xtask/src/bindings/emit.rs @@ -0,0 +1,526 @@ +//! Writing the resolved model as Rust data: one value of +//! `crates/clazel-webidl/src/model.rs`'s types per definition, in `static` +//! tables sorted by name. +//! +//! The files are written in a fixed layout (one list element per line, no +//! dependence on a formatter), so `check` compares them byte for byte; the +//! module that includes them is marked `#[rustfmt::skip]`. + +use std::fmt::Write as _; + +use super::model::{ + Argument, Attribute, Collection, Const, DictMember, ExtAttr, ExtValue, Iterable, Member, + MemberKind, OpKind, Operation, Simple, Ty, TyKind, Value, +}; +use super::resolve::{Callback, Dictionary, EXTERNAL, Enum, Interface, Model, Namespace, Typedef}; + +/// What the header of every generated file says. +const HEADER: &str = "\ +// @generated by `cargo xtask bindings` (xtask/src/bindings/) from +// crates/clazel-webidl/tests/data/webref-idl/ (the webref commit and the +// license are in SOURCE.md there). Do not edit: `cargo xtask check` fails if +// this differs from what the generator produces. +// +// What the generator derives (xtask/src/bindings/resolve.rs has the rules): +// - Every .idl file of that directory is parsed with our own parser, which +// follows the grammar of WebIDL §2; the definitions of all files are +// merged into one model. +// - Partial interfaces, dictionaries and namespaces are appended to their +// target, in file order (files sorted by name), then source order. +// - `A includes M;` appends M's members (and its partials') to A, each +// marked with the mixin's name. +// - `Exposed` and `SecureContext` written on a partial interface or on a +// mixin are copied onto the members it adds, unless a member has its own. +// - Definitions are sorted by name. A mixin has no table of its own: its +// members are in its includers. +// - A name that no vendored file defines is accepted only if it is in +// xtask/src/bindings/resolve.rs's EXTERNAL list; those are in EXTERNAL +// below, with no definition. +"; + +fn q(s: &str) -> String { + format!("{s:?}") +} + +fn opt_str(s: Option<&str>) -> String { + s.map_or_else(|| "None".to_owned(), |s| format!("Some({})", q(s))) +} + +fn simple(s: Simple) -> &'static str { + match s { + Simple::Any => "Any", + Simple::Undefined => "Undefined", + Simple::Boolean => "Boolean", + Simple::Byte => "Byte", + Simple::Octet => "Octet", + Simple::Bigint => "Bigint", + Simple::Object => "Object", + Simple::Symbol => "Symbol", + Simple::Short => "Short", + Simple::UnsignedShort => "UnsignedShort", + Simple::Long => "Long", + Simple::UnsignedLong => "UnsignedLong", + Simple::LongLong => "LongLong", + Simple::UnsignedLongLong => "UnsignedLongLong", + Simple::Float => "Float", + Simple::UnrestrictedFloat => "UnrestrictedFloat", + Simple::Double => "Double", + Simple::UnrestrictedDouble => "UnrestrictedDouble", + Simple::ByteString => "ByteString", + Simple::DomString => "DomString", + Simple::UsvString => "UsvString", + } +} + +fn value(v: &Value) -> String { + match v { + Value::Bool(b) => format!("Value::Bool({b})"), + Value::Integer(n) => format!("Value::Integer({n})"), + Value::Decimal(s) => format!("Value::Decimal({})", q(s)), + Value::Infinity => "Value::Infinity".to_owned(), + Value::NegInfinity => "Value::NegInfinity".to_owned(), + Value::NaN => "Value::NaN".to_owned(), + Value::Str(s) => format!("Value::Str({})", q(s)), + Value::EmptySequence => "Value::EmptySequence".to_owned(), + Value::EmptyDictionary => "Value::EmptyDictionary".to_owned(), + Value::Null => "Value::Null".to_owned(), + Value::Undefined => "Value::Undefined".to_owned(), + } +} + +fn opt_value(v: Option<&Value>) -> String { + v.map_or_else(|| "None".to_owned(), |v| format!("Some({})", value(v))) +} + +fn list(items: &[T], f: impl Fn(&T) -> String) -> String { + let parts: Vec = items.iter().map(f).collect(); + format!("&[{}]", parts.join(", ")) +} + +fn ext_value(v: &ExtValue) -> String { + match v { + ExtValue::None => "ExtValue::None".to_owned(), + ExtValue::Ident(s) => format!("ExtValue::Ident({})", q(s)), + ExtValue::IdentList(l) => format!("ExtValue::IdentList({})", list(l, |s| q(s))), + ExtValue::Wildcard => "ExtValue::Wildcard".to_owned(), + ExtValue::Literal(v) => format!("ExtValue::Literal({})", value(v)), + ExtValue::LiteralList(l) => format!("ExtValue::LiteralList({})", list(l, value)), + ExtValue::Args(a) => format!("ExtValue::Args({})", args(a)), + ExtValue::NamedArgs(n, a) => format!("ExtValue::NamedArgs({}, {})", q(n), args(a)), + } +} + +fn ext(attrs: &[ExtAttr]) -> String { + list(attrs, |a| { + format!( + "ExtAttr {{ name: {}, value: {} }}", + q(&a.name), + ext_value(&a.value) + ) + }) +} + +fn kind(k: &TyKind) -> String { + let boxed = |t: &Ty| format!("&{}", ty(t)); + match k { + TyKind::Simple(s) => format!("Type::Simple(Simple::{})", simple(*s)), + TyKind::Buffer(n) => format!("Type::Buffer({})", q(n)), + TyKind::Named(n) => format!("Type::Named({})", q(n)), + TyKind::Sequence(t) => format!("Type::Sequence({})", boxed(t)), + TyKind::FrozenArray(t) => format!("Type::FrozenArray({})", boxed(t)), + TyKind::ObservableArray(t) => format!("Type::ObservableArray({})", boxed(t)), + TyKind::Record(k, v) => format!("Type::Record({}, {})", boxed(k), boxed(v)), + TyKind::Promise(t) => format!("Type::Promise({})", boxed(t)), + TyKind::Union(ts) => format!("Type::Union({})", list(ts, ty)), + } +} + +fn ty(t: &Ty) -> String { + format!( + "TypeRef {{ ty: {}, nullable: {}, ext_attrs: {} }}", + kind(&t.kind), + t.nullable, + ext(&t.ext) + ) +} + +fn opt_ty(t: Option<&Ty>) -> String { + t.map_or_else(|| "None".to_owned(), |t| format!("Some({})", ty(t))) +} + +fn arg(a: &Argument) -> String { + format!( + "Argument {{ name: {}, ty: {}, optional: {}, variadic: {}, default: {}, ext_attrs: {} }}", + q(&a.name), + ty(&a.ty), + a.optional, + a.variadic, + opt_value(a.default.as_ref()), + ext(&a.ext) + ) +} + +fn args(a: &[Argument]) -> String { + list(a, arg) +} + +fn constant(c: &Const, m: &Member) -> String { + format!( + "Constant {{ name: {}, ty: {}, value: {}, mixin: {}, ext_attrs: {} }}", + q(&c.name), + ty(&c.ty), + value(&c.value), + opt_str(m.mixin.as_deref()), + ext(&m.ext) + ) +} + +fn attribute(a: &Attribute, m: &Member) -> String { + format!( + "Attribute {{ name: {}, ty: {}, readonly: {}, inherit: {}, is_static: {}, stringifier: {}, mixin: {}, ext_attrs: {} }}", + q(&a.name), + ty(&a.ty), + a.readonly, + a.inherit, + a.is_static, + a.stringifier, + opt_str(m.mixin.as_deref()), + ext(&m.ext) + ) +} + +fn operation(o: &Operation, m: &Member) -> String { + let kind = match o.kind { + OpKind::Regular => "Regular", + OpKind::Static => "Static", + OpKind::Getter => "Getter", + OpKind::Setter => "Setter", + OpKind::Deleter => "Deleter", + OpKind::Stringifier => "Stringifier", + }; + format!( + "Operation {{ name: {}, kind: OperationKind::{kind}, ret: {}, args: {}, mixin: {}, ext_attrs: {} }}", + opt_str(o.name.as_deref()), + ty(&o.ret), + args(&o.args), + opt_str(m.mixin.as_deref()), + ext(&m.ext) + ) +} + +fn iterable(i: &Iterable, m: &Member) -> String { + format!( + "Some(Iterable {{ is_async: {}, key: {}, value: {}, args: {}, ext_attrs: {} }})", + i.is_async, + opt_ty(i.key.as_ref()), + ty(&i.value), + args(&i.args), + ext(&m.ext) + ) +} + +fn collection(c: &Collection, m: &Member) -> String { + format!( + "Some(Collection {{ is_map: {}, readonly: {}, key: {}, value: {}, ext_attrs: {} }})", + c.is_map, + c.readonly, + opt_ty(c.key.as_ref()), + ty(&c.value), + ext(&m.ext) + ) +} + +/// The members of one kind, each as an element on its own line, indented. +fn elements(items: impl Iterator, f: impl Fn(T) -> String, indent: &str) -> String { + let lines: Vec = items.map(|i| format!("{indent} {},\n", f(i))).collect(); + if lines.is_empty() { + "&[]".to_owned() + } else { + format!("&[\n{}{indent}]", lines.concat()) + } +} + +fn consts(members: &[Member], indent: &str) -> String { + let it = members.iter().filter_map(|m| match &m.kind { + MemberKind::Const(c) => Some((c, m)), + _ => None, + }); + elements(it, |(c, m)| constant(c, m), indent) +} + +fn attributes(members: &[Member], indent: &str) -> String { + let it = members.iter().filter_map(|m| match &m.kind { + MemberKind::Attribute(a) => Some((a, m)), + _ => None, + }); + elements(it, |(a, m)| attribute(a, m), indent) +} + +fn operations(members: &[Member], indent: &str) -> String { + let it = members.iter().filter_map(|m| match &m.kind { + MemberKind::Operation(o) => Some((o, m)), + _ => None, + }); + elements(it, |(o, m)| operation(o, m), indent) +} + +fn interface_text(i: &Interface) -> String { + let constructors = elements( + i.members.iter().filter_map(|m| match &m.kind { + MemberKind::Constructor(a) => Some((a, m)), + _ => None, + }), + |(a, m)| { + format!( + "Constructor {{ args: {}, ext_attrs: {} }}", + args(a), + ext(&m.ext) + ) + }, + " ", + ); + let it = i + .members + .iter() + .find_map(|m| match &m.kind { + MemberKind::Iterable(x) => Some(iterable(x, m)), + _ => None, + }) + .unwrap_or_else(|| "None".to_owned()); + let col = i + .members + .iter() + .find_map(|m| match &m.kind { + MemberKind::Collection(x) => Some(collection(x, m)), + _ => None, + }) + .unwrap_or_else(|| "None".to_owned()); + format!( + " Interface {{\n name: {},\n parent: {},\n callback: {},\n ext_attrs: {},\n includes: {},\n constructors: {constructors},\n constants: {},\n attributes: {},\n operations: {},\n iterable: {it},\n collection: {col},\n }},\n", + q(&i.name), + opt_str(i.parent.as_deref()), + i.callback, + ext(&i.ext), + list(&i.includes, |s| q(s)), + consts(&i.members, " "), + attributes(&i.members, " "), + operations(&i.members, " "), + ) +} + +fn namespace_text(n: &Namespace) -> String { + format!( + " Namespace {{\n name: {},\n ext_attrs: {},\n constants: {},\n attributes: {},\n operations: {},\n }},\n", + q(&n.name), + ext(&n.ext), + consts(&n.members, " "), + attributes(&n.members, " "), + operations(&n.members, " "), + ) +} + +fn dict_member(m: &DictMember) -> String { + format!( + "DictionaryMember {{ name: {}, ty: {}, required: {}, default: {}, ext_attrs: {} }}", + q(&m.name), + ty(&m.ty), + m.required, + opt_value(m.default.as_ref()), + ext(&m.ext) + ) +} + +fn dictionary_text(d: &Dictionary) -> String { + format!( + " Dictionary {{\n name: {},\n parent: {},\n ext_attrs: {},\n members: {},\n }},\n", + q(&d.name), + opt_str(d.parent.as_deref()), + ext(&d.ext), + elements(d.members.iter(), dict_member, " "), + ) +} + +fn enum_text(e: &Enum) -> String { + format!( + " Enumeration {{ name: {}, ext_attrs: {}, values: {} }},\n", + q(&e.name), + ext(&e.ext), + list(&e.values, |s| q(s)) + ) +} + +fn typedef_text(t: &Typedef) -> String { + format!( + " Typedef {{ name: {}, ext_attrs: {}, ty: {} }},\n", + q(&t.name), + ext(&t.ext), + ty(&t.ty) + ) +} + +fn callback_text(c: &Callback) -> String { + format!( + " Callback {{ name: {}, ext_attrs: {}, ret: {}, args: {} }},\n", + q(&c.name), + ext(&c.ext), + ty(&c.ret), + args(&c.args) + ) +} + +/// One table file: header, doc line, import, the `static`. +fn table(doc: &str, name: &str, ty_name: &str, items: &[T], f: impl Fn(&T) -> String) -> String { + let mut out = String::new(); + out.push_str(HEADER); + let _ = writeln!(out, "\n//! {doc}\n"); + out.push_str("use crate::model::*;\n\n"); + let _ = writeln!(out, "/// {doc}"); + let _ = writeln!(out, "pub static {name}: &[{ty_name}] = &["); + for i in items { + out.push_str(&f(i)); + } + out.push_str("];\n"); + out +} + +/// The generated files: (file name, text), in the order written. +pub fn files(m: &Model) -> Vec<(String, String)> { + let mut mod_rs = String::new(); + mod_rs.push_str("//! The resolved interface model of the vendored WebIDL (item 7.12): plain data of\n//! the types in [`crate::model`], one table per kind of definition, sorted by name.\n//!\n"); + for l in HEADER.lines() { + let _ = writeln!(mod_rs, "{}", l.trim_end()); + } + mod_rs.push_str("\nuse crate::model::{External, ForeignIncludes};\n\n"); + for (module, table) in [ + ("callbacks", "CALLBACKS"), + ("dictionaries", "DICTIONARIES"), + ("enums", "ENUMS"), + ("interfaces", "INTERFACES"), + ("namespaces", "NAMESPACES"), + ("typedefs", "TYPEDEFS"), + ] { + let _ = writeln!(mod_rs, "mod {module};"); + let _ = writeln!(mod_rs, "pub use {module}::{table};"); + } + mod_rs.push_str("\n/// Names the IDL refers to that no vendored file defines, with the standard that does.\n/// They have no entry in any table. Only the names the files use are listed.\npub static EXTERNAL: &[External] = &[\n"); + for (name, by) in EXTERNAL { + if m.external.iter().any(|n| n == name) { + let _ = writeln!( + mod_rs, + " External {{ name: {}, defined_by: {} }},", + q(name), + q(by) + ); + } + } + mod_rs.push_str("];\n\n/// `includes` statements whose interface is in [`EXTERNAL`]; the interface is not in\n/// [`INTERFACES`], so its members from these mixins are not in the model.\npub static FOREIGN_INCLUDES: &[ForeignIncludes] = &[\n"); + for (i, mix) in &m.foreign_includes { + let _ = writeln!( + mod_rs, + " ForeignIncludes {{ interface: {}, mixin: {} }},", + q(i), + q(mix) + ); + } + mod_rs.push_str("];\n"); + vec![ + ("mod.rs".to_owned(), mod_rs), + ( + "interfaces.rs".to_owned(), + table( + "Interfaces and callback interfaces, sorted by name.", + "INTERFACES", + "Interface", + &m.interfaces, + interface_text, + ), + ), + ( + "namespaces.rs".to_owned(), + table( + "Namespaces, sorted by name.", + "NAMESPACES", + "Namespace", + &m.namespaces, + namespace_text, + ), + ), + ( + "dictionaries.rs".to_owned(), + table( + "Dictionaries, sorted by name.", + "DICTIONARIES", + "Dictionary", + &m.dictionaries, + dictionary_text, + ), + ), + ( + "enums.rs".to_owned(), + table( + "Enums, sorted by name.", + "ENUMS", + "Enumeration", + &m.enums, + enum_text, + ), + ), + ( + "typedefs.rs".to_owned(), + table( + "Typedefs, sorted by name.", + "TYPEDEFS", + "Typedef", + &m.typedefs, + typedef_text, + ), + ), + ( + "callbacks.rs".to_owned(), + table( + "Callback function types, sorted by name.", + "CALLBACKS", + "Callback", + &m.callbacks, + callback_text, + ), + ), + ] +} + +/// The counts, for the notes of a run. +pub fn summary(m: &Model) -> String { + let count = |f: &dyn Fn(&Member) -> bool| -> usize { + m.interfaces + .iter() + .flat_map(|i| &i.members) + .chain(m.namespaces.iter().flat_map(|n| &n.members)) + .filter(|x| f(x)) + .count() + }; + let callback_interfaces = m.interfaces.iter().filter(|i| i.callback).count(); + format!( + "{} interfaces ({} callback interfaces), {} mixins resolved into their includers, {} namespaces, {} dictionaries with {} members, {} enums with {} values, {} typedefs, {} callbacks; \ + interface and namespace members: {} attributes, {} operations, {} constants, {} constructors, {} iterables, {} maplikes and setlikes; {} external names", + m.interfaces.len(), + callback_interfaces, + m.mixins, + m.namespaces.len(), + m.dictionaries.len(), + m.dictionaries + .iter() + .map(|d| d.members.len()) + .sum::(), + m.enums.len(), + m.enums.iter().map(|e| e.values.len()).sum::(), + m.typedefs.len(), + m.callbacks.len(), + count(&|x| matches!(x.kind, MemberKind::Attribute(_))), + count(&|x| matches!(x.kind, MemberKind::Operation(_))), + count(&|x| matches!(x.kind, MemberKind::Const(_))), + count(&|x| matches!(x.kind, MemberKind::Constructor(_))), + count(&|x| matches!(x.kind, MemberKind::Iterable(_))), + count(&|x| matches!(x.kind, MemberKind::Collection(_))), + m.external.len(), + ) +} diff --git a/xtask/src/bindings/lexer.rs b/xtask/src/bindings/lexer.rs new file mode 100644 index 00000000..962d0749 --- /dev/null +++ b/xtask/src/bindings/lexer.rs @@ -0,0 +1,285 @@ +//! The WebIDL tokenizer, WebIDL §2 "Interface definition language", the +//! list of tokens: `integer`, `decimal`, `identifier`, `string`, `whitespace`, +//! `comment` and `other`. +//! +//! Whitespace and comments are dropped. Keywords are identifiers here; the +//! parser tells them apart (a keyword is an identifier the grammar spells as +//! a terminal, WebIDL §2, and an identifier written with a leading `_` is +//! never a keyword). + +/// A token. +#[derive(Debug, Clone, PartialEq)] +pub enum Tok { + /// `identifier` (and the keywords), without a leading `_`. `-Infinity` + /// is one token, as the grammar has it as a terminal. + Ident { + /// The text. + name: String, + /// Written with a leading `_`. + escaped: bool, + }, + /// `integer`, as written. + Integer(String), + /// `decimal`, as written. + Decimal(String), + /// `string`, without the quotes. + Str(String), + /// `...`. + Ellipsis, + /// `other`: any one other character. + Punct(char), +} + +/// A token and the line it starts on (from 1). +#[derive(Debug, Clone, PartialEq)] +pub struct Token { + /// The token. + pub tok: Tok, + /// Its line. + pub line: u32, +} + +fn is_ident_start(c: char) -> bool { + c.is_ascii_alphabetic() +} + +fn is_ident_char(c: char) -> bool { + c.is_ascii_alphanumeric() || c == '_' || c == '-' +} + +struct Lexer { + chars: Vec, + pos: usize, + line: u32, +} + +impl Lexer { + fn at(&self, n: usize) -> Option { + self.chars.get(self.pos.saturating_add(n)).copied() + } + + fn bump(&mut self) -> Option { + let c = self.at(0)?; + self.pos = self.pos.saturating_add(1); + if c == '\n' { + self.line = self.line.saturating_add(1); + } + Some(c) + } + + fn starts_with(&self, s: &str) -> bool { + s.chars().enumerate().all(|(i, c)| self.at(i) == Some(c)) + } + + fn take_while(&mut self, f: impl Fn(char) -> bool) -> String { + let mut s = String::new(); + while let Some(c) = self.at(0).filter(|&c| f(c)) { + s.push(c); + self.bump(); + } + s + } + + /// `integer` or `decimal`, at a digit, a `.` before a digit, or a `-` + /// before either. + fn number(&mut self) -> Tok { + let mut s = String::new(); + if self.at(0) == Some('-') { + s.push('-'); + self.bump(); + } + if self.at(0) == Some('0') && matches!(self.at(1), Some('x' | 'X')) { + s.push_str(&self.take_while(|c| c == '0')); + if let Some(x) = self.bump() { + s.push(x); + } + s.push_str(&self.take_while(|c| c.is_ascii_hexdigit())); + return Tok::Integer(s); + } + s.push_str(&self.take_while(|c| c.is_ascii_digit())); + let mut decimal = false; + if self.at(0) == Some('.') { + decimal = true; + s.push('.'); + self.bump(); + s.push_str(&self.take_while(|c| c.is_ascii_digit())); + } + let exp_digit = |l: &Self, n: usize| l.at(n).is_some_and(|c| c.is_ascii_digit()); + if matches!(self.at(0), Some('e' | 'E')) { + let signed = matches!(self.at(1), Some('+' | '-')); + if exp_digit(self, if signed { 2 } else { 1 }) { + decimal = true; + if let Some(e) = self.bump() { + s.push(e); + } + if signed && let Some(sign) = self.bump() { + s.push(sign); + } + s.push_str(&self.take_while(|c| c.is_ascii_digit())); + } + } + if decimal { + Tok::Decimal(s) + } else { + Tok::Integer(s) + } + } +} + +/// Tokenize `src`. +pub fn lex(src: &str) -> Result, String> { + let mut l = Lexer { + chars: src.chars().collect(), + pos: 0, + line: 1, + }; + let mut out = Vec::new(); + while let Some(c) = l.at(0) { + let line = l.line; + if matches!(c, '\t' | '\n' | '\r' | ' ') { + l.bump(); + continue; + } + if l.starts_with("//") { + l.take_while(|c| c != '\n'); + continue; + } + if l.starts_with("/*") { + l.bump(); + l.bump(); + loop { + if l.starts_with("*/") { + l.bump(); + l.bump(); + break; + } + if l.bump().is_none() { + return Err(format!("{line}: unterminated comment")); + } + } + continue; + } + let tok = if c == '"' { + l.bump(); + let s = l.take_while(|c| c != '"'); + if l.bump().is_none() { + return Err(format!("{line}: unterminated string")); + } + Tok::Str(s) + } else if c.is_ascii_digit() + || (c == '.' && l.at(1).is_some_and(|d| d.is_ascii_digit())) + || (c == '-' && l.at(1).is_some_and(|d| d.is_ascii_digit())) + || (c == '-' && l.at(1) == Some('.') && l.at(2).is_some_and(|d| d.is_ascii_digit())) + { + l.number() + } else if l.starts_with("...") { + l.bump(); + l.bump(); + l.bump(); + Tok::Ellipsis + } else if l.starts_with("-Infinity") && !l.at(9).is_some_and(is_ident_char) { + for _ in 0..9 { + l.bump(); + } + Tok::Ident { + name: "-Infinity".to_owned(), + escaped: false, + } + } else if is_ident_start(c) || (c == '_' && l.at(1).is_some_and(is_ident_start)) { + let escaped = c == '_'; + if escaped { + l.bump(); + } + let name = l.take_while(is_ident_char); + Tok::Ident { name, escaped } + } else { + l.bump(); + Tok::Punct(c) + }; + out.push(Token { tok, line }); + } + Ok(out) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn toks(s: &str) -> Vec { + lex(s) + .unwrap_or_default() + .into_iter() + .map(|t| t.tok) + .collect() + } + + fn id(s: &str) -> Tok { + Tok::Ident { + name: s.to_owned(), + escaped: false, + } + } + + #[test] + fn numbers() { + assert_eq!( + toks("1 -2 0x1F 0 1.5 -.5 5. 1e3 2E-2 .5e+1"), + vec![ + Tok::Integer("1".into()), + Tok::Integer("-2".into()), + Tok::Integer("0x1F".into()), + Tok::Integer("0".into()), + Tok::Decimal("1.5".into()), + Tok::Decimal("-.5".into()), + Tok::Decimal("5.".into()), + Tok::Decimal("1e3".into()), + Tok::Decimal("2E-2".into()), + Tok::Decimal(".5e+1".into()), + ] + ); + } + + #[test] + fn infinity_ellipsis_and_identifiers() { + assert_eq!( + toks("-Infinity Infinity -x ... . _interface a-b _x"), + vec![ + id("-Infinity"), + id("Infinity"), + Tok::Punct('-'), + id("x"), + Tok::Ellipsis, + Tok::Punct('.'), + Tok::Ident { + name: "interface".into(), + escaped: true + }, + id("a-b"), + Tok::Ident { + name: "x".into(), + escaped: true + }, + ] + ); + } + + #[test] + fn comments_strings_and_lines() { + let t = lex("// a\n/* b\n c */ \"d e\" ;").unwrap_or_default(); + assert_eq!( + t, + vec![ + Token { + tok: Tok::Str("d e".into()), + line: 3 + }, + Token { + tok: Tok::Punct(';'), + line: 3 + }, + ] + ); + assert!(lex("/* x").is_err()); + assert!(lex("\"x").is_err()); + } +} diff --git a/xtask/src/bindings/mod.rs b/xtask/src/bindings/mod.rs new file mode 100644 index 00000000..f6952bd8 --- /dev/null +++ b/xtask/src/bindings/mod.rs @@ -0,0 +1,158 @@ +//! `cargo xtask bindings`: the WebIDL parser and the generated interface +//! model of `clazel-webidl` (Phase 7 item 7.12, first slice). +//! +//! The vendored IDL of the DOM, HTML, Fetch, XHR, URL and Storage standards, +//! UI Events and CSSOM (`crates/clazel-webidl/tests/data/webref-idl/`, item +//! 7.1; its `SOURCE.md` names the upstream commit, and `cargo xtask +//! testdata` checks every file's size and SHA-256 against the inventory in +//! `tests/generated/webref_idl.rs`) is read by our own parser (`parser.rs`, +//! following the grammar of WebIDL §2), merged into one model (`resolve.rs`) +//! and written as plain Rust data into +//! `crates/clazel-webidl/src/generated/` (`emit.rs`). The data types are +//! `crates/clazel-webidl/src/model.rs`. Nothing there is engine code: the +//! item's binding glue (conversions, wrappers, overload resolution) comes +//! with `clazel-js`'s embedding API (7.8) and is generated from this model. +//! +//! `cargo xtask bindings` rewrites the files; `check` and `verify` fail if +//! a vendored file is missing from the inventory or differs from it, if any +//! file does not parse, if a reference does not resolve (`resolve.rs`), or +//! if a committed file differs from what this produces. +//! +//! The parser is build tooling, not shipped code, and proves nothing: Tier 0. +//! What it is checked against: the unit tests of `parser.rs` and `lexer.rs`, +//! the test here that every vendored file parses, and `clazel-webidl`'s tests +//! of the generated data. + +mod emit; +mod lexer; +mod model; +mod parser; +mod resolve; + +use std::path::{Path, PathBuf}; + +/// The vendored IDL directory, relative to the repository root. +const DATA_DIR: &str = "crates/clazel-webidl/tests/data/webref-idl"; +/// The generated directory, relative to the repository root. +const OUT_DIR: &str = "crates/clazel-webidl/src/generated"; + +/// Parse every `.idl` file of `dir`, in the order of their names, and merge +/// them. +fn load(dir: &Path) -> Result { + let mut names: Vec = std::fs::read_dir(dir) + .map_err(|e| format!("{}: {e}", dir.display()))? + .filter_map(Result::ok) + .filter_map(|e| e.file_name().into_string().ok()) + .filter(|n| n.ends_with(".idl")) + .collect(); + names.sort(); + if names.is_empty() { + return Err(format!("{}: no .idl files", dir.display())); + } + let mut files = Vec::new(); + for name in names { + let path = dir.join(&name); + let text = + std::fs::read_to_string(&path).map_err(|e| format!("{}: {e}", path.display()))?; + let defs = parser::parse(&text).map_err(|e| format!("{name}:{e}"))?; + files.push((name, defs)); + } + resolve::resolve(&files) +} + +/// Compare (or, with `write`, rewrite) the generated files. Returns +/// (problems, notes). +pub fn run(write: bool) -> (Vec, Vec) { + let mut notes = Vec::new(); + let model = match load(&PathBuf::from(DATA_DIR)) { + Ok(m) => m, + Err(e) => return (vec![format!("{DATA_DIR}: {e}")], notes), + }; + notes.push(emit::summary(&model)); + let fresh = emit::files(&model); + let mut problems = Vec::new(); + let out_dir = PathBuf::from(OUT_DIR); + // A file in the directory that the generator no longer writes is stale. + if let Ok(entries) = std::fs::read_dir(&out_dir) { + for e in entries.filter_map(Result::ok) { + let name = e.file_name().to_string_lossy().into_owned(); + if !fresh.iter().any(|(n, _)| *n == name) { + let path = e.path(); + if write { + match std::fs::remove_file(&path) { + Ok(()) => notes.push(format!("{}: removed", path.display())), + Err(err) => problems.push(format!("{}: {err}", path.display())), + } + } else { + problems.push(format!( + "{}: not written by xtask/src/bindings; run `cargo xtask bindings`", + path.display() + )); + } + } + } + } + if write && let Err(e) = std::fs::create_dir_all(&out_dir) { + problems.push(format!("{OUT_DIR}: {e}")); + return (problems, notes); + } + for (name, text) in &fresh { + let path = out_dir.join(name); + let shown = format!("{OUT_DIR}/{name}"); + let current = std::fs::read_to_string(&path).ok(); + if current.as_deref() == Some(text.as_str()) { + notes.push(format!("{shown}: up to date")); + } else if write { + match std::fs::write(&path, text) { + Ok(()) => notes.push(format!("{shown}: written")), + Err(e) => problems.push(format!("{shown}: {e}")), + } + } else if current.is_none() { + problems.push(format!("{shown}: missing; run `cargo xtask bindings`")); + } else { + problems.push(format!( + "{shown}: stale (differs from what xtask/src/bindings produces); \ + run `cargo xtask bindings` and commit the result" + )); + } + } + (problems, notes) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn data_dir() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")) + .join("..") + .join(DATA_DIR) + } + + /// Every vendored file parses on its own, and all of them resolve. + #[test] + fn every_vendored_file_parses() { + let dir = data_dir(); + let mut count = 0usize; + for e in std::fs::read_dir(&dir) + .map(|r| r.filter_map(Result::ok).collect::>()) + .unwrap_or_default() + { + let name = e.file_name().to_string_lossy().into_owned(); + if !name.ends_with(".idl") { + continue; + } + let text = std::fs::read_to_string(e.path()).unwrap_or_default(); + let parsed = parser::parse(&text); + assert!(parsed.is_ok(), "{name}: {:?}", parsed.err()); + assert!( + parsed.map(|d| !d.is_empty()).unwrap_or(false), + "{name}: nothing parsed" + ); + count = count.saturating_add(1); + } + assert_eq!(count, 8); + let model = load(&dir); + assert!(model.is_ok(), "{:?}", model.err()); + } +} diff --git a/xtask/src/bindings/model.rs b/xtask/src/bindings/model.rs new file mode 100644 index 00000000..65523d40 --- /dev/null +++ b/xtask/src/bindings/model.rs @@ -0,0 +1,358 @@ +//! The IDL model: what the parser produces for one file and what the +//! resolver produces for all of them (`resolve.rs`). The crate's +//! `clazel-webidl/src/model.rs` holds the same shapes as `'static` data; +//! `emit.rs` maps one to the other. + +/// An extended attribute (WebIDL §2.2 "Extended attributes"), in one of the +/// forms of that section. +#[derive(Debug, Clone, PartialEq)] +pub struct ExtAttr { + /// Its name (`ExtendedAttributeNoArgs`'s identifier). + pub name: String, + /// What follows the name. + pub value: ExtValue, +} + +/// What follows an extended attribute's name. +#[derive(Debug, Clone, PartialEq)] +pub enum ExtValue { + /// `[Name]`. + None, + /// `[Name=identifier]`. + Ident(String), + /// `[Name=(identifier, identifier)]`. + IdentList(Vec), + /// `[Name=*]`. + Wildcard, + /// `[Name=1]`, `[Name=1.5]` or `[Name="s"]`. + Literal(Value), + /// `[Name=(0, 8)]`: a list of integer, decimal or string literals. + LiteralList(Vec), + /// `[Name(arguments)]`. + Args(Vec), + /// `[Name=identifier(arguments)]`. + NamedArgs(String, Vec), +} + +/// Types the grammar spells with keywords alone. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Simple { + Any, + Undefined, + Boolean, + Byte, + Octet, + Bigint, + Object, + Symbol, + Short, + UnsignedShort, + Long, + UnsignedLong, + LongLong, + UnsignedLongLong, + Float, + UnrestrictedFloat, + Double, + UnrestrictedDouble, + ByteString, + DomString, + UsvString, +} + +/// A type without its nullability and extended attributes. +#[derive(Debug, Clone, PartialEq)] +pub enum TyKind { + /// A keyword type. + Simple(Simple), + /// A buffer-related type (`ArrayBuffer`, `Uint8Array`, ...), by name. + Buffer(String), + /// An identifier: an interface, dictionary, enum, typedef or callback. + Named(String), + /// `sequence`. + Sequence(Box), + /// `FrozenArray`. + FrozenArray(Box), + /// `ObservableArray`. + ObservableArray(Box), + /// `record`. + Record(Box, Box), + /// `Promise`. + Promise(Box), + /// `(A or B or ...)`. + Union(Vec), +} + +/// A type with its nullability and the extended attributes written on it. +#[derive(Debug, Clone, PartialEq)] +pub struct Ty { + /// The type. + pub kind: TyKind, + /// Followed by `?`. + pub nullable: bool, + /// `[Clamp] long` and the like. + pub ext: Vec, +} + +/// A literal: a constant's value or a default. +#[derive(Debug, Clone, PartialEq)] +pub enum Value { + /// `true` or `false`. + Bool(bool), + /// An integer, in the value its lexeme has (`0x10` is 16). + Integer(i128), + /// A decimal, as written. + Decimal(String), + /// `Infinity`. + Infinity, + /// `-Infinity`. + NegInfinity, + /// `NaN`. + NaN, + /// A string, without the quotes. + Str(String), + /// `[]`. + EmptySequence, + /// `{}`. + EmptyDictionary, + /// `null`. + Null, + /// `undefined`. + Undefined, +} + +/// An operation's or constructor's argument. +#[derive(Debug, Clone, PartialEq)] +pub struct Argument { + /// Extended attributes before it. + pub ext: Vec, + /// Its name. + pub name: String, + /// Its type. + pub ty: Ty, + /// `optional`. + pub optional: bool, + /// `...`. + pub variadic: bool, + /// `= value`. + pub default: Option, +} + +/// `const T NAME = value;`. +#[derive(Debug, Clone, PartialEq)] +pub struct Const { + /// Its name. + pub name: String, + /// Its type. + pub ty: Ty, + /// Its value. + pub value: Value, +} + +/// An attribute. +#[derive(Debug, Clone, PartialEq)] +pub struct Attribute { + /// Its name. + pub name: String, + /// Its type. + pub ty: Ty, + /// `readonly`. + pub readonly: bool, + /// `inherit`. + pub inherit: bool, + /// `static`. + pub is_static: bool, + /// `stringifier`. + pub stringifier: bool, +} + +/// What kind of operation. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum OpKind { + /// A regular operation. + Regular, + /// `static`. + Static, + /// `getter`. + Getter, + /// `setter`. + Setter, + /// `deleter`. + Deleter, + /// `stringifier;`. + Stringifier, +} + +/// An operation. +#[derive(Debug, Clone, PartialEq)] +pub struct Operation { + /// Its name, if it has one. + pub name: Option, + /// Its kind. + pub kind: OpKind, + /// Its return type. + pub ret: Ty, + /// Its arguments. + pub args: Vec, +} + +/// `iterable<...>` or `async iterable<...>`. +#[derive(Debug, Clone, PartialEq)] +pub struct Iterable { + /// `async iterable`. + pub is_async: bool, + /// The key type of the pair form. + pub key: Option, + /// The value type. + pub value: Ty, + /// The arguments of `async iterable<...>(...)`. + pub args: Vec, +} + +/// `maplike` or `setlike`. +#[derive(Debug, Clone, PartialEq)] +pub struct Collection { + /// `maplike` (else `setlike`). + pub is_map: bool, + /// `readonly`. + pub readonly: bool, + /// The key type of a maplike. + pub key: Option, + /// The value type (the element of a setlike). + pub value: Ty, +} + +/// What a member is. +#[derive(Debug, Clone, PartialEq)] +pub enum MemberKind { + /// A constant. + Const(Const), + /// An attribute. + Attribute(Attribute), + /// An operation. + Operation(Operation), + /// `constructor(...)`, with its arguments. + Constructor(Vec), + /// An iterable or async iterable. + Iterable(Iterable), + /// A maplike or setlike. + Collection(Collection), +} + +/// A member of an interface, mixin, callback interface or namespace. +#[derive(Debug, Clone, PartialEq)] +pub struct Member { + /// Its extended attributes (after resolution, with those a partial or + /// mixin passes on, `resolve.rs`). + pub ext: Vec, + /// What it is. + pub kind: MemberKind, + /// The mixin it came from through `includes`; set by the resolver. + pub mixin: Option, +} + +/// A dictionary member. +#[derive(Debug, Clone, PartialEq)] +pub struct DictMember { + /// Its extended attributes. + pub ext: Vec, + /// Its name. + pub name: String, + /// Its type. + pub ty: Ty, + /// `required`. + pub required: bool, + /// `= value`. + pub default: Option, +} + +/// One top-level definition of a file (WebIDL §2 `Definition`). +#[derive(Debug, Clone, PartialEq)] +pub enum Definition { + /// `interface`, `partial interface` and `callback interface`. + Interface { + /// Extended attributes. + ext: Vec, + /// Name. + name: String, + /// The `: Parent`. + parent: Option, + /// `partial`. + partial: bool, + /// `callback interface`. + callback: bool, + /// Members. + members: Vec, + }, + /// `interface mixin` and `partial interface mixin`. + Mixin { + /// Extended attributes. + ext: Vec, + /// Name. + name: String, + /// `partial`. + partial: bool, + /// Members. + members: Vec, + }, + /// `namespace` and `partial namespace`. + Namespace { + /// Extended attributes. + ext: Vec, + /// Name. + name: String, + /// `partial`. + partial: bool, + /// Members. + members: Vec, + }, + /// `dictionary` and `partial dictionary`. + Dictionary { + /// Extended attributes. + ext: Vec, + /// Name. + name: String, + /// The `: Parent`. + parent: Option, + /// `partial`. + partial: bool, + /// Members. + members: Vec, + }, + /// `enum`. + Enum { + /// Extended attributes. + ext: Vec, + /// Name. + name: String, + /// Values. + values: Vec, + }, + /// `typedef`. + Typedef { + /// Extended attributes. + ext: Vec, + /// Name. + name: String, + /// The aliased type. + ty: Ty, + }, + /// `callback Name = Return (args);`. + Callback { + /// Extended attributes. + ext: Vec, + /// Name. + name: String, + /// Return type. + ret: Ty, + /// Arguments. + args: Vec, + }, + /// `Target includes Mixin;`. + Includes { + /// The interface. + target: String, + /// The mixin. + mixin: String, + }, +} diff --git a/xtask/src/bindings/parser.rs b/xtask/src/bindings/parser.rs new file mode 100644 index 00000000..e386c5ca --- /dev/null +++ b/xtask/src/bindings/parser.rs @@ -0,0 +1,1489 @@ +//! The WebIDL parser: a recursive-descent reading of the grammar of WebIDL +//! §2 "Interface definition language" +//! (). Each function names the +//! production it reads, in the standard's spelling. +//! +//! Modelling choices (the grammar is read, not extended): +//! - The forms of extended attribute of WebIDL §2.2 are parsed (no +//! arguments, argument list, named argument list, identifier, identifier +//! list), with literals and lists of literals as values too (HTML's +//! `[ReflectRange=(0, 8)]` needs them); the grammar's catch-all +//! `ExtendedAttributeRest` (free-form token sequences) is rejected, as it +//! has no meaning to give. +//! - A keyword is an identifier the grammar spells as a terminal; one is +//! accepted as a name only where the grammar says so (`ArgumentNameKeyword`, +//! `AttributeNameKeyword`, `OperationNameKeyword`) or when written with a +//! leading `_`. +//! - Which members a container takes (`PartialInterfaceMember`, +//! `MixinMember`, `CallbackInterfaceMember`, `NamespaceMember`) is checked +//! after the member is read, with the container named in the error. +//! - Semantic rules (WebIDL §2.5 and the per-feature rules) are not checked +//! here; `resolve.rs` checks what the model needs (names, partials, +//! includes, references). + +use super::lexer::{Tok, Token, lex}; +use super::model::{ + Argument, Attribute, Collection, Const, Definition, DictMember, ExtAttr, ExtValue, Iterable, + Member, MemberKind, OpKind, Operation, Simple, Ty, TyKind, Value, +}; + +/// The terminals of the grammar that look like identifiers. +const KEYWORDS: &[&str] = &[ + "ArrayBuffer", + "BigInt64Array", + "BigUint64Array", + "ByteString", + "DOMString", + "DataView", + "Float16Array", + "Float32Array", + "Float64Array", + "FrozenArray", + "Infinity", + "Int16Array", + "Int32Array", + "Int8Array", + "NaN", + "ObservableArray", + "Promise", + "SharedArrayBuffer", + "USVString", + "Uint16Array", + "Uint32Array", + "Uint8Array", + "Uint8ClampedArray", + "any", + "async", + "attribute", + "bigint", + "boolean", + "byte", + "callback", + "const", + "constructor", + "deleter", + "dictionary", + "double", + "enum", + "false", + "float", + "getter", + "includes", + "inherit", + "interface", + "iterable", + "long", + "maplike", + "mixin", + "namespace", + "null", + "object", + "octet", + "optional", + "or", + "partial", + "readonly", + "record", + "required", + "sequence", + "setlike", + "setter", + "short", + "static", + "stringifier", + "symbol", + "true", + "typedef", + "undefined", + "unrestricted", + "unsigned", +]; + +/// `ArgumentNameKeyword`. +const ARGUMENT_NAME_KEYWORDS: &[&str] = &[ + "async", + "attribute", + "callback", + "const", + "constructor", + "deleter", + "dictionary", + "enum", + "getter", + "includes", + "inherit", + "interface", + "iterable", + "maplike", + "mixin", + "namespace", + "partial", + "readonly", + "required", + "setlike", + "setter", + "static", + "stringifier", + "typedef", + "unrestricted", +]; + +/// `BufferRelatedType`. +const BUFFER_TYPES: &[&str] = &[ + "ArrayBuffer", + "SharedArrayBuffer", + "DataView", + "Int8Array", + "Int16Array", + "Int32Array", + "Uint8Array", + "Uint16Array", + "Uint32Array", + "Uint8ClampedArray", + "BigInt64Array", + "BigUint64Array", + "Float16Array", + "Float32Array", + "Float64Array", +]; + +/// Where a member is being read, for the `*Member` productions. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum Container { + Interface, + PartialInterface, + Mixin, + CallbackInterface, + Namespace, +} + +impl Container { + fn name(self) -> &'static str { + match self { + Self::Interface => "interface", + Self::PartialInterface => "partial interface", + Self::Mixin => "interface mixin", + Self::CallbackInterface => "callback interface", + Self::Namespace => "namespace", + } + } +} + +struct Parser { + toks: Vec, + pos: usize, + last_line: u32, +} + +/// Parse one IDL file (`Definitions`). +pub fn parse(src: &str) -> Result, String> { + let toks = lex(src)?; + let last_line = toks.last().map_or(1, |t| t.line); + let mut p = Parser { + toks, + pos: 0, + last_line, + }; + p.definitions() +} + +type R = Result; + +impl Parser { + fn peek(&self) -> Option<&Tok> { + self.toks.get(self.pos).map(|t| &t.tok) + } + + fn peek_at(&self, n: usize) -> Option<&Tok> { + self.toks.get(self.pos.saturating_add(n)).map(|t| &t.tok) + } + + fn line(&self) -> u32 { + self.toks.get(self.pos).map_or(self.last_line, |t| t.line) + } + + fn err(&self, msg: &str) -> R { + let found = match self.peek() { + Some(Tok::Ident { name, .. }) => format!("`{name}`"), + Some(Tok::Integer(s) | Tok::Decimal(s)) => format!("`{s}`"), + Some(Tok::Str(s)) => format!("\"{s}\""), + Some(Tok::Ellipsis) => "`...`".to_owned(), + Some(Tok::Punct(c)) => format!("`{c}`"), + None => "end of file".to_owned(), + }; + Err(format!("{}: {msg}, found {found}", self.line())) + } + + fn advance(&mut self) { + self.pos = self.pos.saturating_add(1); + } + + fn kw_at(&self, n: usize, kw: &str) -> bool { + matches!(self.peek_at(n), Some(Tok::Ident { name, escaped: false }) if name == kw) + } + + fn is_kw(&self, kw: &str) -> bool { + self.kw_at(0, kw) + } + + fn eat_kw(&mut self, kw: &str) -> bool { + let found = self.is_kw(kw); + if found { + self.advance(); + } + found + } + + fn expect_kw(&mut self, kw: &str) -> R<()> { + if self.eat_kw(kw) { + Ok(()) + } else { + self.err(&format!("expected `{kw}`")) + } + } + + fn is_punct(&self, c: char) -> bool { + self.peek() == Some(&Tok::Punct(c)) + } + + fn eat_punct(&mut self, c: char) -> bool { + let found = self.is_punct(c); + if found { + self.advance(); + } + found + } + + fn expect_punct(&mut self, c: char) -> R<()> { + if self.eat_punct(c) { + Ok(()) + } else { + self.err(&format!("expected `{c}`")) + } + } + + /// The token `identifier`: not a keyword, unless escaped. + fn identifier(&mut self) -> R { + if let Some(Tok::Ident { name, escaped }) = self.peek() + && (*escaped || !KEYWORDS.contains(&name.as_str())) + { + let name = name.clone(); + self.advance(); + return Ok(name); + } + self.err("expected an identifier") + } + + /// An identifier, or one of the keywords `allowed`. + fn identifier_or(&mut self, allowed: &[&str]) -> R { + if let Some(Tok::Ident { + name, + escaped: false, + }) = self.peek() + && allowed.contains(&name.as_str()) + { + let name = name.clone(); + self.advance(); + return Ok(name); + } + self.identifier() + } + + /// Any identifier token, keyword or not (extended attribute names and + /// values, which the standard's per-attribute grammar defines). + fn any_ident(&mut self) -> R { + if let Some(Tok::Ident { name, .. }) = self.peek() { + let name = name.clone(); + self.advance(); + return Ok(name); + } + self.err("expected an identifier") + } + + fn string(&mut self) -> R { + if let Some(Tok::Str(s)) = self.peek() { + let s = s.clone(); + self.advance(); + return Ok(s); + } + self.err("expected a string") + } + + // ---- Definitions ---- + + /// `Definitions`. + fn definitions(&mut self) -> R> { + let mut out = Vec::new(); + while self.peek().is_some() { + let ext = self.extended_attribute_list()?; + out.push(self.definition(ext)?); + } + Ok(out) + } + + /// `Definition`. + fn definition(&mut self, ext: Vec) -> R { + if self.eat_kw("callback") { + return self.callback_rest_or_interface(ext); + } + if self.eat_kw("interface") { + return self.interface_or_mixin(ext, false); + } + if self.eat_kw("partial") { + return self.partial_definition(ext); + } + if self.is_kw("namespace") { + return self.namespace(ext, false); + } + if self.is_kw("dictionary") { + return self.dictionary(ext, false); + } + if self.eat_kw("enum") { + return self.enumeration(ext); + } + if self.eat_kw("typedef") { + let ty = self.type_with_extended_attributes()?; + let name = self.identifier()?; + self.expect_punct(';')?; + return Ok(Definition::Typedef { ext, name, ty }); + } + // IncludesStatement ::= identifier includes identifier ; + if matches!(self.peek(), Some(Tok::Ident { .. })) && self.kw_at(1, "includes") { + let target = self.identifier()?; + self.expect_kw("includes")?; + let mixin = self.identifier()?; + self.expect_punct(';')?; + if !ext.is_empty() { + return self.err("an includes statement takes no extended attributes"); + } + return Ok(Definition::Includes { target, mixin }); + } + self.err("expected a definition") + } + + /// `CallbackOrInterfaceOrMixin ::= callback CallbackRestOrInterface`, + /// after `callback`. + fn callback_rest_or_interface(&mut self, ext: Vec) -> R { + if self.eat_kw("interface") { + // callback interface identifier { CallbackInterfaceMembers } ; + let name = self.identifier()?; + self.expect_punct('{')?; + let members = self.members(Container::CallbackInterface)?; + self.expect_punct(';')?; + return Ok(Definition::Interface { + ext, + name, + parent: None, + partial: false, + callback: true, + members, + }); + } + // CallbackRest ::= identifier = Type ( ArgumentList ) ; + let name = self.identifier()?; + self.expect_punct('=')?; + let ret = self.type_()?; + self.expect_punct('(')?; + let args = self.argument_list()?; + self.expect_punct(')')?; + self.expect_punct(';')?; + Ok(Definition::Callback { + ext, + name, + ret, + args, + }) + } + + /// `InterfaceOrMixin ::= InterfaceRest | MixinRest`, after `interface` + /// (`PartialInterfaceOrPartialMixin` when `partial`). + fn interface_or_mixin(&mut self, ext: Vec, partial: bool) -> R { + if self.eat_kw("mixin") { + // MixinRest ::= mixin identifier { MixinMembers } ; + let name = self.identifier()?; + self.expect_punct('{')?; + let members = self.members(Container::Mixin)?; + self.expect_punct(';')?; + return Ok(Definition::Mixin { + ext, + name, + partial, + members, + }); + } + // InterfaceRest ::= identifier Inheritance { InterfaceMembers } ; + // PartialInterfaceRest ::= identifier { PartialInterfaceMembers } ; + let name = self.identifier()?; + let parent = if partial { None } else { self.inheritance()? }; + self.expect_punct('{')?; + let container = if partial { + Container::PartialInterface + } else { + Container::Interface + }; + let members = self.members(container)?; + self.expect_punct(';')?; + Ok(Definition::Interface { + ext, + name, + parent, + partial, + callback: false, + members, + }) + } + + /// `Partial ::= partial PartialDefinition`, after `partial`. + fn partial_definition(&mut self, ext: Vec) -> R { + if self.eat_kw("interface") { + return self.interface_or_mixin(ext, true); + } + if self.is_kw("dictionary") { + return self.dictionary(ext, true); + } + if self.is_kw("namespace") { + return self.namespace(ext, true); + } + self.err("expected `interface`, `dictionary` or `namespace` after `partial`") + } + + /// `Inheritance ::= : identifier | ε`. + fn inheritance(&mut self) -> R> { + if self.eat_punct(':') { + return Ok(Some(self.identifier()?)); + } + Ok(None) + } + + /// `Namespace ::= namespace identifier { NamespaceMembers } ;`. + fn namespace(&mut self, ext: Vec, partial: bool) -> R { + self.expect_kw("namespace")?; + let name = self.identifier()?; + self.expect_punct('{')?; + let members = self.members(Container::Namespace)?; + self.expect_punct(';')?; + Ok(Definition::Namespace { + ext, + name, + partial, + members, + }) + } + + /// `Dictionary ::= dictionary identifier Inheritance { DictionaryMembers } ;` + /// and `PartialDictionary`. + fn dictionary(&mut self, ext: Vec, partial: bool) -> R { + self.expect_kw("dictionary")?; + let name = self.identifier()?; + let parent = if partial { None } else { self.inheritance()? }; + self.expect_punct('{')?; + let mut members = Vec::new(); + while !self.eat_punct('}') { + // DictionaryMember ::= ExtendedAttributeList DictionaryMemberRest + let mext = self.extended_attribute_list()?; + let required = self.eat_kw("required"); + let ty = if required { + self.type_with_extended_attributes()? + } else { + self.type_()? + }; + let mname = self.identifier()?; + let default = self.default()?; + self.expect_punct(';')?; + members.push(DictMember { + ext: mext, + name: mname, + ty, + required, + default, + }); + } + self.expect_punct(';')?; + Ok(Definition::Dictionary { + ext, + name, + parent, + partial, + members, + }) + } + + /// `Enum ::= enum identifier { EnumValueList } ;`, after `enum`. + fn enumeration(&mut self, ext: Vec) -> R { + let name = self.identifier()?; + self.expect_punct('{')?; + let mut values = vec![self.string()?]; + while self.eat_punct(',') { + // EnumValueListComma allows a trailing comma. + if self.is_punct('}') { + break; + } + values.push(self.string()?); + } + self.expect_punct('}')?; + self.expect_punct(';')?; + Ok(Definition::Enum { ext, name, values }) + } + + // ---- Members ---- + + /// The members of a container up to and including its `}`. + fn members(&mut self, container: Container) -> R> { + let mut out = Vec::new(); + while !self.eat_punct('}') { + let ext = self.extended_attribute_list()?; + let line = self.line(); + let kind = self.member(container)?; + if !allowed(container, &kind) { + return Err(format!( + "{line}: this kind of member is not allowed in a {}", + container.name() + )); + } + out.push(Member { + ext, + kind, + mixin: None, + }); + } + Ok(out) + } + + /// `InterfaceMember`, and the other containers' member productions. + fn member(&mut self, container: Container) -> R { + if self.eat_kw("const") { + return self.constant(); + } + // Constructor ::= constructor ( ArgumentList ) ; + if self.is_kw("constructor") && matches!(self.peek_at(1), Some(Tok::Punct('('))) { + self.advance(); + self.advance(); + let args = self.argument_list()?; + self.expect_punct(')')?; + self.expect_punct(';')?; + return Ok(MemberKind::Constructor(args)); + } + if self.eat_kw("stringifier") { + // StringifierRest ::= OptionalReadOnly AttributeRest | ; + if self.eat_punct(';') { + return Ok(MemberKind::Operation(Operation { + name: None, + kind: OpKind::Stringifier, + ret: simple(Simple::DomString), + args: Vec::new(), + })); + } + let readonly = self.eat_kw("readonly"); + return self.attribute_rest(readonly, false, false, true); + } + if self.eat_kw("static") { + // StaticMemberRest ::= OptionalReadOnly AttributeRest | RegularOperation + if self.is_kw("readonly") || self.is_kw("attribute") { + let readonly = self.eat_kw("readonly"); + return self.attribute_rest(readonly, false, true, false); + } + return self.regular_operation(OpKind::Static); + } + if self.is_kw("iterable") || (self.is_kw("async") && self.kw_at(1, "iterable")) { + return self.iterable(); + } + if self.is_kw("maplike") || self.is_kw("setlike") { + return self.maplike_setlike(false); + } + if self.eat_kw("readonly") { + // ReadOnlyMember ::= readonly ReadOnlyMemberRest + if self.is_kw("maplike") || self.is_kw("setlike") { + return self.maplike_setlike(true); + } + return self.attribute_rest(true, false, false, false); + } + if self.eat_kw("inherit") { + return self.attribute_rest(false, true, false, false); + } + if self.is_kw("attribute") { + return self.attribute_rest(false, false, false, false); + } + // Special ::= getter | setter | deleter + for (kw, kind) in [ + ("getter", OpKind::Getter), + ("setter", OpKind::Setter), + ("deleter", OpKind::Deleter), + ] { + if self.eat_kw(kw) { + return self.regular_operation(kind); + } + } + let _ = container; + self.regular_operation(OpKind::Regular) + } + + /// `Const ::= const ConstType identifier = ConstValue ;`, after `const`. + fn constant(&mut self) -> R { + // ConstType ::= PrimitiveType | identifier + let ty = if self.is_primitive_start() { + self.distinguishable_type()? + } else { + let name = self.identifier()?; + Ty { + kind: TyKind::Named(name), + nullable: false, + ext: Vec::new(), + } + }; + let name = self.identifier()?; + self.expect_punct('=')?; + let value = self.const_value()?; + self.expect_punct(';')?; + Ok(MemberKind::Const(Const { name, ty, value })) + } + + /// `AttributeRest ::= attribute TypeWithExtendedAttributes AttributeName ;` + fn attribute_rest( + &mut self, + readonly: bool, + inherit: bool, + is_static: bool, + stringifier: bool, + ) -> R { + self.expect_kw("attribute")?; + let ty = self.type_with_extended_attributes()?; + // AttributeName ::= AttributeNameKeyword | identifier + let name = self.identifier_or(&["async", "required"])?; + self.expect_punct(';')?; + Ok(MemberKind::Attribute(Attribute { + name, + ty, + readonly, + inherit, + is_static, + stringifier, + })) + } + + /// `RegularOperation ::= Type OperationRest`. + fn regular_operation(&mut self, kind: OpKind) -> R { + let ret = self.type_()?; + // OptionalOperationName ::= OperationName | ε + let name = if self.is_punct('(') { + None + } else { + Some(self.identifier_or(&["includes"])?) + }; + self.expect_punct('(')?; + let args = self.argument_list()?; + self.expect_punct(')')?; + self.expect_punct(';')?; + Ok(MemberKind::Operation(Operation { + name, + kind, + ret, + args, + })) + } + + /// `Iterable` and `AsyncIterable`. + fn iterable(&mut self) -> R { + let is_async = self.eat_kw("async"); + self.expect_kw("iterable")?; + self.expect_punct('<')?; + let first = self.type_with_extended_attributes()?; + let (key, value) = if self.eat_punct(',') { + (Some(first), self.type_with_extended_attributes()?) + } else { + (None, first) + }; + self.expect_punct('>')?; + let mut args = Vec::new(); + if is_async && self.eat_punct('(') { + args = self.argument_list()?; + self.expect_punct(')')?; + } + self.expect_punct(';')?; + Ok(MemberKind::Iterable(Iterable { + is_async, + key, + value, + args, + })) + } + + /// `MaplikeRest` and `SetlikeRest`. + fn maplike_setlike(&mut self, readonly: bool) -> R { + let is_map = self.is_kw("maplike"); + self.advance(); + self.expect_punct('<')?; + let first = self.type_with_extended_attributes()?; + let (key, value) = if is_map { + self.expect_punct(',')?; + (Some(first), self.type_with_extended_attributes()?) + } else { + (None, first) + }; + self.expect_punct('>')?; + self.expect_punct(';')?; + Ok(MemberKind::Collection(Collection { + is_map, + readonly, + key, + value, + })) + } + + // ---- Arguments, values ---- + + /// `ArgumentList`, up to but not including the `)`. + fn argument_list(&mut self) -> R> { + let mut out = Vec::new(); + if self.is_punct(')') { + return Ok(out); + } + loop { + out.push(self.argument()?); + if !self.eat_punct(',') { + return Ok(out); + } + } + } + + /// `Argument ::= ExtendedAttributeList ArgumentRest`. + fn argument(&mut self) -> R { + let ext = self.extended_attribute_list()?; + if self.eat_kw("optional") { + let ty = self.type_with_extended_attributes()?; + let name = self.identifier_or(ARGUMENT_NAME_KEYWORDS)?; + let default = self.default()?; + return Ok(Argument { + ext, + name, + ty, + optional: true, + variadic: false, + default, + }); + } + let ty = self.type_()?; + let variadic = self.peek() == Some(&Tok::Ellipsis); + if variadic { + self.advance(); + } + let name = self.identifier_or(ARGUMENT_NAME_KEYWORDS)?; + Ok(Argument { + ext, + name, + ty, + optional: false, + variadic, + default: None, + }) + } + + /// `Default ::= = DefaultValue | ε`. + fn default(&mut self) -> R> { + if !self.eat_punct('=') { + return Ok(None); + } + // DefaultValue ::= ConstValue | string | [ ] | { } | null | undefined + if let Some(Tok::Str(s)) = self.peek() { + let v = Value::Str(s.clone()); + self.advance(); + return Ok(Some(v)); + } + if self.eat_punct('[') { + self.expect_punct(']')?; + return Ok(Some(Value::EmptySequence)); + } + if self.eat_punct('{') { + self.expect_punct('}')?; + return Ok(Some(Value::EmptyDictionary)); + } + if self.eat_kw("null") { + return Ok(Some(Value::Null)); + } + if self.eat_kw("undefined") { + return Ok(Some(Value::Undefined)); + } + Ok(Some(self.const_value()?)) + } + + /// `ConstValue ::= BooleanLiteral | FloatLiteral | integer`. + fn const_value(&mut self) -> R { + let v = match self.peek() { + Some(Tok::Ident { + name, + escaped: false, + }) => match name.as_str() { + "true" => Value::Bool(true), + "false" => Value::Bool(false), + "Infinity" => Value::Infinity, + "-Infinity" => Value::NegInfinity, + "NaN" => Value::NaN, + _ => return self.err("expected a constant value"), + }, + Some(Tok::Decimal(s)) => Value::Decimal(s.clone()), + Some(Tok::Integer(s)) => match integer_value(s) { + Some(n) => Value::Integer(n), + None => return self.err("integer out of range"), + }, + _ => return self.err("expected a constant value"), + }; + self.advance(); + Ok(v) + } + + // ---- Extended attributes ---- + + /// `ExtendedAttributeList ::= [ ExtendedAttribute ExtendedAttributes ] | ε`. + fn extended_attribute_list(&mut self) -> R> { + let mut out = Vec::new(); + if !self.eat_punct('[') { + return Ok(out); + } + loop { + out.push(self.extended_attribute()?); + if self.eat_punct(',') { + continue; + } + self.expect_punct(']')?; + return Ok(out); + } + } + + /// `ExtendedAttribute`, in the five forms of WebIDL §2.2: no arguments, + /// argument list, named argument list, identifier, identifier list + /// (and the wildcard form of `[Exposed=*]`). + fn extended_attribute(&mut self) -> R { + let name = self.any_ident()?; + let value = if self.eat_punct('=') { + if self.eat_punct('*') { + ExtValue::Wildcard + } else if self.eat_punct('(') { + self.ext_list_value()? + } else if let Some(v) = self.literal() { + ExtValue::Literal(v) + } else { + let value = self.any_ident()?; + if self.eat_punct('(') { + let args = self.argument_list()?; + self.expect_punct(')')?; + ExtValue::NamedArgs(value, args) + } else { + ExtValue::Ident(value) + } + } + } else if self.eat_punct('(') { + let args = self.argument_list()?; + self.expect_punct(')')?; + ExtValue::Args(args) + } else { + ExtValue::None + }; + Ok(ExtAttr { name, value }) + } + + /// The inside of `[Name=( ... )]`, after the `(`: identifiers or + /// literals, not mixed. + fn ext_list_value(&mut self) -> R { + if matches!(self.peek(), Some(Tok::Ident { .. })) { + let mut list = vec![self.any_ident()?]; + while self.eat_punct(',') { + list.push(self.any_ident()?); + } + self.expect_punct(')')?; + return Ok(ExtValue::IdentList(list)); + } + let mut list = Vec::new(); + loop { + match self.literal() { + Some(v) => list.push(v), + None => return self.err("expected an identifier or a literal"), + } + if !self.eat_punct(',') { + break; + } + } + self.expect_punct(')')?; + Ok(ExtValue::LiteralList(list)) + } + + /// An `integer`, `decimal` or `string` token, consumed. + fn literal(&mut self) -> Option { + let v = match self.peek()? { + Tok::Integer(s) => Value::Integer(integer_value(s)?), + Tok::Decimal(s) => Value::Decimal(s.clone()), + Tok::Str(s) => Value::Str(s.clone()), + _ => return None, + }; + self.advance(); + Some(v) + } + + // ---- Types ---- + + /// `TypeWithExtendedAttributes ::= ExtendedAttributeList Type`. + fn type_with_extended_attributes(&mut self) -> R { + let ext = self.extended_attribute_list()?; + let mut ty = self.type_()?; + ty.ext = ext; + Ok(ty) + } + + /// `Type ::= SingleType | UnionType Null`. + fn type_(&mut self) -> R { + if self.is_punct('(') { + return self.union_type(); + } + // SingleType ::= DistinguishableType | any | PromiseType + if self.eat_kw("any") { + return Ok(simple(Simple::Any)); + } + if self.eat_kw("Promise") { + self.expect_punct('<')?; + let inner = self.type_()?; + self.expect_punct('>')?; + return Ok(Ty { + kind: TyKind::Promise(Box::new(inner)), + nullable: false, + ext: Vec::new(), + }); + } + self.distinguishable_type() + } + + /// `UnionType ::= ( UnionMemberType or UnionMemberType UnionMemberTypes )` + /// followed by `Null`. + fn union_type(&mut self) -> R { + self.expect_punct('(')?; + let mut members = vec![self.union_member_type()?]; + self.expect_kw("or")?; + members.push(self.union_member_type()?); + while self.eat_kw("or") { + members.push(self.union_member_type()?); + } + self.expect_punct(')')?; + let nullable = self.eat_punct('?'); + Ok(Ty { + kind: TyKind::Union(members), + nullable, + ext: Vec::new(), + }) + } + + /// `UnionMemberType ::= ExtendedAttributeList DistinguishableType | UnionType Null`. + fn union_member_type(&mut self) -> R { + let ext = self.extended_attribute_list()?; + let mut ty = if self.is_punct('(') { + self.union_type()? + } else { + self.distinguishable_type()? + }; + ty.ext = ext; + Ok(ty) + } + + /// Whether a `PrimitiveType` starts here. + fn is_primitive_start(&self) -> bool { + [ + "unsigned", + "unrestricted", + "short", + "long", + "float", + "double", + "undefined", + "boolean", + "byte", + "octet", + "bigint", + ] + .iter() + .any(|k| self.is_kw(k)) + } + + /// `DistinguishableType`. + fn distinguishable_type(&mut self) -> R { + let kind = if let Some(s) = self.primitive_type()? { + TyKind::Simple(s) + } else if let Some(Tok::Ident { + name, + escaped: false, + }) = self.peek().cloned() + { + match name.as_str() { + "ByteString" => self.keyword_type(Simple::ByteString), + "DOMString" => self.keyword_type(Simple::DomString), + "USVString" => self.keyword_type(Simple::UsvString), + "object" => self.keyword_type(Simple::Object), + "symbol" => self.keyword_type(Simple::Symbol), + "sequence" | "FrozenArray" | "ObservableArray" => { + self.advance(); + self.expect_punct('<')?; + let inner = Box::new(self.type_with_extended_attributes()?); + self.expect_punct('>')?; + match name.as_str() { + "sequence" => TyKind::Sequence(inner), + "FrozenArray" => TyKind::FrozenArray(inner), + _ => TyKind::ObservableArray(inner), + } + } + "record" => { + self.advance(); + self.expect_punct('<')?; + // RecordType ::= record < StringType , TypeWithExtendedAttributes > + let key = match self.peek() { + Some(Tok::Ident { name, .. }) + if matches!( + name.as_str(), + "ByteString" | "DOMString" | "USVString" + ) => + { + self.distinguishable_type_no_null()? + } + _ => return self.err("expected a string type as the record key"), + }; + self.expect_punct(',')?; + let value = self.type_with_extended_attributes()?; + self.expect_punct('>')?; + TyKind::Record(Box::new(key), Box::new(value)) + } + n if BUFFER_TYPES.contains(&n) => { + self.advance(); + TyKind::Buffer(name.clone()) + } + _ => TyKind::Named(self.identifier()?), + } + } else { + return self.err("expected a type"); + }; + let nullable = self.eat_punct('?'); + Ok(Ty { + kind, + nullable, + ext: Vec::new(), + }) + } + + /// A `StringType` with no `Null` after it. + fn distinguishable_type_no_null(&mut self) -> R { + let simple_kind = match self.peek() { + Some(Tok::Ident { name, .. }) => match name.as_str() { + "ByteString" => Simple::ByteString, + "DOMString" => Simple::DomString, + _ => Simple::UsvString, + }, + _ => return self.err("expected a string type"), + }; + self.advance(); + Ok(simple(simple_kind)) + } + + fn keyword_type(&mut self, s: Simple) -> TyKind { + self.advance(); + TyKind::Simple(s) + } + + /// `PrimitiveType`, if one starts here. + fn primitive_type(&mut self) -> R> { + let Some(Tok::Ident { + name, + escaped: false, + }) = self.peek().cloned() + else { + return Ok(None); + }; + let simple = match name.as_str() { + "undefined" => { + self.advance(); + Simple::Undefined + } + "boolean" => { + self.advance(); + Simple::Boolean + } + "byte" => { + self.advance(); + Simple::Byte + } + "octet" => { + self.advance(); + Simple::Octet + } + "bigint" => { + self.advance(); + Simple::Bigint + } + "unsigned" => { + // UnsignedIntegerType ::= unsigned IntegerType + self.advance(); + match self.integer_type()? { + Simple::Short => Simple::UnsignedShort, + Simple::Long => Simple::UnsignedLong, + _ => Simple::UnsignedLongLong, + } + } + "short" | "long" => self.integer_type()?, + "unrestricted" => { + // UnrestrictedFloatType ::= unrestricted FloatType + self.advance(); + if self.eat_kw("float") { + Simple::UnrestrictedFloat + } else if self.eat_kw("double") { + Simple::UnrestrictedDouble + } else { + return self.err("expected `float` or `double` after `unrestricted`"); + } + } + "float" => { + self.advance(); + Simple::Float + } + "double" => { + self.advance(); + Simple::Double + } + _ => return Ok(None), + }; + Ok(Some(simple)) + } + + /// `IntegerType ::= short | long OptionalLong`; `Short`, `Long` or + /// `LongLong`. + fn integer_type(&mut self) -> R { + if self.eat_kw("short") { + return Ok(Simple::Short); + } + if self.eat_kw("long") { + return Ok(if self.eat_kw("long") { + Simple::LongLong + } else { + Simple::Long + }); + } + self.err("expected `short` or `long`") + } +} + +fn simple(s: Simple) -> Ty { + Ty { + kind: TyKind::Simple(s), + nullable: false, + ext: Vec::new(), + } +} + +/// The value of an `integer` token: decimal, `0x` hexadecimal or `0` octal. +fn integer_value(s: &str) -> Option { + let (neg, digits) = match s.strip_prefix('-') { + Some(rest) => (true, rest), + None => (false, s), + }; + let magnitude = if let Some(hex) = digits + .strip_prefix("0x") + .or_else(|| digits.strip_prefix("0X")) + { + i128::from_str_radix(hex, 16).ok()? + } else if digits.len() > 1 && digits.starts_with('0') { + i128::from_str_radix(digits, 8).ok()? + } else { + digits.parse::().ok()? + }; + if neg { + magnitude.checked_neg() + } else { + Some(magnitude) + } +} + +/// Whether `container`'s member production includes this kind of member. +fn allowed(container: Container, kind: &MemberKind) -> bool { + match (container, kind) { + (Container::Interface, _) => true, + (Container::PartialInterface, MemberKind::Constructor(_)) => false, + (Container::PartialInterface, _) => true, + // MixinMember ::= Const | RegularOperation | Stringifier | OptionalReadOnly AttributeRest + (Container::Mixin, MemberKind::Const(_)) => true, + (Container::Mixin, MemberKind::Attribute(a)) => !a.is_static && !a.inherit, + (Container::Mixin, MemberKind::Operation(o)) => { + matches!(o.kind, OpKind::Regular | OpKind::Stringifier) + } + // CallbackInterfaceMember ::= Const | RegularOperation + (Container::CallbackInterface, MemberKind::Const(_)) => true, + (Container::CallbackInterface, MemberKind::Operation(o)) => o.kind == OpKind::Regular, + // NamespaceMember ::= RegularOperation | readonly AttributeRest | Const + (Container::Namespace, MemberKind::Const(_)) => true, + (Container::Namespace, MemberKind::Attribute(a)) => { + a.readonly && !a.is_static && !a.inherit && !a.stringifier + } + (Container::Namespace, MemberKind::Operation(o)) => o.kind == OpKind::Regular, + _ => false, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn one(src: &str) -> Result { + let mut defs = parse(src)?; + if defs.len() == 1 { + Ok(defs.remove(0)) + } else { + Err(format!("{src:?}: {} definitions", defs.len())) + } + } + + /// The first attribute's type in `interface I { attribute a; };`. + fn ty(src: &str) -> Ty { + if let Ok(Definition::Interface { members, .. }) = + one(&format!("interface I {{ attribute {src} a; }};")) + && let Some(Member { + kind: MemberKind::Attribute(a), + .. + }) = members.into_iter().next() + { + return a.ty; + } + simple(Simple::Any) + } + + #[test] + fn integer_and_float_types() { + assert_eq!(ty("unsigned long long"), simple(Simple::UnsignedLongLong)); + assert_eq!(ty("long long"), simple(Simple::LongLong)); + assert_eq!(ty("unsigned short"), simple(Simple::UnsignedShort)); + assert_eq!( + ty("unrestricted double"), + simple(Simple::UnrestrictedDouble) + ); + assert_eq!(ty("float"), simple(Simple::Float)); + assert!(parse("interface I { attribute unsigned float a; };").is_err()); + assert!(parse("interface I { attribute unrestricted long a; };").is_err()); + } + + #[test] + fn nullable_unions_and_generics() -> Result<(), String> { + let t = ty("(DOMString or sequence<(long or Node)?>)?"); + assert!(t.nullable); + let TyKind::Union(members) = t.kind else { + return Err("not a union".into()); + }; + assert_eq!(members.len(), 2); + let Some(TyKind::Sequence(inner)) = members.get(1).map(|m| m.kind.clone()) else { + return Err("not a sequence".into()); + }; + assert!(inner.nullable); + assert!(matches!(inner.kind, TyKind::Union(ref m) if m.len() == 2)); + // A union takes at least two members. + assert!(parse("interface I { attribute (long) a; };").is_err()); + Ok(()) + } + + #[test] + fn record_promise_frozen_array_observable_array_buffers() { + let t = ty("record>"); + assert!( + matches!(t.kind, TyKind::Record(ref k, _) if k.kind == TyKind::Simple(Simple::UsvString)) + ); + assert!(parse("interface I { attribute record a; };").is_err()); + let t = ty("Promise"); + assert!( + matches!(t.kind, TyKind::Promise(ref i) if i.kind == TyKind::Simple(Simple::Undefined)) + ); + assert!(matches!( + ty("FrozenArray").kind, + TyKind::FrozenArray(_) + )); + assert!(matches!( + ty("ObservableArray").kind, + TyKind::ObservableArray(_) + )); + assert_eq!( + ty("Uint8ClampedArray").kind, + TyKind::Buffer("Uint8ClampedArray".into()) + ); + assert_eq!(ty("any").kind, TyKind::Simple(Simple::Any)); + assert!(ty("object?").nullable); + } + + #[test] + fn extended_attributes_in_every_form() -> Result<(), String> { + let Definition::Interface { ext, .. } = one( + "[Exposed=(Window,Worker), Global=Window, LegacyFactoryFunction=Image(unsigned long width), \ + Constructor(optional DOMString s = \"\"), Exposed=*, SecureContext] \ + interface I {};", + )? + else { + return Err("not an interface".into()); + }; + let names: Vec<_> = ext.iter().map(|e| e.name.as_str()).collect(); + assert_eq!( + names, + [ + "Exposed", + "Global", + "LegacyFactoryFunction", + "Constructor", + "Exposed", + "SecureContext" + ] + ); + assert_eq!( + ext.first().map(|e| e.value.clone()), + Some(ExtValue::IdentList(vec!["Window".into(), "Worker".into()])) + ); + assert_eq!( + ext.get(4).map(|e| e.value.clone()), + Some(ExtValue::Wildcard) + ); + assert!(matches!( + ext.get(2).map(|e| &e.value), + Some(ExtValue::NamedArgs(n, a)) if n == "Image" && a.len() == 1 + )); + Ok(()) + } + + #[test] + fn extended_attributes_on_types_and_arguments() -> Result<(), String> { + let t = ty("[Clamp] long"); + assert_eq!(t.ext.len(), 1); + let Definition::Interface { members, .. } = one( + "interface I { undefined f([EnforceRange] unsigned long a, [AllowShared] BufferSource b); };", + )? + else { + return Err("not an interface".into()); + }; + assert_eq!(members.len(), 1); + Ok(()) + } + + #[test] + fn keywords_as_names_and_escaped_identifiers() { + // ArgumentNameKeyword, AttributeNameKeyword, OperationNameKeyword. + assert!(parse("interface I { undefined includes(long required, long async, long interface); attribute long async; attribute long required; };").is_ok()); + // Not a keyword the grammar allows there. + assert!(parse("interface I { attribute long long; };").is_err()); + assert!(parse("interface I { attribute long record; };").is_err()); + // An underscore escapes any keyword. + assert!(parse("interface _interface { attribute long _record; };").is_ok()); + assert!(parse("interface I { undefined f(long sequence); };").is_err()); + } + + #[test] + fn operations_specials_and_members() -> Result<(), String> { + let src = "interface I : P { + constructor(); + constructor(long a, optional long b = 1, DOMString... rest); + getter any (DOMString name); + setter undefined (DOMString name, any v); + deleter undefined (DOMString name); + stringifier; + stringifier attribute USVString href; + static undefined s(); + static readonly attribute long sa; + inherit attribute DOMString ia; + readonly attribute long ro; + const unsigned short C = 0x1F; + const double D = -Infinity; + iterable; + async iterable(optional long x); + maplike; + readonly setlike; + };"; + let Definition::Interface { + parent, members, .. + } = one(src)? + else { + return Err("not an interface".into()); + }; + assert_eq!(parent.as_deref(), Some("P")); + assert_eq!(members.len(), 17); + assert!(matches!( + members.get(1).map(|m| &m.kind), + Some(MemberKind::Constructor(a)) if a.len() == 3 + && a.get(2).is_some_and(|x| x.variadic) + && a.get(1).is_some_and(|x| x.default == Some(Value::Integer(1))) + )); + assert!(matches!( + members.get(11).map(|m| &m.kind), + Some(MemberKind::Const(c)) if c.value == Value::Integer(31) + )); + assert!(matches!( + members.get(12).map(|m| &m.kind), + Some(MemberKind::Const(c)) if c.value == Value::NegInfinity + )); + assert!(matches!( + members.get(14).map(|m| &m.kind), + Some(MemberKind::Iterable(i)) if i.is_async && i.key.is_some() && i.args.len() == 1 + )); + assert!(matches!( + members.get(16).map(|m| &m.kind), + Some(MemberKind::Collection(c)) if !c.is_map && c.readonly + )); + Ok(()) + } + + #[test] + fn containers_restrict_their_members() { + assert!(parse("partial interface I { constructor(); };").is_err()); + assert!(parse("interface mixin M { constructor(); };").is_err()); + assert!(parse("interface mixin M { static undefined f(); };").is_err()); + assert!(parse("interface mixin M { getter any (DOMString n); };").is_err()); + assert!(parse("interface mixin M { readonly attribute long a; stringifier; const long C = 1; undefined f(); };").is_ok()); + assert!(parse("callback interface C { attribute long a; };").is_err()); + assert!(parse("callback interface C { const long K = 1; undefined f(); };").is_ok()); + assert!(parse("namespace N { attribute long a; };").is_err()); + assert!( + parse("namespace N { readonly attribute long a; undefined f(); const long K = 1; };") + .is_ok() + ); + assert!(parse("interface I { iterable; };").is_ok()); + assert!(parse("interface mixin M { iterable; };").is_err()); + } + + #[test] + fn dictionaries_enums_typedefs_callbacks_includes() { + let defs = parse( + "dictionary D : B { required long a; [Clamp] octet b = 1; DOMString c = \"x\"; sequence d = []; E e = {}; any f = null; any g; unrestricted double h = NaN; double i = 1.5e3; boolean j = true; }; + partial dictionary D { long k; }; + enum E { \"a\", \"b-c\", \"\", }; + typedef (long or DOMString)? T; + callback CB = undefined (long a, optional any b); + callback interface CI { undefined f(); }; + namespace N { }; + partial namespace N { readonly attribute long x; }; + X includes M; + interface mixin M { }; + partial interface mixin M { };", + ) + .unwrap_or_default(); + assert_eq!(defs.len(), 11); + assert!(matches!( + defs.first(), + Some(Definition::Dictionary { parent: Some(p), members, .. }) if p == "B" && members.len() == 10 + )); + assert!(matches!( + defs.get(2), + Some(Definition::Enum { values, .. }) if values == &["a", "b-c", ""] + )); + assert!(matches!(defs.get(3), Some(Definition::Typedef { ty, .. }) if ty.nullable)); + assert!( + matches!(defs.get(8), Some(Definition::Includes { target, mixin }) if target == "X" && mixin == "M") + ); + assert!(matches!( + defs.get(1), + Some(Definition::Dictionary { partial: true, .. }) + )); + } + + #[test] + fn rejects_malformed_input_with_a_line() { + let e = parse("interface I {\n attribute long\n};") + .err() + .unwrap_or_default(); + assert!(e.starts_with("3: "), "{e}"); + assert!(parse("interface I { };").is_ok()); + assert!(parse("interface I { }").is_err()); + assert!(parse("enum E { };").is_err()); + assert!(parse("[Exposed=Window] X includes Y;").is_err()); + assert!(parse("partial enum E { \"a\" };").is_err()); + } +} diff --git a/xtask/src/bindings/resolve.rs b/xtask/src/bindings/resolve.rs new file mode 100644 index 00000000..896c17c0 --- /dev/null +++ b/xtask/src/bindings/resolve.rs @@ -0,0 +1,686 @@ +//! Resolution: merge the definitions of every file into one model. +//! +//! WebIDL §2.5 (the semantics of partials and `includes`), as far as the +//! model needs: +//! - **Partial interfaces, dictionaries and namespaces** (WebIDL §2.2 +//! "Interfaces", "Dictionaries", "Namespaces"): the members of each +//! `partial` are appended to its target. A target defined nowhere is an +//! error. +//! - **`includes`** (WebIDL §2.2 "Interface mixins", "Includes +//! statements"): `A includes M;` appends the members of mixin `M` (its own +//! and those of its partials) to `A`, each marked with the mixin's name. +//! +//! Modelling choices: +//! - Files are read in the order given (sorted by name by the caller), the +//! definitions of a file in source order. An interface's members are its +//! own, then those of its partials in the order the partials appear, then +//! those of the mixins in the order the `includes` statements appear. +//! - Extended attributes `Exposed` and `SecureContext` written on a partial +//! interface or a mixin (or a partial of one) apply to the members it +//! adds (WebIDL §3.3.1 `[Exposed]` and HTML's `[SecureContext]` on partials +//! and mixins), so each such member gets a copy unless it has its own. +//! No other extended attribute of a partial or mixin is passed on, and +//! the extended attributes of a partial are not merged into its target's. +//! - Every definition is in one namespace: an interface, namespace, +//! dictionary, enum, typedef, callback or mixin name is defined once. +//! - A reference to a name no file defines is an error unless it is listed +//! in [`EXTERNAL`], the types the vendored files refer to and other +//! standards define (each with the standard that does). +//! - Interfaces, dictionaries, enums and the rest are sorted by name in the +//! output, so lookups can bisect and a reordering of the input files +//! changes nothing. + +use std::collections::{BTreeMap, BTreeSet}; + +use super::model::{ + Argument, Attribute, Const, Definition, DictMember, ExtAttr, ExtValue, Iterable, Member, + MemberKind, Operation, Ty, TyKind, +}; + +/// Names the vendored IDL refers to and defines nowhere in it, sorted, each +/// with the standard that defines it (its IDL is not vendored; see `SOURCE.md` +/// of `tests/data/webref-idl/`). The generated model records them as external +/// and gives them no definition. A reference to any other undefined name is an +/// error. +pub const EXTERNAL: &[(&str, &str)] = &[ + ("ARIAMixin", "WAI-ARIA (an interface mixin)"), + ("Blob", "File API"), + ("BufferSource", "WebIDL"), + ("CSSMarginDescriptors", "CSS Paged Media"), + ( + "CSSOMString", + "CSSOM (an implementation-defined string type: DOMString or USVString)", + ), + ("DOMException", "WebIDL"), + ("DOMHighResTimeStamp", "High Resolution Time"), + ("DOMMatrix", "Geometry Interfaces"), + ("DOMMatrix2DInit", "Geometry Interfaces"), + ("DOMPointInit", "Geometry Interfaces"), + ("File", "File API"), + ("FileList", "File API"), + ("Function", "WebIDL"), + ("GPUCanvasContext", "WebGPU"), + ("MathMLElement", "MathML Core"), + ("MediaSource", "Media Source Extensions"), + ("MediaStream", "Media Capture and Streams"), + ( + "MouseEvent", + "UI Events (not in the vendored `uievents.idl`)", + ), + ( + "MouseEventInit", + "UI Events (not in the vendored `uievents.idl`)", + ), + ("PerformanceEntry", "Performance Timeline"), + ("QuotaExceededError", "WebIDL"), + ("ReadableStream", "Streams"), + ("ReferrerPolicy", "Referrer Policy"), + ("SVGElement", "SVG 2"), + ("SVGImageElement", "SVG 2"), + ("SVGScriptElement", "SVG 2"), + ("ServiceWorker", "Service Workers"), + ("TrustedHTML", "Trusted Types"), + ("TrustedHTMLParserOptions", "Trusted Types"), + ("TrustedScript", "Trusted Types"), + ("TrustedScriptURL", "Trusted Types"), + ("TrustedType", "Trusted Types"), + ("VideoFrame", "WebCodecs"), + ("ViewTransition", "CSS View Transitions"), + ("VoidFunction", "WebIDL"), + ("WebGL2RenderingContext", "WebGL"), + ("WebGLRenderingContext", "WebGL"), + ( + "WindowProxy", + "HTML (WindowProxy is defined in prose, not in `html.idl`)", + ), + ("WritableStream", "Streams"), +]; + +/// The extended attributes a partial interface or a mixin passes on to the +/// members it adds. +const PASSED_ON: &[&str] = &["Exposed", "SecureContext"]; + +/// A resolved interface. +#[derive(Debug, Clone, PartialEq)] +pub struct Interface { + /// Its name. + pub name: String, + /// What it inherits from. + pub parent: Option, + /// `callback interface`. + pub callback: bool, + /// Its own extended attributes. + pub ext: Vec, + /// The mixins it includes, in order. + pub includes: Vec, + /// Members: own, partials', then mixins'. + pub members: Vec, +} + +/// A resolved namespace. +#[derive(Debug, Clone, PartialEq)] +pub struct Namespace { + /// Its name. + pub name: String, + /// Its extended attributes. + pub ext: Vec, + /// Members: own, then partials'. + pub members: Vec, +} + +/// A resolved dictionary. +#[derive(Debug, Clone, PartialEq)] +pub struct Dictionary { + /// Its name. + pub name: String, + /// What it inherits from. + pub parent: Option, + /// Its extended attributes. + pub ext: Vec, + /// Members: own, then partials'. + pub members: Vec, +} + +/// An enum. +#[derive(Debug, Clone, PartialEq)] +pub struct Enum { + /// Its name. + pub name: String, + /// Its extended attributes. + pub ext: Vec, + /// Its values. + pub values: Vec, +} + +/// A typedef. +#[derive(Debug, Clone, PartialEq)] +pub struct Typedef { + /// Its name. + pub name: String, + /// Its extended attributes. + pub ext: Vec, + /// The type it names. + pub ty: Ty, +} + +/// A callback function type. +#[derive(Debug, Clone, PartialEq)] +pub struct Callback { + /// Its name. + pub name: String, + /// Its extended attributes. + pub ext: Vec, + /// Its return type. + pub ret: Ty, + /// Its arguments. + pub args: Vec, +} + +/// The resolved model of all the files. +#[derive(Debug, Clone, PartialEq, Default)] +pub struct Model { + /// Interfaces and callback interfaces, sorted by name. + pub interfaces: Vec, + /// Namespaces, sorted by name. + pub namespaces: Vec, + /// Dictionaries, sorted by name. + pub dictionaries: Vec, + /// Enums, sorted by name. + pub enums: Vec, + /// Typedefs, sorted by name. + pub typedefs: Vec, + /// Callbacks, sorted by name. + pub callbacks: Vec, + /// How many mixins there were (they are resolved into their includers). + pub mixins: usize, + /// The external names that are referenced, sorted. + pub external: Vec, + /// `includes` statements whose interface another standard defines + /// (`EXTERNAL`), as (interface, mixin), in order. + pub foreign_includes: Vec<(String, String)>, +} + +/// What a name defines, for the single namespace of definitions. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum Kind { + Interface, + Mixin, + Namespace, + Dictionary, + Enum, + Typedef, + Callback, +} + +struct Mixin { + ext_members: Vec, +} + +/// Merge `files` (name and definitions of each, in order) into a model. +pub fn resolve(files: &[(String, Vec)]) -> Result { + let mut kinds: BTreeMap = BTreeMap::new(); + // First pass: the one non-partial definition of each name. + for (file, defs) in files { + for d in defs { + let (name, kind) = match d { + Definition::Interface { + name, + partial: false, + .. + } => (name, Kind::Interface), + Definition::Mixin { + name, + partial: false, + .. + } => (name, Kind::Mixin), + Definition::Namespace { + name, + partial: false, + .. + } => (name, Kind::Namespace), + Definition::Dictionary { + name, + partial: false, + .. + } => (name, Kind::Dictionary), + Definition::Enum { name, .. } => (name, Kind::Enum), + Definition::Typedef { name, .. } => (name, Kind::Typedef), + Definition::Callback { name, .. } => (name, Kind::Callback), + _ => continue, + }; + if let Some((_, other)) = kinds.insert(name.clone(), (kind, file.as_str())) { + return Err(format!("{name} is defined in both {other} and {file}")); + } + } + } + let kind_of = |name: &str| kinds.get(name).map(|(k, _)| *k); + + let mut interfaces: BTreeMap = BTreeMap::new(); + let mut mixins: BTreeMap = BTreeMap::new(); + let mut namespaces: BTreeMap = BTreeMap::new(); + let mut dictionaries: BTreeMap = BTreeMap::new(); + let mut model = Model::default(); + let mut foreign_mixins: BTreeSet = BTreeSet::new(); + // Partials are applied in file order after every main definition exists. + let mut includes: Vec<(&str, &str, &str)> = Vec::new(); + for (file, defs) in files { + for d in defs { + match d { + Definition::Interface { + ext, + name, + parent, + partial: false, + callback, + members, + } => { + interfaces.insert( + name.clone(), + Interface { + name: name.clone(), + parent: parent.clone(), + callback: *callback, + ext: ext.clone(), + includes: Vec::new(), + members: members.clone(), + }, + ); + } + Definition::Mixin { + name, + partial: false, + ext, + members, + } => { + mixins.insert( + name.clone(), + Mixin { + ext_members: passing_on(ext, members), + }, + ); + } + Definition::Namespace { + name, + partial: false, + ext, + members, + } => { + namespaces.insert( + name.clone(), + Namespace { + name: name.clone(), + ext: ext.clone(), + members: members.clone(), + }, + ); + } + Definition::Dictionary { + name, + partial: false, + ext, + parent, + members, + } => { + dictionaries.insert( + name.clone(), + Dictionary { + name: name.clone(), + parent: parent.clone(), + ext: ext.clone(), + members: members.clone(), + }, + ); + } + Definition::Enum { ext, name, values } => model.enums.push(Enum { + name: name.clone(), + ext: ext.clone(), + values: values.clone(), + }), + Definition::Typedef { ext, name, ty } => model.typedefs.push(Typedef { + name: name.clone(), + ext: ext.clone(), + ty: ty.clone(), + }), + Definition::Callback { + ext, + name, + ret, + args, + } => model.callbacks.push(Callback { + name: name.clone(), + ext: ext.clone(), + ret: ret.clone(), + args: args.clone(), + }), + Definition::Includes { target, mixin } => { + includes.push((file.as_str(), target.as_str(), mixin.as_str())); + } + _ => {} + } + } + } + // Partials. + for (file, defs) in files { + for d in defs { + match d { + Definition::Interface { + name, + ext, + partial: true, + members, + .. + } => { + let target = interfaces.get_mut(name).ok_or_else(|| { + format!("{file}: partial interface {name} has no interface") + })?; + target.members.extend(passing_on(ext, members)); + } + Definition::Mixin { + name, + ext, + partial: true, + members, + } => { + let target = mixins.get_mut(name).ok_or_else(|| { + format!("{file}: partial interface mixin {name} has no mixin") + })?; + target.ext_members.extend(passing_on(ext, members)); + } + Definition::Namespace { + name, + ext, + partial: true, + members, + } => { + let target = namespaces.get_mut(name).ok_or_else(|| { + format!("{file}: partial namespace {name} has no namespace") + })?; + target.members.extend(passing_on(ext, members)); + } + Definition::Dictionary { + name, + partial: true, + members, + .. + } => { + let target = dictionaries.get_mut(name).ok_or_else(|| { + format!("{file}: partial dictionary {name} has no dictionary") + })?; + target.members.extend(members.iter().cloned()); + } + _ => {} + } + } + } + // Includes. + for (file, target, mixin) in includes { + let external_mixin = kind_of(mixin).is_none() && EXTERNAL.iter().any(|(n, _)| *n == mixin); + if kind_of(mixin) != Some(Kind::Mixin) && !external_mixin { + return Err(format!( + "{file}: {target} includes {mixin}, which is not an interface mixin" + )); + } + let Some(iface) = interfaces.get_mut(target) else { + // An interface of another standard: the statement is recorded, + // its members are not (the interface is not in the model). + if EXTERNAL.iter().any(|(n, _)| *n == target) { + model + .foreign_includes + .push((target.to_owned(), mixin.to_owned())); + continue; + } + return Err(format!( + "{file}: {target} includes {mixin}, but {target} is not an interface" + )); + }; + if iface.includes.iter().any(|m| m == mixin) { + return Err(format!("{file}: {target} includes {mixin} twice")); + } + iface.includes.push(mixin.to_owned()); + } + for iface in interfaces.values_mut() { + for m in iface.includes.clone() { + if let Some(mixin) = mixins.get(&m) { + for member in &mixin.ext_members { + let mut member = member.clone(); + member.mixin = Some(m.clone()); + iface.members.push(member); + } + } + } + } + // Mixins of other standards that an interface includes: the name is + // kept in `includes`, and counted as a used external name. + for iface in interfaces.values() { + for m in &iface.includes { + if !mixins.contains_key(m) { + foreign_mixins.insert(m.clone()); + } + } + } + model.mixins = mixins.len(); + model.interfaces = interfaces.into_values().collect(); + model.namespaces = namespaces.into_values().collect(); + model.dictionaries = dictionaries.into_values().collect(); + model.enums.sort_by(|a, b| a.name.cmp(&b.name)); + model.typedefs.sort_by(|a, b| a.name.cmp(&b.name)); + model.callbacks.sort_by(|a, b| a.name.cmp(&b.name)); + check_unique_members(&model)?; + check_references(&mut model, foreign_mixins, &|n| { + kind_of(n).is_some_and(|k| k != Kind::Mixin) + })?; + Ok(model) +} + +/// `members`, each with a copy of the [`PASSED_ON`] attributes of `ext` +/// that it lacks. +fn passing_on(ext: &[ExtAttr], members: &[Member]) -> Vec { + members + .iter() + .map(|m| { + let mut m = m.clone(); + for a in ext.iter().filter(|a| PASSED_ON.contains(&a.name.as_str())) { + if !m.ext.iter().any(|b| b.name == a.name) { + m.ext.push(a.clone()); + } + } + m + }) + .collect() +} + +/// The name a member is known by, for duplicate checks of attributes and +/// constants (operations overload, so repeat freely). +fn unique_name(m: &Member) -> Option<(&'static str, &str)> { + match &m.kind { + MemberKind::Const(c) => Some(("constant", c.name.as_str())), + MemberKind::Attribute(a) => Some(("attribute", a.name.as_str())), + _ => None, + } +} + +fn check_unique_members(model: &Model) -> Result<(), String> { + for i in &model.interfaces { + let mut seen = BTreeSet::new(); + let mut statics = BTreeSet::new(); + for m in &i.members { + if let Some((what, name)) = unique_name(m) { + let is_static = matches!(&m.kind, MemberKind::Attribute(a) if a.is_static); + let set = if is_static { &mut statics } else { &mut seen }; + if !set.insert(name) { + return Err(format!( + "interface {}: {what} {name} is defined twice", + i.name + )); + } + } + } + } + for i in &model.interfaces { + // WebIDL: at most one of iterable, async iterable, maplike, setlike. + let declarations = i + .members + .iter() + .filter(|m| matches!(m.kind, MemberKind::Iterable(_) | MemberKind::Collection(_))) + .count(); + if declarations > 1 { + return Err(format!( + "interface {}: more than one of iterable, maplike and setlike", + i.name + )); + } + } + for d in &model.dictionaries { + let mut seen = BTreeSet::new(); + for m in &d.members { + if !seen.insert(m.name.as_str()) { + return Err(format!( + "dictionary {}: member {} is defined twice", + d.name, m.name + )); + } + } + } + Ok(()) +} + +/// Every `Named` type, parent and `includes` target resolves, or is +/// external; collects the external names used. +fn check_references( + model: &mut Model, + foreign_mixins: BTreeSet, + defined: &dyn Fn(&str) -> bool, +) -> Result<(), String> { + let mut used_external = foreign_mixins; + let mut missing: BTreeSet = BTreeSet::new(); + for (target, _) in &model.foreign_includes { + used_external.insert(target.clone()); + } + let mut check = |name: &str, whence: &str| -> Result<(), String> { + if defined(name) { + return Ok(()); + } + if EXTERNAL.iter().any(|(n, _)| *n == name) { + used_external.insert(name.to_owned()); + return Ok(()); + } + missing.insert(format!("{name} (first in {whence})")); + Ok(()) + }; + for i in &model.interfaces { + let whence = format!("interface {}", i.name); + if let Some(p) = &i.parent { + check(p, &whence)?; + } + walk_ext(&i.ext, &whence, &mut check)?; + for m in &i.members { + walk_member(m, &whence, &mut check)?; + } + } + for n in &model.namespaces { + let whence = format!("namespace {}", n.name); + walk_ext(&n.ext, &whence, &mut check)?; + for m in &n.members { + walk_member(m, &whence, &mut check)?; + } + } + for d in &model.dictionaries { + let whence = format!("dictionary {}", d.name); + if let Some(p) = &d.parent { + check(p, &whence)?; + } + walk_ext(&d.ext, &whence, &mut check)?; + for m in &d.members { + walk_ext(&m.ext, &whence, &mut check)?; + walk_ty(&m.ty, &whence, &mut check)?; + } + } + for t in &model.typedefs { + let whence = format!("typedef {}", t.name); + walk_ext(&t.ext, &whence, &mut check)?; + walk_ty(&t.ty, &whence, &mut check)?; + } + for c in &model.callbacks { + let whence = format!("callback {}", c.name); + walk_ext(&c.ext, &whence, &mut check)?; + walk_ty(&c.ret, &whence, &mut check)?; + walk_args(&c.args, &whence, &mut check)?; + } + for e in &model.enums { + walk_ext(&e.ext, &format!("enum {}", e.name), &mut check)?; + } + if !missing.is_empty() { + return Err(format!( + "names no vendored file defines and EXTERNAL does not list: {}", + missing.into_iter().collect::>().join("; ") + )); + } + model.external = used_external.into_iter().collect(); + Ok(()) +} + +type Check<'a> = dyn FnMut(&str, &str) -> Result<(), String> + 'a; + +fn walk_ty(ty: &Ty, whence: &str, check: &mut Check<'_>) -> Result<(), String> { + walk_ext(&ty.ext, whence, check)?; + match &ty.kind { + TyKind::Simple(_) | TyKind::Buffer(_) => Ok(()), + TyKind::Named(n) => check(n, whence), + TyKind::Sequence(t) + | TyKind::FrozenArray(t) + | TyKind::ObservableArray(t) + | TyKind::Promise(t) => walk_ty(t, whence, check), + TyKind::Record(k, v) => { + walk_ty(k, whence, check)?; + walk_ty(v, whence, check) + } + TyKind::Union(ts) => ts.iter().try_for_each(|t| walk_ty(t, whence, check)), + } +} + +fn walk_args(args: &[Argument], whence: &str, check: &mut Check<'_>) -> Result<(), String> { + for a in args { + walk_ext(&a.ext, whence, check)?; + walk_ty(&a.ty, whence, check)?; + } + Ok(()) +} + +fn walk_ext(ext: &[ExtAttr], whence: &str, check: &mut Check<'_>) -> Result<(), String> { + for a in ext { + match &a.value { + ExtValue::Args(args) | ExtValue::NamedArgs(_, args) => walk_args(args, whence, check)?, + _ => {} + } + } + Ok(()) +} + +fn walk_member(m: &Member, whence: &str, check: &mut Check<'_>) -> Result<(), String> { + walk_ext(&m.ext, whence, check)?; + match &m.kind { + MemberKind::Const(Const { ty, .. }) | MemberKind::Attribute(Attribute { ty, .. }) => { + walk_ty(ty, whence, check) + } + MemberKind::Operation(Operation { ret, args, .. }) => { + walk_ty(ret, whence, check)?; + walk_args(args, whence, check) + } + MemberKind::Constructor(args) => walk_args(args, whence, check), + MemberKind::Iterable(Iterable { + key, value, args, .. + }) => { + if let Some(k) = key { + walk_ty(k, whence, check)?; + } + walk_ty(value, whence, check)?; + walk_args(args, whence, check) + } + MemberKind::Collection(c) => { + if let Some(k) = &c.key { + walk_ty(k, whence, check)?; + } + walk_ty(&c.value, whence, check) + } + } +} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 0feed148..ad934957 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -29,12 +29,17 @@ //! user agent style sheet from HTML §15 (`crates/clazel-style/data/*.css`). //! `check` and `verify` fail if they are stale or a data file's hash //! differs from its `SOURCE.md`. +//! - `cargo xtask bindings`: regenerate the resolved WebIDL interface model +//! of `clazel-webidl` (`crates/clazel-webidl/src/generated/`) from the +//! vendored IDL, with our own parser (`bindings/`). `check` and `verify` +//! fail if it is stale or a vendored file does not parse. //! - `cargo xtask report [--write] [--changed [base]]`: run the checks that produce the //! status table (including each crate's conformance suites, see //! `conformance.rs`), print it, and with `--write` update docs/STATUS.md //! and the images drawn from it (`status.rs`). A table that differs from //! what was measured is reported, not a failure: CI rewrites it on main. +mod bindings; mod changed; mod conformance; mod deps; @@ -397,6 +402,8 @@ fn static_checks(r: &mut Runner, crates: &[Crate], pins: &Pins) { "generated encoding labels and indexes", outcome(problems, notes), ); + let (problems, notes) = bindings::run(false); + r.step("generated WebIDL interface model", outcome(problems, notes)); let tooling = crates .iter() .filter(|c| c.tooling) @@ -1020,6 +1027,29 @@ fn generate_testdata() -> ExitCode { } } +/// `cargo xtask bindings`: rewrite the generated WebIDL interface model of +/// `clazel-webidl` if stale. +fn generate_bindings() -> ExitCode { + let mut r = Runner::default(); + let root = Path::new(env!("CARGO_MANIFEST_DIR")).parent(); + if !root.is_some_and(|p| std::env::set_current_dir(p).is_ok()) { + r.step( + "find repository root", + Outcome::Fail(vec!["cannot enter the repository root".into()]), + ); + return ExitCode::from(1); + } + let (problems, notes) = bindings::run(true); + r.step("generate WebIDL interface model", outcome(problems, notes)); + if r.failed { + println!("RESULT: FAILED"); + ExitCode::from(1) + } else { + println!("RESULT: WEBIDL BINDINGS UP TO DATE"); + ExitCode::SUCCESS + } +} + /// `cargo xtask tables`: rewrite the generated Unicode tables if stale. fn generate_tables() -> ExitCode { let mut r = Runner::default(); @@ -1124,6 +1154,7 @@ fn main() -> ExitCode { let (full, only_mutate, report_mode, write) = match (args, base) { (["testdata"], None) => return generate_testdata(), (["tables"], None) => return generate_tables(), + (["bindings"], None) => return generate_bindings(), (["verify"], _) => (true, false, false, false), (["check"], None) => (false, false, false, false), (["mutate"], None) => (false, true, false, false), @@ -1135,7 +1166,7 @@ fn main() -> ExitCode { (["report", "--write"], _) => (false, false, true, true), _ => { eprintln!( - "usage: cargo xtask ]|crate --metrics |assemble --metrics [--write|--changed ])|crates [--changed ]|check|mutate [crate]|testdata|tables|report [--write] [--changed [base]]>" + "usage: cargo xtask ]|crate --metrics |assemble --metrics [--write|--changed ])|crates [--changed ]|check|mutate [crate]|testdata|tables|bindings|report [--write] [--changed [base]]>" ); return ExitCode::from(64); } From e3588df96db3a9da8a1b12f9c1b47f94b65e5af2 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 17:02:06 +0000 Subject: [PATCH 030/195] clazel-dom: spec and contracts for pre-insert, replace, replace all, clone, attribute changes Adds, as spec fns and contract predicates only (no implementation, no new proofs): DOM 4.2.3 ensure pre-insertion validity, pre-insert, insert of a DocumentFragment, replace, replace all, 4.4 shallow clone a node, 4.9 change/remove/replace an attribute, and the named insertion steps and removing steps hooks (identity), called from insert and remove. Step numbers are marked as written from memory. Two existing lemmas and the independent insert equivalence get rlimit headroom, as the hooks add one unfolding to insert and remove. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-dom/src/contract.rs | 104 +++ .../clazel-dom/src/independent_equivalence.rs | 7 +- crates/clazel-dom/src/lemmas.rs | 2 + crates/clazel-dom/src/spec.rs | 638 +++++++++++++++++- 4 files changed, 743 insertions(+), 8 deletions(-) diff --git a/crates/clazel-dom/src/contract.rs b/crates/clazel-dom/src/contract.rs index cfe1605e..5a355121 100644 --- a/crates/clazel-dom/src/contract.rs +++ b/crates/clazel-dom/src/contract.rs @@ -113,4 +113,108 @@ pub open spec fn set_mode_ensures(doc: Document, mode: DocumentMode, out: Docume out == set_mode(doc, mode) } +// --------------------------------------------------------------------- +// Phase 7 item 7.13 (see `spec.rs`, "the mutation algorithms scripts +// call"). Their section and step numbers carry the mark † there. + +/// Precondition of `Arena::ensure_pre_insertion_validity(node, parent, +/// child)` and `Arena::pre_insert(node, parent, child)`: ids of a +/// well-formed arena. Any node, parent and child are allowed: the +/// algorithm's job is to refuse the invalid ones. +pub open spec fn pre_insert_requires(doc: Document, node: NodeId, parent: NodeId, child: Option) -> bool { + ids_requires(doc, node, parent, child) +} + +/// Contract for `Arena::ensure_pre_insertion_validity(node, parent, +/// child) -> Option`: the error DOM §4.2.3† throws, or none. +pub open spec fn ensure_pre_insertion_validity_ensures( + doc: Document, + node: NodeId, + parent: NodeId, + child: Option, + err: Option, +) -> bool { + err == pre_insert_error(doc, node, parent, child) +} + +/// Contract for `Arena::pre_insert(node, parent, child) -> +/// Option`: the error is [`pre_insert_error`], and the arena is +/// [`pre_insert`] (unchanged if there is an error). +pub open spec fn pre_insert_ensures( + doc: Document, + node: NodeId, + parent: NodeId, + child: Option, + out: Document, + err: Option, +) -> bool { + &&& err == pre_insert_error(doc, node, parent, child) + &&& out == pre_insert(doc, node, parent, child) +} + +/// Precondition of `Arena::replace(child, node, parent)`: ids of a +/// well-formed arena. +pub open spec fn replace_requires(doc: Document, child: NodeId, node: NodeId, parent: NodeId) -> bool { + &&& ids_requires(doc, node, parent, Some(child)) +} + +/// Contract for `Arena::replace(child, node, parent) -> Option`. +pub open spec fn replace_ensures( + doc: Document, + child: NodeId, + node: NodeId, + parent: NodeId, + out: Document, + err: Option, +) -> bool { + &&& err == replace_error(doc, child, node, parent) + &&& out == replace(doc, child, node, parent) +} + +/// Contract for `Arena::replace_all(node, parent)`, under +/// [`replace_all_requires`]. +pub open spec fn replace_all_ensures(doc: Document, node: Option, parent: NodeId, out: Document) -> bool { + out == replace_all(doc, node, parent) +} + +/// Precondition of `Arena::adopt(node)`: a node of a well-formed arena. +pub open spec fn adopt_requires(doc: Document, node: NodeId) -> bool { + wf(doc) && valid(doc, node) +} + +/// Contract for `Arena::adopt(node)`. +pub open spec fn adopt_ensures(doc: Document, node: NodeId, out: Document) -> bool { + out == adopt(doc, node) +} + +/// Contract for `Arena::clone_node(node) -> Option`, under +/// [`clone_requires`]: refused (`None`, nothing changed) unless the arena +/// can hold the copy (and a template's contents), and otherwise +/// [`clone_node`]. +pub open spec fn clone_node_ensures(doc: Document, node: NodeId, out: Document, id: Option) -> bool { + if can_create(doc, clone_count(doc, node)) { + id == Some(clone_node(doc, node).1) && out == clone_node(doc, node).0 + } else { + id is None && out == doc + } +} + +/// Contract for `Arena::change_attribute(e, i, value)`, under +/// [`attribute_requires`]. +pub open spec fn change_attribute_ensures(doc: Document, e: NodeId, i: nat, value: Seq, out: Document) -> bool { + out == change_attribute(doc, e, i, value) +} + +/// Contract for `Arena::remove_attribute(e, i)`, under +/// [`attribute_requires`]. +pub open spec fn remove_attribute_ensures(doc: Document, e: NodeId, i: nat, out: Document) -> bool { + out == remove_attribute(doc, e, i) +} + +/// Contract for `Arena::replace_attribute(e, i, new_attr)`, under +/// [`attribute_requires`]. +pub open spec fn replace_attribute_ensures(doc: Document, e: NodeId, i: nat, new_attr: Attr, out: Document) -> bool { + out == replace_attribute(doc, e, i, new_attr) +} + } // verus! diff --git a/crates/clazel-dom/src/independent_equivalence.rs b/crates/clazel-dom/src/independent_equivalence.rs index c814a814..b9f19d3a 100644 --- a/crates/clazel-dom/src/independent_equivalence.rs +++ b/crates/clazel-dom/src/independent_equivalence.rs @@ -124,6 +124,7 @@ pub proof fn lemma_independent_adopt(doc: Document, node: NodeId) /// The independent "insert" is the spec's, on every call the parser makes /// ([`insert_requires`]); so are "append" and "pre-insert", which call it. +#[verifier::rlimit(50)] pub proof fn lemma_independent_insert(doc: Document, node: NodeId, parent: NodeId, child: Option) requires insert_requires(doc, node, parent, child), @@ -160,8 +161,10 @@ pub proof fn lemma_independent_insert(doc: Document, node: NodeId, parent: NodeI } let a = ind_insert(doc, node, parent, child); let b = insert(doc, node, parent, child); - assert forall|i: int| 0 <= i < doc.nodes.len() implies #[trigger] a.nodes[i] == b.nodes[i] by {} - assert(a.nodes =~= b.nodes); + let c = attach(d1, node, parent, kids); + assert(b == c); + assert forall|i: int| 0 <= i < doc.nodes.len() implies #[trigger] a.nodes[i] == c.nodes[i] by {} + assert(a.nodes =~= c.nodes); } } // verus! diff --git a/crates/clazel-dom/src/lemmas.rs b/crates/clazel-dom/src/lemmas.rs index b823ef26..1bd3b10b 100644 --- a/crates/clazel-dom/src/lemmas.rs +++ b/crates/clazel-dom/src/lemmas.rs @@ -1242,6 +1242,7 @@ pub proof fn lemma_insert_attach_requires(doc: Document, paths: Seq> /// DOM §4.2.3 "insert" keeps the arena well formed, with [`insert_paths`] /// as the witness; paths that do not pass through `node` are unchanged. +#[verifier::rlimit(50)] pub proof fn lemma_insert_wf_with(doc: Document, paths: Seq>, node: NodeId, parent: NodeId, child: Option) requires insert_requires(doc, node, parent, child), @@ -2260,6 +2261,7 @@ pub open spec fn reparent_one(d: Document, from: NodeId, to: NodeId) -> Seq (Document // --------------------------------------------------------------------- // Mutation algorithms (DOM §4.2.3) +/// The "insertion steps" hook (DOM §4.2.3 "insert", step 7.7.1†: "Run the +/// insertion steps with inclusiveDescendant."). Other standards define +/// insertion steps for particular elements (HTML §4.12.1 `script`, §4.8.5 +/// `iframe`, §4.12.3 `template`, and others). A named hook point: here the +/// hook changes nothing, and is called once, with the root of the inserted +/// subtree, from [`insert`] only. A later phase that gives a hook an effect +/// replaces this one definition, and must then re-prove the theorems of +/// `lemmas.rs` that unfold [`insert`] (each states, in its `ensures`, what +/// the hook may not change). +pub open spec fn insertion_steps(doc: Document, inserted: NodeId) -> Document { + doc +} + +/// The "removing steps" hook (DOM §4.2.3 "remove", step 12†: "Run the +/// removing steps with node and parent."). Defined by other standards for +/// particular elements, as [`insertion_steps`] is. A named hook point +/// that changes nothing here, called once from [`remove`] only, with the +/// removed node and its former parent. +pub open spec fn removing_steps(doc: Document, removed: NodeId, old_parent: NodeId) -> Document { + doc +} + /// DOM §4.2.3 "remove" a node, the steps that change the tree: "1. Let /// parent be node's parent. 2. Assert: parent is non-null." ... "7. Remove /// node from its parent's children." Steps 3 to 6 and 8 onward update live @@ -479,12 +501,14 @@ pub open spec fn remove(doc: Document, node: NodeId) -> Document { let pn = doc.nodes[p as int]; // 7. let i = index_of(pn.children, node); - Document { + let removed = Document { nodes: doc.nodes.update(p as int, Node { children: pn.children.remove(i), ..pn }).update( node as int, Node { parent: None, ..doc.nodes[node as int] }, ), - } + }; + // 12.† "Run the removing steps with node and parent." + removing_steps(removed, node, p) } /// DOM §4.5 "adopt" a node into its own node document: "1. Let oldDocument @@ -540,14 +564,17 @@ pub open spec fn insert(doc: Document, node: NodeId, parent: NodeId, child: Opti // from the same parent.) Some(c) => pn.children.insert(index_of(pn.children, c), node), }; - // 7.4 to 7.7, 8 onward: slots, insertion steps, custom elements, - // observers, children changed and post-connection steps; not modelled. - Document { + let inserted = Document { nodes: d1.nodes.update(parent as int, Node { children: kids, ..pn }).update( node as int, Node { parent: Some(parent), ..d1.nodes[node as int] }, ), - } + }; + // 7.4 to 7.6: slots; 7.7.1† "Run the insertion steps with + // inclusiveDescendant."; 7.7.2 onward, 8 onward: custom elements, + // observers, children changed and post-connection steps; not modelled + // beyond the hook. + insertion_steps(inserted, node) } /// DOM §4.2.3 "append" a node to a parent: "pre-insert node into parent @@ -646,4 +673,603 @@ pub open spec fn set_mode(doc: Document, mode: DocumentMode) -> Document { Document { nodes: doc.nodes.update(0, Node { kind: k, ..node }) } } +// --------------------------------------------------------------------- +// Phase 7 item 7.13: the mutation algorithms scripts call +// +// Everything below was transcribed from memory of the DOM Standard, not read +// at the pinned commit: its section and step numbers carry the mark † +// (docs/phases/phase-7.md's convention), and must be checked against the +// pinned snapshot before a review relies on them. The algorithms are +// §4.2.3 "ensure pre-insertion validity", "pre-insert", "insert" (for a +// DocumentFragment too), "replace", "replace all", §4.4 "clone a node" and +// §4.9 "change", "remove" and "replace an attribute". +// +// Modelling choices of this part, in addition to those at the top of the +// file: +// - **Errors are values.** "Throw a HierarchyRequestError / NotFoundError" +// becomes returning `Some(DomError)` from an `_error` function; an +// algorithm that throws leaves the tree unchanged, because every check +// runs before the first change. A caller (Phase 7's bindings) turns the +// value into a `DOMException`. +// - **A DocumentFragment may be inserted.** The restriction of +// [`insert_requires`] (the node is not a fragment) belongs to the +// parser's calls; [`insert_any`] below handles a fragment, as step 4 of +// "insert" does. A fragment is still never a child (`wf`), so inserting +// one moves its children and leaves it empty and parentless. +// - **The only `CharacterData` interfaces are `Text`, `Comment` and +// `ProcessingInstruction`**, as the arena has no `CDATASection` (a +// `Text` subclass, so "node is a Text node" would cover it). +// - **"Host-including inclusive ancestor"** (§4.2) is +// [`is_host_including_inclusive_ancestor`]: walk parents to the root, and +// from a fragment root that has a host continue at the host. The walk is +// deterministic, so a node it reaches it reaches within `nodes.len()` +// steps (it visits each node at most once before repeating), which is +// the fuel. +// - **Index arguments.** An attribute is named by its position in the +// element's attribute list (DOM names the `Attr` object); the position +// is a precondition, as the attribute's presence in the list is. +// - **Attributes' "handle attribute changes"** (queues records, runs +// attribute change steps) is not modelled, as in [`append_attribute`]. +// - **Shallow "clone a node" only.** The clone children flag is never +// set: a deep clone's recursion is not specified here (not done). +// - **A template** is an element whose template contents is non-null (the +// parser creates the contents of every `template` it creates). Its clone +// gets contents of its own (HTML §4.12.3 "when a template element is +// created"); the copied element's form owner is null (a created element +// has none). +// - **The node limit applies to clones** like to creation: a clone that +// needs `k` new nodes is refused (the arena unchanged) unless the arena +// can hold `k` more. +// - **The hooks** [`insertion_steps`] and [`removing_steps`] are called +// from [`insert`] and [`remove`], so every algorithm below reaches them +// through those two. +// --------------------------------------------------------------------- + +/// The `DOMException` names the algorithms below throw. +pub enum DomError { + /// "HierarchyRequestError" + HierarchyRequest, + /// "NotFoundError" + NotFound, +} + +/// The kinds of node the validity checks count among a parent's children. +pub enum NodeTag { + /// An `Element`. + Element, + /// A `Text` node. + Text, + /// A `DocumentType` (a "doctype"). + DocumentType, +} + +/// A node of kind `k` is a node of the tag `t`. +pub open spec fn has_tag(k: NodeKind, t: NodeTag) -> bool { + match t { + NodeTag::Element => k is Element, + NodeTag::Text => k is Text, + NodeTag::DocumentType => k is DocumentType, + } +} + +/// How many of `kids` have the tag `t`, other than `skip` (a node, or none). +/// Defined from the end, so that appending a child adds its share. +pub open spec fn count_tag(doc: Document, kids: Seq, t: NodeTag, skip: Option) -> nat + decreases kids.len(), +{ + if kids.len() == 0 { + 0 + } else { + let last = kids.last(); + count_tag(doc, kids.drop_last(), t, skip) + if has_tag(doc.nodes[last as int].kind, t) && skip != Some(last) { + 1nat + } else { + 0nat + } + } +} + +/// DOM §4.2 "next sibling": "the first following sibling", null if there is +/// none (or no parent). +pub open spec fn next_sibling(doc: Document, n: NodeId) -> Option { + match parent(doc, n) { + None => None, + Some(p) => { + let i = index_of(children(doc, p), n); + if 0 <= i && i + 1 < children(doc, p).len() { + Some(children(doc, p)[i + 1]) + } else { + None + } + }, + } +} + +/// `a` is `x` or one of its first `fuel` host-including ancestors (§4.2). +pub open spec fn host_including_within(doc: Document, a: NodeId, x: NodeId, fuel: nat) -> bool + decreases fuel, +{ + if x == a { + true + } else if fuel == 0 { + false + } else { + match parent(doc, x) { + Some(p) => host_including_within(doc, a, p, (fuel - 1) as nat), + None => match doc.nodes[x as int].kind { + // x is a root: "if B's root has a non-null host and A is a + // host-including inclusive ancestor of B's root's host". + NodeKind::DocumentFragment { host: Some(h) } => host_including_within(doc, a, h, (fuel - 1) as nat), + _ => false, + }, + } + } +} + +/// DOM §4.2 "host-including inclusive ancestor": "An object A is a +/// host-including inclusive ancestor of an object B, if either A is an +/// inclusive ancestor of B, or if B's root has a non-null host and A is a +/// host-including inclusive ancestor of B's root's host." +pub open spec fn is_host_including_inclusive_ancestor(doc: Document, a: NodeId, x: NodeId) -> bool { + host_including_within(doc, a, x, doc.nodes.len()) +} + +/// The statements of step 6 of "ensure pre-insertion validity"† about a +/// `parent` that is a document, switched on the interface `node` +/// implements. True means "throw a HierarchyRequestError". +pub open spec fn pre_insert_document_violation(doc: Document, node: NodeId, parent: NodeId, child: Option) -> bool { + let kids = children(doc, parent); + // "child is non-null and a doctype is following child" and "an element + // is preceding child": the siblings after / before child. + let after = match child { + Some(c) => count_tag(doc, kids.subrange(index_of(kids, c) + 1, kids.len() as int), NodeTag::DocumentType, None), + None => 0, + }; + let before = match child { + Some(c) => count_tag(doc, kids.subrange(0, index_of(kids, c)), NodeTag::Element, None), + None => 0, + }; + let child_is_doctype = match child { + Some(c) => doc.nodes[c as int].kind is DocumentType, + None => false, + }; + match doc.nodes[node as int].kind { + // "DocumentFragment: If node has more than one element child or has + // a Text node child. Otherwise, if node has one element child and + // either parent has an element child, child is a doctype, or child + // is non-null and a doctype is following child." + NodeKind::DocumentFragment { .. } => { + let elements = count_tag(doc, children(doc, node), NodeTag::Element, None); + let texts = count_tag(doc, children(doc, node), NodeTag::Text, None); + elements > 1 || texts > 0 || (elements == 1 && (count_tag(doc, kids, NodeTag::Element, None) > 0 || child_is_doctype + || after > 0)) + }, + // "Element: parent has an element child, child is a doctype, or + // child is non-null and a doctype is following child." + NodeKind::Element { .. } => count_tag(doc, kids, NodeTag::Element, None) > 0 || child_is_doctype || after > 0, + // "DocumentType: parent has a doctype child, child is non-null and + // an element is preceding child, or child is null and parent has an + // element child." + NodeKind::DocumentType { .. } => count_tag(doc, kids, NodeTag::DocumentType, None) > 0 || before > 0 || (child is None + && count_tag(doc, kids, NodeTag::Element, None) > 0), + _ => false, + } +} + +/// DOM §4.2.3† "ensure pre-insertion validity" of `node` into `parent` +/// before `child`: the error the algorithm throws, or none. +/// "1. If parent is not a Document, DocumentFragment, or Element node, +/// then throw a "HierarchyRequestError" DOMException. 2. If node is a +/// host-including inclusive ancestor of parent, then throw a +/// "HierarchyRequestError". 3. If child is non-null and its parent is not +/// parent, then throw a "NotFoundError". 4. If node is not a +/// DocumentFragment, DocumentType, Element, or CharacterData node, then +/// throw a "HierarchyRequestError". 5. If either node is a Text node and +/// parent is a document, or node is a doctype and parent is not a +/// document, then throw a "HierarchyRequestError". 6. If parent is a +/// document, and any of the statements below, switched on the interface +/// node implements, are true, then throw a "HierarchyRequestError"." +pub open spec fn pre_insert_error(doc: Document, node: NodeId, parent: NodeId, child: Option) -> Option { + // 1. + if !may_have_children(doc.nodes[parent as int].kind) { + Some(DomError::HierarchyRequest) + } + // 2. + else if is_host_including_inclusive_ancestor(doc, node, parent) { + Some(DomError::HierarchyRequest) + } + // 3. + else if child is Some && doc.nodes[child->Some_0 as int].parent != Some(parent) { + Some(DomError::NotFound) + } + // 4. (Every kind but a Document is one of the listed.) + else if doc.nodes[node as int].kind is Document { + Some(DomError::HierarchyRequest) + } + // 5. + else if (doc.nodes[node as int].kind is Text && doc.nodes[parent as int].kind is Document) || (doc.nodes[node as int].kind is DocumentType + && !(doc.nodes[parent as int].kind is Document)) { + Some(DomError::HierarchyRequest) + } + // 6. + else if doc.nodes[parent as int].kind is Document && pre_insert_document_violation(doc, node, parent, child) { + Some(DomError::HierarchyRequest) + } else { + None + } +} + +/// What the callers of the algorithms below guarantee of their ids: they +/// name nodes of a well-formed arena. +pub open spec fn ids_requires(doc: Document, node: NodeId, parent: NodeId, child: Option) -> bool { + &&& wf(doc) + &&& valid(doc, node) + &&& valid(doc, parent) + &&& match child { + None => true, + Some(c) => valid(doc, c), + } +} + +/// DOM §4.2.3 "remove" every child of `parent`, "in tree order": the +/// first `n` remaining children are removed, one after the other. +pub open spec fn remove_children_n(doc: Document, parent: NodeId, n: nat) -> Document + decreases n, +{ + if n == 0 || children(doc, parent).len() == 0 { + doc + } else { + remove_children_n(remove(doc, children(doc, parent)[0]), parent, (n - 1) as nat) + } +} + +/// "Remove all parent's children, in tree order" (DOM §4.2.3† "replace +/// all" step 5, "insert" step 4.1). +pub open spec fn remove_children(doc: Document, parent: NodeId) -> Document { + remove_children_n(doc, parent, children(doc, parent).len()) +} + +/// Insert each of `nodes`, in order, into `parent` before `child` (DOM +/// §4.2.3 "insert" step 7, "For each node in nodes, in tree order"), each +/// a node that is not a `DocumentFragment`. +pub open spec fn insert_list(doc: Document, nodes: Seq, parent: NodeId, child: Option) -> Document + decreases nodes.len(), +{ + if nodes.len() == 0 { + doc + } else { + insert_list(insert(doc, nodes[0], parent, child), nodes.drop_first(), parent, child) + } +} + +/// DOM §4.2.3 "insert" a `DocumentFragment` `node` into `parent` before +/// `child` (null: `None`): "1. Let nodes be node's children, if node is a +/// DocumentFragment node; otherwise « node ». 2. Let count be nodes's size. +/// 3. If count is 0, then return. 4. If node is a DocumentFragment node: +/// 1. Remove its children with the suppress observers flag set. 2. Queue a +/// tree mutation record for node with « », nodes, null, and null." (not +/// modelled) "5. If child is non-null: …" (live ranges, not modelled) "6. +/// Let previousSibling be …" (observers, not modelled) "7. For each node +/// in nodes, in tree order: …" ([`insert_list`]; each node has no parent, +/// so step 7.1's adopt changes nothing). +pub open spec fn insert_fragment(doc: Document, node: NodeId, parent: NodeId, child: Option) -> Document { + // 1. and 2. + let nodes = children(doc, node); + // 3. + if nodes.len() == 0 { + doc + } else { + // 4.1 + let d1 = remove_children(doc, node); + // 7. + insert_list(d1, nodes, parent, child) + } +} + +/// DOM §4.2.3 "insert" for any `node`: a `DocumentFragment` by +/// [`insert_fragment`], any other node by [`insert`] (the parser's +/// operation, whose steps 1 to 4 do nothing for « node »). +pub open spec fn insert_any(doc: Document, node: NodeId, parent: NodeId, child: Option) -> Document { + if doc.nodes[node as int].kind is DocumentFragment { + insert_fragment(doc, node, parent, child) + } else { + insert(doc, node, parent, child) + } +} + +/// DOM §4.2.3† "pre-insert" `node` into `parent` before `child`, on a +/// valid call: "1. Ensure pre-insertion validity of node, parent, and +/// child." (An error leaves the tree as it is: [`pre_insert_error`].) "2. +/// Let referenceChild be child. 3. If referenceChild is node, then set +/// referenceChild to node's next sibling. 4. Insert node into parent before +/// referenceChild. 5. Return node." +pub open spec fn pre_insert(doc: Document, node: NodeId, parent: NodeId, child: Option) -> Document { + // 1. + if pre_insert_error(doc, node, parent, child) is Some { + doc + } else { + // 2. and 3. + let reference_child = if child == Some(node) { + next_sibling(doc, node) + } else { + child + }; + // 4. + insert_any(doc, node, parent, reference_child) + } +} + +/// The statements of step 6 of "replace"† about a `parent` that is a +/// document; true means "throw a HierarchyRequestError". They differ from +/// pre-insert's: "an element child that is not child", and a doctype +/// following (or an element preceding) `child`. +pub open spec fn replace_document_violation(doc: Document, child: NodeId, node: NodeId, parent: NodeId) -> bool { + let kids = children(doc, parent); + let i = index_of(kids, child); + let after = count_tag(doc, kids.subrange(i + 1, kids.len() as int), NodeTag::DocumentType, None); + let before = count_tag(doc, kids.subrange(0, i), NodeTag::Element, None); + match doc.nodes[node as int].kind { + // "DocumentFragment: If node has more than one element child or has + // a Text node child. Otherwise, if node has one element child and + // either parent has an element child that is not child or a doctype + // is following child." + NodeKind::DocumentFragment { .. } => { + let elements = count_tag(doc, children(doc, node), NodeTag::Element, None); + let texts = count_tag(doc, children(doc, node), NodeTag::Text, None); + elements > 1 || texts > 0 || (elements == 1 && (count_tag(doc, kids, NodeTag::Element, Some(child)) > 0 || after > 0)) + }, + // "Element: parent has an element child that is not child or a + // doctype is following child." + NodeKind::Element { .. } => count_tag(doc, kids, NodeTag::Element, Some(child)) > 0 || after > 0, + // "DocumentType: parent has a doctype child that is not child, or + // an element is preceding child." + NodeKind::DocumentType { .. } => count_tag(doc, kids, NodeTag::DocumentType, Some(child)) > 0 || before > 0, + _ => false, + } +} + +/// Steps 1 to 6 of DOM §4.2.3† "replace" `child` with `node` within +/// `parent`: the error it throws, or none. "1. If parent is not a +/// Document, DocumentFragment, or Element node, then throw a +/// "HierarchyRequestError". 2. If node is a host-including inclusive +/// ancestor of parent, then throw a "HierarchyRequestError". 3. If child's +/// parent is not parent, then throw a "NotFoundError". 4. If node is not a +/// DocumentFragment, DocumentType, Element, or CharacterData node, then +/// throw a "HierarchyRequestError". 5. If either node is a Text node and +/// parent is a document, or node is a doctype and parent is not a +/// document, then throw a "HierarchyRequestError". 6. If parent is a +/// document, and any of the statements below, switched on the interface +/// node implements, are true, then throw a "HierarchyRequestError"." +pub open spec fn replace_error(doc: Document, child: NodeId, node: NodeId, parent: NodeId) -> Option { + // 1. + if !may_have_children(doc.nodes[parent as int].kind) { + Some(DomError::HierarchyRequest) + } + // 2. + else if is_host_including_inclusive_ancestor(doc, node, parent) { + Some(DomError::HierarchyRequest) + } + // 3. + else if doc.nodes[child as int].parent != Some(parent) { + Some(DomError::NotFound) + } + // 4. + else if doc.nodes[node as int].kind is Document { + Some(DomError::HierarchyRequest) + } + // 5. + else if (doc.nodes[node as int].kind is Text && doc.nodes[parent as int].kind is Document) || (doc.nodes[node as int].kind is DocumentType + && !(doc.nodes[parent as int].kind is Document)) { + Some(DomError::HierarchyRequest) + } + // 6. + else if doc.nodes[parent as int].kind is Document && replace_document_violation(doc, child, node, parent) { + Some(DomError::HierarchyRequest) + } else { + None + } +} + +/// DOM §4.2.3† "replace" `child` with `node` within `parent`, on a valid +/// call. "7. Let referenceChild be child's next sibling. 8. If +/// referenceChild is node, then set referenceChild to node's next sibling. +/// 9. Let previousSibling be child's previous sibling. 10. Let +/// removedNodes be the empty set. 11. If child's parent is non-null, then: +/// 1. Set removedNodes to « child ». 2. Remove child with the suppress +/// observers flag set. 12. Let nodes be node's children if node is a +/// DocumentFragment node; otherwise « node ». 13. Insert node into parent +/// before referenceChild with the suppress observers flag set. 14. Queue a +/// tree mutation record … 15. Return child." Steps 9, 10, 12 (only +/// `nodes`' size matters to "insert") and 14 touch observers only. An +/// error (steps 1 to 6) leaves the tree as it is. +pub open spec fn replace(doc: Document, child: NodeId, node: NodeId, parent: NodeId) -> Document { + if replace_error(doc, child, node, parent) is Some { + doc + } else { + // 7. + let reference0 = next_sibling(doc, child); + // 8. + let reference_child = if reference0 == Some(node) { + next_sibling(doc, node) + } else { + reference0 + }; + // 11. + let d1 = if doc.nodes[child as int].parent is Some { + remove(doc, child) + } else { + doc + }; + // 13. + insert_any(d1, node, parent, reference_child) + } +} + +/// What a caller of [`replace_all`] guarantees: `parent` may have children, +/// `node` (if any) is not a document and not a host-including inclusive +/// ancestor of `parent`. (The standard's callers, `textContent` and +/// `replaceChildren`, have established what "insert" needs; DOM's "replace +/// all" checks nothing itself.) +pub open spec fn replace_all_requires(doc: Document, node: Option, parent: NodeId) -> bool { + &&& wf(doc) + &&& valid(doc, parent) + &&& may_have_children(doc.nodes[parent as int].kind) + &&& match node { + None => true, + Some(n) => valid(doc, n) && !(doc.nodes[n as int].kind is Document) && !is_host_including_inclusive_ancestor(doc, n, parent), + } +} + +/// DOM §4.2.3† "replace all with a node `node` within a node `parent`": +/// "1. Let removedNodes be parent's children. 2. Let addedNodes be the +/// empty set. 3. If node is a DocumentFragment node, then set addedNodes to +/// node's children. 4. Otherwise, if node is non-null, set addedNodes to « +/// node ». 5. Remove all parent's children, in tree order, with the +/// suppress observers flag set. 6. If node is non-null, then insert node +/// into parent before null with the suppress observers flag set. 7. If +/// either addedNodes or removedNodes is not empty, then queue a tree +/// mutation record for parent with addedNodes, removedNodes, null, and +/// null." Steps 1 to 4 and 7 only feed observers. +pub open spec fn replace_all(doc: Document, node: Option, parent: NodeId) -> Document { + // 5. + let d1 = remove_children(doc, parent); + // 6. + match node { + Some(n) => insert_any(d1, n, parent, None), + None => d1, + } +} + +// --------------------------------------------------------------------- +// Cloning (DOM §4.4† "clone a node") + +/// The kind of the copy made by steps 2 and 3 of "clone a node"†: "2. If +/// node is an element, then: create an element with … node's local name, +/// node's namespace, node's namespace prefix …. Let copy be the result. +/// Then, for each attribute in node's attribute list: Let copyAttribute be +/// a clone of attribute. Append copyAttribute to copy. 3. Otherwise, let +/// copy be a node that implements the same interfaces as node, and +/// fulfills these additional requirements, switching on the interface node +/// implements: … DocumentType: Set copy's name, public ID, and system ID to +/// those of node. … Text, Comment: Set copy's data to that of node. +/// ProcessingInstruction: Set copy's target and data to those of node. Any +/// other node: Do nothing." A created element has no template contents +/// (yet) and no form owner. A document is not cloned here (one per arena). +pub open spec fn clone_kind(k: NodeKind) -> NodeKind { + match k { + NodeKind::Element { namespace, prefix, local_name, attributes, .. } => NodeKind::Element { + namespace, + prefix, + local_name, + attributes, + template_contents: None, + form_owner: None, + }, + NodeKind::DocumentFragment { .. } => NodeKind::DocumentFragment { host: None }, + other => other, + } +} + +/// A template element (see the modelling choices). +pub open spec fn is_template(k: NodeKind) -> bool { + k is Element && k->Element_template_contents is Some +} + +/// How many nodes cloning `node` creates: the copy, and for a template its +/// contents too. +pub open spec fn clone_count(doc: Document, node: NodeId) -> nat { + if is_template(doc.nodes[node as int].kind) { + 2 + } else { + 1 + } +} + +/// DOM §4.4† "clone a node" `node`, with the clone children flag unset: +/// "1. If document is not given, let document be node's node document." +/// (One document.) "2.", "3." ([`clone_kind`]). "4. Set copy's node +/// document and document to document." (Implicit.) "5. Run any cloning +/// steps defined for node in other applicable specifications and pass copy, +/// node, document, and the clone children flag if set, as parameters." +/// (HTML §4.12.3: a template's cloning steps return when the flag is +/// unset; its copy was created with template contents, step 2.) "6. If the +/// clone children flag is set, …" (never.) "7. Return copy." The copy's id +/// is the next one; a template's contents' is the one after. +pub open spec fn clone_node(doc: Document, node: NodeId) -> (Document, NodeId) { + // 2. and 3. + let (d1, copy) = create_node(doc, clone_kind(doc.nodes[node as int].kind)); + // 5. + if is_template(doc.nodes[node as int].kind) { + (create_template_contents(d1, copy).0, copy) + } else { + (d1, copy) + } +} + +/// What the caller of [`clone_node`] guarantees: `node` is a node of a +/// well-formed arena, and not its document. +pub open spec fn clone_requires(doc: Document, node: NodeId) -> bool { + &&& wf(doc) + &&& valid(doc, node) + &&& !(doc.nodes[node as int].kind is Document) +} + +// --------------------------------------------------------------------- +// Attribute changes (DOM §4.9†) + +/// The element `e` with its attribute list replaced by `attrs`. +pub open spec fn set_attributes(doc: Document, e: NodeId, attrs: Seq) -> Document { + let node = doc.nodes[e as int]; + let k = match node.kind { + NodeKind::Element { namespace, prefix, local_name, template_contents, form_owner, .. } => NodeKind::Element { + namespace, + prefix, + local_name, + attributes: attrs, + template_contents, + form_owner, + }, + other => other, + }; + Document { nodes: doc.nodes.update(e as int, Node { kind: k, ..node }) } +} + +/// DOM §4.9† "change an attribute" (the `i`th of `e`'s attribute list) "to +/// value": "1. Let oldValue be attribute's value. 2. Set attribute's value +/// to value. 3. Handle attribute changes for attribute with attribute's +/// element, oldValue, and value." (Not modelled.) +pub open spec fn change_attribute(doc: Document, e: NodeId, i: nat, value: Seq) -> Document { + let attrs = doc.nodes[e as int].kind->Element_attributes; + set_attributes(doc, e, attrs.update(i as int, Attr { value, ..attrs[i as int] })) +} + +/// DOM §4.9† "remove an attribute" (the `i`th of `e`'s attribute list): +/// "1. Let element be attribute's element. 2. Remove attribute from +/// element's attribute list. 3. Set attribute's element to null. 4. Handle +/// attribute changes for attribute with element, attribute's value, and +/// null." (Step 3 is implicit, step 4 not modelled.) +pub open spec fn remove_attribute(doc: Document, e: NodeId, i: nat) -> Document { + set_attributes(doc, e, doc.nodes[e as int].kind->Element_attributes.remove(i as int)) +} + +/// DOM §4.9† "replace an attribute" (the `i`th of `e`'s attribute list, +/// oldAttr) "with newAttr": "1. Replace oldAttr by newAttr in oldAttr's +/// element's attribute list. 2. Set newAttr's element to oldAttr's +/// element. 3. Set newAttr's node document to element's node document. 4. +/// Set oldAttr's element to null. 5. Handle attribute changes for oldAttr +/// with oldAttr's element, oldAttr's value, and newAttr's value." (Steps 2 +/// to 4 are implicit, step 5 not modelled.) +pub open spec fn replace_attribute(doc: Document, e: NodeId, i: nat, new_attr: Attr) -> Document { + set_attributes(doc, e, doc.nodes[e as int].kind->Element_attributes.update(i as int, new_attr)) +} + +/// What the callers of the attribute changes above guarantee: `e` is an +/// element of a well-formed arena and `i` names one of its attributes. +pub open spec fn attribute_requires(doc: Document, e: NodeId, i: nat) -> bool { + &&& wf(doc) + &&& valid(doc, e) + &&& doc.nodes[e as int].kind is Element + &&& i < doc.nodes[e as int].kind->Element_attributes.len() +} + } // verus! From 149f059d6560353838d2fcbd3cbbed4a2988f72f Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 17:02:56 +0000 Subject: [PATCH 031/195] clazel-js-regexp: shorter Miri runs for the differential and the catastrophic test Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js-regexp/tests/differential.rs | 2 +- crates/clazel-js-regexp/tests/limits.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/clazel-js-regexp/tests/differential.rs b/crates/clazel-js-regexp/tests/differential.rs index 216720d1..ad93c644 100644 --- a/crates/clazel-js-regexp/tests/differential.rs +++ b/crates/clazel-js-regexp/tests/differential.rs @@ -1059,7 +1059,7 @@ fn run_differential( #[test] fn matcher_agrees_with_the_reference() -> Result<(), String> { - let (patterns, inputs) = if cfg!(miri) { (40, 3) } else { (6000, 8) }; + let (patterns, inputs) = if cfg!(miri) { (10, 2) } else { (6000, 8) }; let mut total = Tally { patterns: 0, parse_errors: 0, diff --git a/crates/clazel-js-regexp/tests/limits.rs b/crates/clazel-js-regexp/tests/limits.rs index 32479802..f8b14d79 100644 --- a/crates/clazel-js-regexp/tests/limits.rs +++ b/crates/clazel-js-regexp/tests/limits.rs @@ -59,9 +59,10 @@ fn nested_quantifier_hits_the_step_limit() -> Result<(), String> { fn small_catastrophic_input_still_finishes() -> Result<(), String> { // Without a limit the same pattern is just slow: 2^n paths, so n = 14 // finishes at once and has no match. - let input = units(&"a".repeat(14)); + let n = scale(14, 6); + let input = units(&"a".repeat(n)); assert_eq!(is_match("(a*)*b", &input, &Limits::default())?, Ok(false)); - let with_b = units(&format!("{}b", "a".repeat(14))); + let with_b = units(&format!("{}b", "a".repeat(n))); assert_eq!(is_match("(a*)*b", &with_b, &Limits::default())?, Ok(true)); Ok(()) } From 347f36cc24d33d761728e28a19e3af4dd58d0f74 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 17:16:19 +0000 Subject: [PATCH 032/195] xtask: an ENGINE list, so engine crates reach no browser crate phase-7.md's boundary says engine crates depend on no browser crate and that cargo xtask check enforces it through an ENGINE list next to PLACES. The list did not exist. It names the clazel-js crates, rejects any path (direct or through another crate) to a browser crate, and fails on a clazel-js* crate missing from the list. clazel-js is placed in the Renderer component. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 4 ++ xtask/src/main.rs | 13 ++++++ xtask/src/status.rs | 111 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 127 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index c8972623..32f30af2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -388,6 +388,10 @@ dependencies = [ "vstd", ] +[[package]] +name = "clazel-js" +version = "0.0.0" + [[package]] name = "clazel-js-lexer" version = "0.0.0" diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 0feed148..d77e3088 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -342,6 +342,19 @@ fn static_checks(r: &mut Runner, crates: &[Crate], pins: &Pins) { "every crate placed in the status images", outcome(status::placement_problems(&names), Vec::new()), ); + let engine_deps: Vec<(String, Vec)> = crates + .iter() + .map(|c| { + ( + c.name.clone(), + c.deps_normal().into_iter().map(|(n, _)| n).collect(), + ) + }) + .collect(); + r.step( + "engine crates depend on no browser crate", + outcome(status::engine_problems(&engine_deps), Vec::new()), + ); // Unreviewed specs are not a failure (agents must be able to edit // them), but every run lists them. let review_notes: Vec = review_status diff --git a/xtask/src/status.rs b/xtask/src/status.rs index 95f09263..6e316807 100644 --- a/xtask/src/status.rs +++ b/xtask/src/status.rs @@ -72,6 +72,7 @@ const PLACES: &[(&str, Place)] = &[ ("clazel-css", Place::Renderer), ("clazel-selectors", Place::Renderer), ("clazel-js-lexer", Place::Renderer), + ("clazel-js", Place::Renderer), ("clazel-js-vm", Place::Renderer), ("clazel-js-syntax", Place::Renderer), ("clazel-style", Place::Renderer), @@ -100,6 +101,31 @@ const PLACES: &[(&str, Place)] = &[ ("clazel-sys", Place::Os), ]; +/// The engine crates (phase-7.md, "The engine as a library"): a program other +/// than the browser can embed them, so none may depend, directly or through +/// other crates, on a crate in [`BROWSER`]. `cargo xtask check` enforces this. +/// `clazel-js*` crates not listed here fail the check too, so a new engine +/// crate cannot skip the rule by being left out. +const ENGINE: &[&str] = &[ + "clazel-js", + "clazel-js-lexer", + "clazel-js-regexp", + "clazel-js-syntax", + "clazel-js-vm", +]; + +/// The crates an engine crate must never reach (phase-7.md, "The boundary"). +const BROWSER: &[&str] = &[ + "clazel-dom", + "clazel-webidl", + "clazel-web", + "clazel-ipc", + "clazel-kernel", + "clazel-renderer", + "clazel-url", + "clazel-fetch", +]; + /// Workspace members that are not part of the browser, so not drawn. const NOT_DRAWN: &[&str] = &["xtask"]; @@ -143,6 +169,49 @@ pub fn placement_problems(names: &[&str]) -> Vec { out } +/// Engine crates that reach a browser crate through normal dependencies, and +/// `clazel-js*` workspace crates missing from [`ENGINE`]. `deps` is each +/// workspace crate's name with its normal dependencies' names. +pub fn engine_problems(deps: &[(String, Vec)]) -> Vec { + let direct = |name: &str| -> &[String] { + deps.iter() + .find(|(n, _)| n == name) + .map_or(&[][..], |(_, d)| d.as_slice()) + }; + let mut out = Vec::new(); + for (name, _) in deps { + if name.starts_with("clazel-js") && !ENGINE.contains(&name.as_str()) { + out.push(format!( + "{name}: an engine crate (clazel-js*) missing from ENGINE in xtask/src/status.rs" + )); + } + } + for e in ENGINE { + if !deps.iter().any(|(n, _)| n == e) { + out.push(format!( + "xtask/src/status.rs: ENGINE names {e}, which is no workspace crate" + )); + continue; + } + // Breadth-first over the workspace crates reachable from `e`. + let mut seen: Vec<&str> = vec![e]; + let mut next = 0; + while let Some(&cur) = seen.get(next) { + next = next.saturating_add(1); + for d in direct(cur) { + if BROWSER.contains(&d.as_str()) { + out.push(format!( + "{e}: engine crate depends on browser crate {d} (via {cur}); engine crates depend on no browser crate" + )); + } else if deps.iter().any(|(n, _)| n == d) && !seen.contains(&d.as_str()) { + seen.push(d.as_str()); + } + } + } + } + out +} + /// The first sentence of an `axioms.rs`'s module documentation, for the /// detail image's note on axioms. `None` if the crate has no such file or /// it has no `//!` comment. @@ -995,7 +1064,8 @@ pub fn render( #[cfg(test)] mod tests { use super::{ - PLACES, Place, Rows, SCOREBOARD_PER_LINE, numbers, placement_problems, render, short_count, + ENGINE, PLACES, Place, Rows, SCOREBOARD_PER_LINE, engine_problems, numbers, + placement_problems, render, short_count, }; fn row(cells: &[&str]) -> Vec { @@ -1112,6 +1182,45 @@ mod tests { assert!(render(&rows, &|_| None).is_err()); } + #[test] + fn engine_crates_reach_no_browser_crate() { + // The engine crates, with these edges, plus the other crates named. + let graph = |edges: &[(&str, &[&str])], extra: &[&str]| { + let mut deps: Vec<(String, Vec)> = ENGINE + .iter() + .map(|e| { + let to = edges + .iter() + .find(|(n, _)| n == e) + .map_or(&[][..], |(_, d)| *d); + ( + (*e).to_owned(), + to.iter().map(|d| (*d).to_owned()).collect(), + ) + }) + .collect(); + deps.extend(extra.iter().map(|n| ((*n).to_owned(), Vec::new()))); + engine_problems(&deps) + }; + assert!(graph(&[], &[]).is_empty()); + // A direct dependency. + assert_eq!( + graph(&[("clazel-js", &["clazel-dom"])], &["clazel-dom"]).len(), + 1 + ); + // A transitive one, through another engine crate: both are reported. + let found = graph( + &[ + ("clazel-js", &["clazel-js-vm"]), + ("clazel-js-vm", &["clazel-dom"]), + ], + &["clazel-dom"], + ); + assert_eq!(found.len(), 2, "{found:?}"); + // An engine crate left out of ENGINE. + assert_eq!(graph(&[], &["clazel-js-heap"]).len(), 1); + } + #[test] fn short_counts() { assert_eq!(short_count(912), "912"); From 88a03e3d4fb7a3f6b5c684a95bb043605a0f11a9 Mon Sep 17 00:00:00 2001 From: Alex Tiernan-Berry Date: Sat, 21 Nov 2026 17:16:19 +0000 Subject: [PATCH 033/195] clazel-js: the embedding API contract (phase 7.8, contract first) The public types, traits and signatures of the engine's embedding API, with a README stating the rules and doc examples that compile (no_run). Every operation that needs the engine returns Error::NotImplemented; the Terminator, DefaultHost and Limits are real because they are small. Tier 0, no dependencies. Co-Authored-By: Claude Opus 5.5 --- crates/clazel-js/Cargo.toml | 21 + crates/clazel-js/README.md | 325 ++++++++++++++ crates/clazel-js/src/code.rs | 293 ++++++++++++ crates/clazel-js/src/error.rs | 193 ++++++++ crates/clazel-js/src/host.rs | 477 ++++++++++++++++++++ crates/clazel-js/src/lib.rs | 46 ++ crates/clazel-js/src/native.rs | 237 ++++++++++ crates/clazel-js/src/runtime.rs | 330 ++++++++++++++ crates/clazel-js/src/scope.rs | 775 ++++++++++++++++++++++++++++++++ crates/clazel-js/src/value.rs | 346 ++++++++++++++ 10 files changed, 3043 insertions(+) create mode 100644 crates/clazel-js/Cargo.toml create mode 100644 crates/clazel-js/README.md create mode 100644 crates/clazel-js/src/code.rs create mode 100644 crates/clazel-js/src/error.rs create mode 100644 crates/clazel-js/src/host.rs create mode 100644 crates/clazel-js/src/lib.rs create mode 100644 crates/clazel-js/src/native.rs create mode 100644 crates/clazel-js/src/runtime.rs create mode 100644 crates/clazel-js/src/scope.rs create mode 100644 crates/clazel-js/src/value.rs diff --git a/crates/clazel-js/Cargo.toml b/crates/clazel-js/Cargo.toml new file mode 100644 index 00000000..da3af2cf --- /dev/null +++ b/crates/clazel-js/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "clazel-js" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish.workspace = true +description = "The JavaScript engine's embedding API for Clazel (phase-7.md item 7.8): Runtime, realms, scripts and modules, native functions, host objects, rooted handles, the Host trait, limits and the Terminator. This is the contract only; nothing here is implemented yet." + +# No dependencies yet. When the engine's types are needed here they come from +# other engine crates only (`cargo xtask check` enforces that no engine crate +# reaches a browser crate; see ENGINE in xtask/src/status.rs). +[dependencies] + +# Verification tier (docs/VERIFICATION.md). Tier 0: this crate holds the +# contract and its stubs, and nothing is proven about it. +[package.metadata.clazel] +tier = 0 +target-tier = 0 + +[lints] +workspace = true diff --git a/crates/clazel-js/README.md b/crates/clazel-js/README.md new file mode 100644 index 00000000..864d3f60 --- /dev/null +++ b/crates/clazel-js/README.md @@ -0,0 +1,325 @@ +# clazel-js: the engine's embedding API + +`clazel-js` is the one crate a program names to embed Clazel's JavaScript +engine. The browser embeds it, and so can a command-line runtime, a +Node-style server, or another Rust program. This is phase-7.md item 7.8, and +"The engine as a library" in that file is the plan this README works out. + +**Status: the contract, and nothing else.** The types and signatures here are +the proposal, and the doc comments carry examples that compile (`no_run`, +because there is nothing to run). Every operation that needs the engine returns +`Error::NotImplemented`. Tier 0, no proofs. The contract is written first, as +the plan says, so that people can review it before `clazel-webidl` and +`clazel-web` build on it. What to review is below, in "Open questions". + +Read the API in `src/`, one file per topic: `runtime.rs` (Runtime, limits, +Terminator), `value.rs` (the four ways to hold a value), `scope.rs` (all the +operations), `code.rs` (realms, source, scripts, modules), `native.rs` +(native functions, host objects), `host.rs` (the `Host` trait), `error.rs`. +`cargo doc -p clazel-js --no-deps --open` shows the same with the examples. + +## The boundary + +- Engine crates depend on no browser crate. `cargo xtask check` enforces it + with the `ENGINE` list in `xtask/src/status.rs`, which holds this crate. +- `clazel-js` has no dependencies yet. It will re-export the types the API needs + from other engine crates (the heap's value and arena types) and no more. +- The browser uses only this public API. A binding that needs something the API + lacks gets it added here, not a private path. +- The Test262 runner (`clazel-js-shell`, a later item) is a second embedder and + builds `$262` from public calls alone. + +## A `Runtime` + +A `Runtime` is one ECMAScript agent: a heap, a job queue, limits and a `Host`. + +- **No global state.** No `static`, no thread-local. A process can hold many + runtimes. +- **`Send`, not `Sync`.** A runtime can move to another thread between calls, and + only one thread uses it at a time. Compile-checked by doctests. For this to + hold the `Host` is `Send` too. The browser runs one runtime per renderer, on + one thread (7.0(e)). +- **Everything goes through a scope.** `Runtime::scope(|scope| ...)` is the only + way in. Inside native functions and `Host` hooks the engine hands over a + `Scope` for that call. +- **Dropping a runtime** frees the heap and drops native closures and host + object data. It runs no JavaScript. + +Configuration is a `Config` of `Limits` and a `JitMode` (only `Off` until jit.md's +crate exists), and a `Host`: + +```rust,no_run +use clazel_js::{Config, DefaultHost, Limits, RealmOptions, Runtime, Source}; + +fn main() -> Result<(), clazel_js::Error> { + let mut rt = Runtime::new(Config::new(Limits::unlimited()), DefaultHost::new())?; + let realm = rt.scope(|scope| scope.create_realm(RealmOptions::default()))?; + let sum = rt.scope(|scope| { + let value = scope.eval_script(&realm, Source::new("sum.js", "1 + 2"))?; + Ok(scope.as_number(value)) + })?; + assert_eq!(sum, Some(3.0)); + rt.run_jobs()?; + Ok(()) +} +``` + +## Realms + +`Scope::create_realm` makes a realm: a global object and its own built-ins. +`$262.createRealm()` is exactly this, and frames would be later. A `Realm` is a +root (cloneable, `Send`, `Sync`) and every call that runs code names its realm. +`Scope::global` reaches the global object, and installing `console` or `window` +is ordinary property definition on it. `RealmOptions::global` lets the +global object be a host object, which the browser's `Window` needs. +`Scope::set_realm_host_defined` attaches the embedder's data to a realm (HTML's +environment settings object). + +## Scripts and modules + +- **Source** is `Source { name, text, start_line, host_defined }`. The text is a + `&str`, a sequence of code points, as ECMA-262 defines source text. The name + is for stack traces and reports, and `host_defined` is the embedder's data + (base URL, fetch options), kept with the compiled code. +- **Scripts.** `eval_script` does `compile_script` then `run_script`, which are + separate so a host can follow HTML's "prepare the script element". A syntax + error is a thrown `SyntaxError`. +- **Modules** follow ECMA-262's phases, one method each: `parse_module`, + `load_requested_modules`, `link`, `evaluate_module`, plus `module_namespace` and + `module_status`. Loading is asynchronous and the host's: the engine calls + `Host::load_imported_module(referrer, request, payload)`, and the host + answers with `Scope::finish_loading_imported_module(payload, result)`, now or + on a later event-loop turn. Dynamic `import()` uses the same hook. The + `Referrer` carries the importing code's `host_defined` data, so the host knows + what to resolve against. `import.meta` goes through two more hooks. A host + can add its own resolver, or CommonJS (through synthetic modules), without + engine changes. +- **Jobs.** The engine queues jobs and runs them only when asked: + `Runtime::run_jobs` is a microtask checkpoint. The event loop is the host's. + HTML's lives in `clazel-web`, and a Node-style runtime would drive the same + calls from its own. + +## Values, and holding them + +Values live in the collector's heap, which does not move them (7.0(f)). Four +types hold a value, from cheapest to most durable: + +| Type | Roots the value? | Lives | Use | +|---|---|---|---| +| `Local<'s>` | yes, until its scope ends | one `Scope` | everything inside a call. `Copy`; cannot escape the closure (compile-checked) | +| `Handle` | yes, until dropped | any time, any thread | what outlives a call: a callback to run later, a promise's resolvers. `Clone`, `Send`, `Sync`; dropping needs no runtime | +| `Weak` | no | any time | side tables from platform objects to wrappers; `upgrade` gives `None` after collection | +| `Member` | only if its owner reports it | owner's choice | JS values inside a host object's data or the host, reported from `trace` so there is no uncollectable cycle | + +- **Stale is an error, never an alias.** Every reference carries the arena's + generation (7.5, 7.6). Using one that no longer names its object gives + `Error::StaleHandle`. A handle from another runtime gives `Error::WrongRuntime`. +- **When the collector runs:** inside an operation that allocates, or on + `Scope::gc()` (`$262.gc()`), at points the engine chooses. Never between two + of the embedder's own Rust statements, and never while tracing, which is given + no `Scope`. +- **Roots** are the value stack, every live `Local`, every `Handle`, the job + queue, and what the host reports from `Host::trace_roots` (for the browser: + the wrapper of every node in a tree) and each host object's `trace`. +- **Strings** are UTF-16 code unit sequences, as in the language. + `Scope::string` takes Rust text; `string_utf16` takes units, including lone + surrogates, which WebIDL's conversions need. `string_to_utf16` reads exactly, + and `string_to_string_lossy` replaces lone surrogates. + +## Native functions and host objects + +- **`Scope::function(name, length, Callable, f)`** makes a JavaScript function + from a Rust closure `Fn(&mut Scope, &Args) -> Result`. It is `Fn`, not + `FnMut`, because a native function can be re-entered through JavaScript it + calls. State it needs lives in a host object, in the `Host`, or behind a lock. + `Callable::Constructor` makes it usable with `new`, with `Args::new_target` + set, and `get_prototype_from_constructor` gives subclasses their prototype. +- **`HostObject`** is a trait for the Rust data of a JavaScript object. It is + typed (`host_data::` checks, `Error::WrongType` otherwise), is dropped when + the collector frees the object, reports the values it refers to from `trace`, + and may have four exotic hooks (`get_own_property`, `define_own_property`, + `delete_property`, `own_property_keys`) for WebIDL's legacy platform objects. + This is how `clazel-webidl` builds DOM wrappers. + +## `Host` + +One trait for everything ECMA-262 leaves to the host, each with a stated +default, so `DefaultHost` works for a program that needs none. Hooks get +`&mut self` and a `Scope`, may re-enter the engine, and may fail with an +`Error`, which the calling operation passes on. + +| Group | Methods (ECMA-262 name) | Default | +|---|---|---| +| Jobs | `enqueue_promise_job`, `enqueue_generic_job`, `enqueue_timeout_job`, `enqueue_finalization_registry_cleanup_job` | the engine's own queue | +| Job callbacks | `make_job_callback`, `call_job_callback` | a plain callback; call it | +| Modules | `load_imported_module`, `supported_import_attributes`, `get_import_meta_properties`, `finalize_import_meta` | refuse with a `TypeError`; none; none; nothing | +| Promises | `promise_rejection_tracker` | nothing | +| Code from strings | `ensure_can_compile_strings`, `has_source_text_available` | allow; yes | +| Objects | `ensure_can_add_private_element`, `resize_array_buffer` | allow; `Unhandled` | +| The world | `now_ms`, `local_tza`, `random_u64`, `default_locale` | system clock; UTC; (required); `en-US` | +| The collector | `trace_roots` | nothing | + +The browser's answers for the world are its own: 7.0(b)'s fixed offset and +`en-US`, in `clazel-web`. The engine fixes none of them. `random_u64` has no +default because the engine has no entropy source and rule 8 forbids adding a +dependency for one. `DefaultHost` implements it from the standard library. + +**`$262`, built from public calls.** The shell's hooks need nothing private: + +| `$262` | Public call | +|---|---| +| `createRealm()` | `Scope::create_realm`, then `global` | +| `evalScript(src)` | `Scope::eval_script` in the realm | +| `gc()` | `Scope::gc` | +| `detachArrayBuffer(buf)` | `Scope::detach_array_buffer` | +| `agent` | none; see the open questions | + +## Errors and exceptions + +`Result` throughout. One variant is a JavaScript value; the rest are the +engine's and cannot be caught by JavaScript: + +- `Thrown(Exception)`: JavaScript threw. An `Exception` holds the value in a + `Handle`, so it can be reported after the call returned. This includes the + `SyntaxError` for bad source and the `RangeError`s the limits raise. + `Scope::report` turns it into an `ErrorReport` (name, message, stack) without + running user code. +- `Terminated`: a `Terminator` ended the evaluation. +- `OutOfMemory`: the heap limit was hit and not even the `RangeError` could be + allocated. Rare. +- `StaleHandle`, `WrongRuntime`, `WrongType`, `Busy`: misuse of the API, + caught and reported, never undefined behaviour. +- `NotImplemented`: this contract's stubs, until 7.8 builds the bodies. + +A native function returns errors of either kind with `?`. To throw: +`return Err(scope.throw_error(ErrorKind::TypeError, "..."))`, or +`scope.throw(value)` for a value the embedder made (a `DOMException`). + +## Limits and the `Terminator` + +**Limits are the embedder's.** `Limits` has no `Default`, and a struct literal must +name every field, so nothing is fixed in the engine and adding a limit makes +each embedder choose. `Limits::unlimited()` is a named choice for tests. + +| Limit | When passed | +|---|---| +| `heap_bytes` | full collection first, then a `RangeError` | +| `value_stack_bytes` | `RangeError`, "too much recursion" | +| `native_depth` | `RangeError`; counts built-ins that call back into JS | +| `code_bytes` | the JIT stops compiling; not an error | +| `regexp_backtrack_entries` | `RangeError` from the match | +| `nesting_depth` | `SyntaxError` (parser), `RangeError` (`JSON.parse`) | + +Timers and fetches in flight are the host's to bound, not the engine's. + +**`Terminator`** (`Runtime::terminator()`; `Clone`, `Send`, `Sync`) stops a runtime +from another thread. It sets a flag; the interpreter checks it at loop back-edges +and calls, JIT code at the same points, built-ins in their long loops, and native +functions via `Scope::check_terminated`. The evaluation ends with +`Error::Terminated`. JavaScript cannot catch it, and no `finally` runs. The flag +stays set until `Terminator::clear`. The `Terminator` itself is implemented +and tested here, because it is only an atomic flag. The browser keeps 7.0(g)'s +policy (it ends a stuck renderer, on the user's word) and may use this later to +keep the tab. jit.md adds no interaction beyond "JIT code checks the same flag at +the same points". + +**Executable memory** is the embedder's choice (jit.md J.0(b)). `JitMode` gains a +variant that carries a `CodeMapper` when `clazel-jit` exists. Until then it is +interpreter only, which is complete. + +## What the browser's bindings will use + +| Browser need | API | +|---|---| +| Install `window`, `document`, `console` | `create_realm` with a host-object global; `global`; `define_property`, `define_method` | +| Interface objects and prototypes (7.12) | `function` with `Callable::Constructor`; `get_prototype_from_constructor`; `define_property`; `set_prototype_of` | +| Wrappers, one per platform object (7.12, 7.13) | `new_host_object` with typed data; `Weak` for the side table; `Host::trace_roots` for nodes in a tree | +| `NodeList[0]`, `HTMLCollection.name` | `HostObject`'s exotic hooks | +| WebIDL conversions (3.2) | `to_number`, `to_string`, `to_boolean`, `to_object`, `is_callable`, `get_method`, `iterate`, `string_utf16`, `bigint_from_*` | +| `DOMException`, TypeErrors | `throw_error`, `throw` | +| Event listeners calling JS (7.14) | `Handle` or `Member` to the callback; `call`; `report` for uncaught exceptions | +| Promises from `fetch()`, `import()` (7.15, 7.16) | `new_promise`, `resolve_promise`, `reject_promise`, `promise_then`, `promise_state` | +| Script elements (7.15) | `compile_script`, `run_script`, `parse_module`, `load_requested_modules`, `link`, `evaluate_module`, `Host::load_imported_module` | +| Event loop, microtasks, `queueMicrotask` (7.15) | `Runtime::run_jobs`; `Host::enqueue_promise_job`, `make_job_callback`, `call_job_callback`; `clear_kept_objects` after a checkpoint | +| Unhandled rejections | `Host::promise_rejection_tracker` | +| `Date`, `Math.random`, locale | `Host::now_ms`, `local_tza`, `random_u64`, `default_locale` | +| A stuck page (7.0(g)) | `Terminator` | + +## What is deliberately not in the API + +- **A C API** (`clazel-js-capi`): Phase 8, and needs its own decision under rule 1. +- **Stability.** Rust only, unstable, no semver promise until Phase 8 has a second + real user. +- **Node as a drop-in.** A Node-compatible runtime on `clazel-js` is the + realistic path, not V8 API emulation. +- **Threads and shared memory**: `SharedArrayBuffer`, `Atomics`, and so + `$262.agent`; one runtime per thread only (7.0(b), 7.0(e)). +- **`Intl`, Temporal, WebAssembly, a debugger protocol, heap snapshots.** +- **Event loops, timers, `console`, `fetch`, a DOM.** The embedder's. The engine + has none and calls the `Host` instead. +- **Catching panics from native functions.** The lints forbid them here, and an + embedder's panic is its own. +- **Safety against a hostile embedder is not a goal; safety against hostile + JavaScript is.** An embedder that runs untrusted code without the browser's + sandbox relies on the engine's own guarantees: no `unsafe` outside + `clazel-sys`, the arena's generation checks, the validator's theorem for JIT + code, and the limits. + +## Open questions + +Nothing here is a decision the plan marks as the maintainer's. These are what the +plan leaves open and this contract had to settle, or leaves unsettled, so please +look at each. + +1. **After `Terminated`, is the runtime usable?** The proposal: the flag is + sticky, so every call ends `Terminated` until the embedder calls + `Terminator::clear`; after that the heap is consistent and the runtime + usable. It rests on `finally` blocks not running. It makes termination safe + for a runtime that is then dropped, and for the browser, but "usable after" + is a promise to implement and test. +2. **Handle model.** `Local<'s>` scoped to a closure, plus `Handle` (reference + counted, dropped without the runtime) and `Member` (reported from `trace`). + Plan 7.0(f) says "a scoped handle stack, checked on scope exit". The scope + here is a closure with a lifetime the compiler enforces, which is checked + earlier than at exit. The cost is that a value cannot be returned from a + nested scope except as a `Handle`; an `escape` call is possible if that bites. +3. **`Host: Send`.** It keeps `Runtime: Send`. It means the browser's host cannot + hold `Rc`s of DOM state: nodes are arena ids (Phase 4), which should work, + but it is the contract's strictest demand on `clazel-web`. +4. **Exotic hooks.** Four are given; WebIDL §3.9 and §3.10 (legacy platform + objects, named properties) may need `set`/`get` receivers or more. The + set is to be fixed against 7.12's generator, and may grow. +5. **The global's `this` value** (HTML's `WindowProxy`) is not in `RealmOptions`. + ECMA-262 lets a host set it separately from the global object. Needed by + 7.15, and the contract does not yet say how. +6. **Synthetic modules** (`new_synthetic_module`, `set_synthetic_export`) are + reserved in the contract, since "a host can add CommonJS" needs them and + JSON modules do. The plan does not list them as a Phase 7 deliverable. +7. **`$262.agent`.** The plan lists `agent` among the host hooks, and 7.0(b) + leaves out `SharedArrayBuffer` and `Atomics`, which `agent` exists to test. + This API has no agent hook, and the shell skips those tests. If another + host wants agents in Phase 8, a `Runtime` per thread plus shared memory + needs its own design. +8. **Hooks the plan's list lacks.** `HostEnqueueFinalizationRegistryCleanupJob` + (7.6 needs it) and `HostGetSupportedImportAttributes` are in the trait; + the plan's list does not name them. 7.4's check against the pinned edition + decides which stay. +9. **ECMA-262 section numbers** are not cited on the hooks, because 7.1 has not + pinned an edition. They are named by abstract operation instead, which does + not change between editions. Rule 5 asks for sections, so they are added when + 7.1 pins one. Until then the citations are incomplete. +10. **`run_jobs` and a throwing job.** A job that throws stops the run and + returns the exception; later jobs stay queued. A host that wants + "report and continue" overrides the queue hooks and runs jobs itself. + The alternative is one more hook. The plan names none. +11. **`Source` text as `&str`.** Source with a lone surrogate cannot be written. ECMA-262 + source text is code points, and the browser decodes with `clazel-encoding`, + which gives scalar values only, so nothing is lost in practice. Say so if + UTF-16 source is wanted. +12. **Where `CodeMapper` lives.** jit.md names it; this crate cannot depend on a + crate that does not exist. Likely `clazel-jit` defines it and `clazel-js` + re-exports it. +13. **`OutOfMemory` versus `RangeError`.** 7.19 says the heap limit gives a + `RangeError`. This contract keeps `OutOfMemory` for when even that cannot + be allocated. If that case can be avoided by reserving room for one + error object, the variant can go. diff --git a/crates/clazel-js/src/code.rs b/crates/clazel-js/src/code.rs new file mode 100644 index 00000000..1b49058a --- /dev/null +++ b/crates/clazel-js/src/code.rs @@ -0,0 +1,293 @@ +//! Realms, source text, scripts and modules. + +use core::any::Any; +use core::marker::PhantomData; + +use crate::native::HostObject; +use crate::value::Handle; + +/// A realm: a global object and its own copy of every built-in +/// (ECMA-262's Realm Record). +/// +/// - **Why more than one.** `$262.createRealm()` in Test262, and later a +/// frame. A realm's `Array` is not another realm's `Array`, and +/// `instanceof` across them is false, as in a browser. +/// - **Lifetime.** A `Realm` is a root: the realm and everything reachable +/// from its global object live until the last clone is dropped. Like +/// [`Handle`] it is `Send`, `Sync` and `Clone`, and needs a +/// [`Scope`](crate::Scope) to do anything. +/// - **No ambient realm.** Every call that runs code names the realm. Inside a +/// native function, [`Scope::current_realm`](crate::Scope::current_realm) +/// is the realm of the function being called. +/// +/// ```no_run +/// use clazel_js::{Runtime, RealmOptions, Source}; +/// +/// fn two_realms(rt: &mut Runtime) -> clazel_js::Result<()> { +/// let (a, b) = rt.scope(|scope| { +/// Ok((scope.create_realm(RealmOptions::default())?, +/// scope.create_realm(RealmOptions::default())?)) +/// })?; +/// rt.scope(|scope| { +/// let same = scope.eval_script(&a, Source::new("t.js", "[] instanceof Array"))?; +/// assert_eq!(scope.as_boolean(same), Some(true)); +/// // A realm's own object is not an instance of the other realm's Array. +/// let global_b = scope.global(&b)?; +/// let _ = global_b; +/// Ok(()) +/// }) +/// } +/// ``` +#[derive(Clone, Debug)] +pub struct Realm { + root: Handle, +} + +impl Realm { + /// The root that keeps the realm alive. + pub fn as_handle(&self) -> &Handle { + &self.root + } +} + +/// How to build a realm. The default is an ordinary global object with the +/// standard built-ins. +/// +/// ```no_run +/// use clazel_js::{Exotic, HostObject, RealmOptions}; +/// +/// /// The browser's `Window`: a host object serving as the global object. +/// struct Window; +/// impl HostObject for Window {} +/// +/// let options = RealmOptions { +/// global: Some(Box::new(Window)), +/// }; +/// # let _ = options; +/// ``` +#[derive(Default)] +pub struct RealmOptions { + /// Make the global object a host object with this data, whose prototype is + /// the realm's `Object.prototype`. `None` makes an ordinary object. Its + /// exotic hooks answer for the global's own properties. The global's `this` + /// value (HTML's `WindowProxy`) is an open question in the README. + pub global: Option>, +} + +/// Source text to compile, with where it came from. +/// +/// - **Text** is a `&str`: a sequence of Unicode code points, as ECMA-262 +/// defines source text. The browser decodes bytes to text with +/// `clazel-encoding` before calling. +/// - **Name** is what stack traces and error reports show: a URL for a +/// script from the network, `"inline"` or similar for the rest. +/// - **`start_line`** is the 1-based line number of the text's first line, so +/// an inline script in a page reports page line numbers. +/// - **`host_defined`** is the embedder's data about this code (a base URL, +/// fetch options). It is kept with the compiled [`Script`] or [`Module`] and +/// given back by [`Scope::host_defined`](crate::Scope::host_defined) +/// and to the [`Host`](crate::Host) hooks as part of a [`Referrer`]. +/// +/// ```no_run +/// use clazel_js::Source; +/// +/// struct BaseUrl(String); +/// +/// let source = Source::new("https://example.test/app.js", "export default 1;") +/// .with_start_line(1) +/// .with_host_defined(Box::new(BaseUrl("https://example.test/".to_owned()))); +/// assert_eq!(source.name(), "https://example.test/app.js"); +/// ``` +pub struct Source<'a> { + name: &'a str, + text: &'a str, + start_line: u32, + host_defined: Option>, +} + +impl<'a> Source<'a> { + /// Source text with a name, starting at line 1, with no host data. + pub fn new(name: &'a str, text: &'a str) -> Source<'a> { + Source { + name, + text, + start_line: 1, + host_defined: None, + } + } + + /// Sets the line number of the first line. + #[must_use] + pub fn with_start_line(mut self, start_line: u32) -> Source<'a> { + self.start_line = start_line; + self + } + + /// Attaches the embedder's data. + #[must_use] + pub fn with_host_defined(mut self, data: Box) -> Source<'a> { + self.host_defined = Some(data); + self + } + + /// The name. + pub fn name(&self) -> &str { + self.name + } + + /// The text. + pub fn text(&self) -> &str { + self.text + } + + /// The line number of the first line. + pub fn start_line(&self) -> u32 { + self.start_line + } + + /// The embedder's data, if any. + pub fn host_defined(&self) -> Option<&(dyn Any + Send)> { + self.host_defined.as_deref() + } +} + +/// A parsed classic script (ECMA-262's Script Record), not yet run. +/// +/// Parsing and running are separate so a host can follow HTML's "prepare the +/// script element", which fetches and compiles, then runs when the parser +/// or the event loop says. [`Scope::eval_script`](crate::Scope::eval_script) does both at +/// once. A `Script` is a root, `Clone`, `Send` and `Sync`, and may be run +/// more than once; top-level `var`s and functions are created in the realm +/// each time it runs, as for a script run twice. +/// +/// ```no_run +/// use clazel_js::{Realm, Runtime, Script, Source}; +/// +/// fn compile_then_run(rt: &mut Runtime, realm: &Realm) -> clazel_js::Result<()> { +/// let script: Script = rt.scope(|scope| { +/// scope.compile_script(realm, Source::new("later.js", "globalThis.n = 1")) +/// })?; +/// // ... the parser unblocks ... +/// rt.scope(|scope| { +/// scope.run_script(&script)?; +/// Ok(()) +/// }) +/// } +/// ``` +#[derive(Clone, Debug)] +pub struct Script { + root: Handle, +} + +impl Script { + /// The root that keeps the script alive. + pub fn as_handle(&self) -> &Handle { + &self.root + } +} + +/// A module (ECMA-262's Source Text Module Record or a synthetic one). +/// +/// The life of a module follows ECMA-262 §16.2.1.5, which the methods of +/// [`Scope`](crate::Scope) name: parse, load requested modules (the host +/// supplies each import through [`Host::load_imported_module`](crate::Host::load_imported_module)), +/// link, evaluate. `Module` is a root, `Clone`, `Send` and `Sync`. +/// +/// ```no_run +/// use clazel_js::{ModuleStatus, Realm, Runtime, Source}; +/// +/// /// Loads and runs a module whose imports the host can already resolve. +/// fn run_module(rt: &mut Runtime, realm: &Realm, text: &str) -> clazel_js::Result<()> { +/// let module = rt.scope(|scope| scope.parse_module(realm, Source::new("m.js", text)))?; +/// rt.scope(|scope| { +/// let loaded = scope.load_requested_modules(&module)?; +/// let _ = loaded; // a promise: settled when every import has been finished +/// Ok(()) +/// })?; +/// rt.run_jobs()?; +/// rt.scope(|scope| { +/// if scope.module_status(&module)? == ModuleStatus::Unlinked { +/// scope.link(&module)?; +/// } +/// let _done = scope.evaluate_module(&module)?; // a promise, for top-level await +/// Ok(()) +/// }) +/// } +/// ``` +#[derive(Clone, Debug)] +pub struct Module { + root: Handle, +} + +impl Module { + /// The root that keeps the module alive. + pub fn as_handle(&self) -> &Handle { + &self.root + } +} + +/// A module's state (ECMA-262's Cyclic Module Record `[[Status]]`). +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum ModuleStatus { + /// Just created by `parse_module`. + New, + /// Its requested modules are loaded; not yet linked. + Unlinked, + /// `link` is running. + Linking, + /// Linked, not yet evaluated. + Linked, + /// Evaluation is running. + Evaluating, + /// Evaluation is waiting on top-level `await`. + EvaluatingAsync, + /// Evaluation finished, with a value or an error (kept by the module). + Evaluated, +} + +/// One import attribute: `with { type: "json" }` is `("type", "json")`. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ImportAttribute { + /// The attribute's key. + pub key: String, + /// Its value. + pub value: String, +} + +/// What a module asks to import: ECMA-262's ModuleRequest Record. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ModuleRequest { + /// The module specifier, exactly as written in the source. + pub specifier: String, + /// The import attributes, in source order. + pub attributes: Vec, +} + +/// The code that asked for an import: the referrer of +/// [`Host::load_imported_module`](crate::Host::load_imported_module). Its +/// [host data](crate::Scope::host_defined) tells the host where to resolve +/// the specifier against. +#[derive(Clone, Copy, Debug)] +pub enum Referrer<'a> { + /// A classic script (a dynamic `import()` in one). + Script(&'a Script), + /// A module (a static `import` or a dynamic `import()` in one). + Module(&'a Module), + /// Neither: `import()` in `eval` or `Function` code outside any script + /// or module, which has only the realm. + Realm(&'a Realm), +} + +/// The engine's token for one pending import, passed to +/// [`Host::load_imported_module`](crate::Host::load_imported_module) and given +/// back to [`Scope::finish_loading_imported_module`](crate::Scope::finish_loading_imported_module). +/// +/// A host may finish it at once or on a later turn of its event loop, from +/// the same thread as the runtime. It must be finished exactly once; the type +/// is consumed by finishing it. Dropping it without finishing leaves the +/// module graph's load promise pending for ever, which is a bug in the host +/// but not unsafe. +#[derive(Debug)] +pub struct LoadPayload { + _pending: PhantomData<()>, +} diff --git a/crates/clazel-js/src/error.rs b/crates/clazel-js/src/error.rs new file mode 100644 index 00000000..35c25fef --- /dev/null +++ b/crates/clazel-js/src/error.rs @@ -0,0 +1,193 @@ +//! Errors and exceptions. + +use core::fmt; + +use crate::value::Handle; + +/// What every fallible call in this crate returns. +pub type Result = core::result::Result; + +/// The kinds of error object the engine can create (ECMA-262's native error +/// types). +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum ErrorKind { + /// `Error`. + Error, + /// `EvalError`. + EvalError, + /// `RangeError`. + RangeError, + /// `ReferenceError`. + ReferenceError, + /// `SyntaxError`. + SyntaxError, + /// `TypeError`. + TypeError, + /// `URIError`. + UriError, +} + +/// A value JavaScript threw, held by a rooted [`Handle`]. +/// +/// An `Exception` is what `catch` would see. It stays alive for as long as it +/// is held, whichever scope it was thrown in, so an embedder can report it +/// after the call that threw it has returned. +/// +/// ```no_run +/// use clazel_js::{Error, Realm, Scope, Source}; +/// +/// fn report(scope: &mut Scope<'_>, realm: &Realm) -> clazel_js::Result<()> { +/// match scope.eval_script(realm, Source::new("page.js", "null.x")) { +/// Err(Error::Thrown(exception)) => { +/// let report = scope.report(&exception)?; +/// println!("{}: {}", report.name, report.message); +/// Ok(()) +/// } +/// other => other.map(|_| ()), +/// } +/// } +/// ``` +#[derive(Clone, Debug)] +pub struct Exception { + value: Handle, +} + +impl Exception { + /// Wraps a value to be reported as thrown, for example to refuse a module + /// load in [`Scope::finish_loading_imported_module`](crate::Scope::finish_loading_imported_module). + /// The engine builds the ones it returns in [`Error::Thrown`]. + pub fn from_handle(value: Handle) -> Exception { + Exception { value } + } + + /// The thrown value, as a rooted handle. Turn it back into a + /// [`Local`](crate::Local) with [`Scope::local`](crate::Scope::local). + pub fn value(&self) -> &Handle { + &self.value + } +} + +/// A thrown error described in plain Rust types, for logging and for the +/// browser's "report the exception" step (which is HTML's, not the engine's; +/// the engine only supplies these fields). +/// +/// Built by [`Scope::report`](crate::Scope::report). It never runs user code: +/// a getter that throws while the report is built leaves that field empty. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct ErrorReport { + /// `name` of the thrown object, or `"Error"` if it has none. For a thrown + /// non-object, the type of the value, such as `"string"`. + pub name: String, + /// `message` of the thrown object, or the string conversion of a thrown + /// primitive. + pub message: String, + /// The call stack when the error object was created, innermost first. + /// Empty if the thrown value is not an error object. + pub stack: Vec, +} + +/// One frame of a call stack. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct StackFrame { + /// The function's name, or `None` for top-level code and anonymous + /// functions. + pub function: Option, + /// The `name` of the [`Source`](crate::Source) the frame's code came from. + pub source: String, + /// 1-based line, counting from the source's `start_line`. + pub line: u32, + /// 1-based column, in UTF-16 code units. + pub column: u32, +} + +/// Why a call failed. +/// +/// Exactly one variant, [`Thrown`](Error::Thrown), is a JavaScript value. +/// Every other variant is the engine's or the embedder's, and JavaScript +/// cannot observe or catch it. A native function passes both kinds back with +/// `?`. +/// +/// ```no_run +/// use clazel_js::{Error, Realm, Scope, Source}; +/// +/// fn run(scope: &mut Scope<'_>, realm: &Realm) { +/// match scope.eval_script(realm, Source::new("a.js", "while (true) {}")) { +/// Ok(_) => {} +/// Err(Error::Thrown(_)) => { /* the script threw; `catch` could have caught it */ } +/// Err(Error::Terminated) => { /* a Terminator stopped it; nothing in JS ran after */ } +/// Err(other) => eprintln!("engine error: {other}"), +/// } +/// } +/// ``` +#[derive(Clone, Debug)] +#[non_exhaustive] +pub enum Error { + /// JavaScript threw this value. Includes the `SyntaxError` for source + /// that does not parse, and the `RangeError`s the limits report + /// (heap, value stack, nested native calls, nesting depth, RegExp + /// backtracking). All of them can be caught by JavaScript. + Thrown(Exception), + /// A [`Terminator`](crate::Terminator) ended the evaluation. JavaScript + /// cannot catch it, and no `finally` block runs while it propagates. + Terminated, + /// The heap limit was reached and the engine could not even allocate the + /// `RangeError` to report it. This is the rare case; the ordinary report + /// of the heap limit is [`Thrown`](Error::Thrown). + OutOfMemory, + /// The handle names something that no longer exists, so using it would + /// have aliased a different object. The generation check caught it. + StaleHandle, + /// The handle, realm, script or module belongs to another + /// [`Runtime`](crate::Runtime). + WrongRuntime, + /// The value was not of the type the call needs. The text names what was + /// wanted, for example `"host object of this type"`. + WrongType(&'static str), + /// The data being asked for is already borrowed by a call further up the + /// stack (a host object's data while one of its own hooks runs). + Busy, + /// The contract is written but the body is not. The text names the call. + /// This variant exists only until item 7.8 builds the implementation. + NotImplemented(&'static str), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Error::Thrown(_) => f.write_str("JavaScript threw a value"), + Error::Terminated => f.write_str("terminated"), + Error::OutOfMemory => f.write_str("out of memory"), + Error::StaleHandle => f.write_str("stale handle"), + Error::WrongRuntime => f.write_str("handle from another runtime"), + Error::WrongType(what) => write!(f, "wrong type: wanted {what}"), + Error::Busy => f.write_str("already borrowed further up the stack"), + Error::NotImplemented(what) => write!(f, "not implemented: {what}"), + } + } +} + +impl std::error::Error for Error {} + +/// The body of every call whose implementation is still to come: names the +/// call, uses its arguments so the contract's parameter names stay as written, +/// and returns [`Error::NotImplemented`]. +macro_rules! not_implemented { + ($what:expr $(, $arg:expr)* $(,)?) => {{ + let _ = ($(&$arg,)*); + ::core::result::Result::Err($crate::Error::NotImplemented($what)) + }}; +} +pub(crate) use not_implemented; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn display_names_the_unimplemented_call() { + assert_eq!( + Error::NotImplemented("Runtime::new").to_string(), + "not implemented: Runtime::new" + ); + } +} diff --git a/crates/clazel-js/src/host.rs b/crates/clazel-js/src/host.rs new file mode 100644 index 00000000..6d433578 --- /dev/null +++ b/crates/clazel-js/src/host.rs @@ -0,0 +1,477 @@ +//! The [`Host`] trait: everything ECMA-262 leaves to the host, and what the +//! engine needs from the world. +//! +//! The ECMA-262 section of each hook is not cited yet. Rule 5 asks for the +//! exact section, and the edition they refer to is pinned in item 7.1, which +//! has not run. Each hook is named by the abstract operation's name, which +//! does not change between editions; section numbers join when 7.1 pins one, +//! and 7.4 checks this list against the pinned edition's list of host hooks. + +use core::any::Any; +use std::hash::{BuildHasher, RandomState}; +use std::time::{SystemTime, UNIX_EPOCH}; + +use crate::code::{LoadPayload, Module, ModuleRequest, Realm, Referrer}; +use crate::error::{ErrorKind, Result, not_implemented}; +use crate::native::Tracer; +use crate::scope::Scope; +use crate::value::{Handle, Local}; + +/// A queued unit of work for the event loop: a promise reaction, a +/// `FinalizationRegistry` cleanup, or a generic job. +/// +/// The engine makes a `Job` and gives it to the host to queue. Running it is +/// [`Scope::run_job`](crate::Scope::run_job), once, on the runtime's thread. A +/// `Job` is a root, so dropping one without running it only loses the work. +/// It is `Send` and `Sync` like a [`Handle`]. +#[derive(Debug)] +pub struct Job { + root: Handle, + realm: Option, +} + +impl Job { + /// The realm the job runs in, if the operation that made it names one. + pub fn realm(&self) -> Option<&Realm> { + self.realm.as_ref() + } + + /// The root that keeps the job's closure alive. + pub fn as_handle(&self) -> &Handle { + &self.root + } +} + +/// A callback and the host's data about it: ECMA-262's JobCallback Record. +/// +/// [`Host::make_job_callback`] makes one when a promise reaction or a +/// `FinalizationRegistry` is created, and [`Host::call_job_callback`] calls it +/// later. HTML uses the data to remember the "incumbent settings object". +#[derive(Debug)] +pub struct JobCallback { + callback: Handle, + host_defined: Option>, +} + +impl JobCallback { + /// A job callback with no host data. + pub fn new(callback: Handle) -> JobCallback { + JobCallback { + callback, + host_defined: None, + } + } + + /// Attaches the host's data. + #[must_use] + pub fn with_host_defined(mut self, data: Box) -> JobCallback { + self.host_defined = Some(data); + self + } + + /// The callback function. + pub fn callback(&self) -> &Handle { + &self.callback + } + + /// The host's data, if any. + pub fn host_defined(&self) -> Option<&(dyn Any + Send)> { + self.host_defined.as_deref() + } +} + +/// What [`Host::promise_rejection_tracker`] is told happened. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum RejectionOperation { + /// A promise with no handler was rejected. + Reject, + /// A handler was added to an already-rejected promise that had none. + Handle, +} + +/// Which dynamic code-from-strings feature is asking +/// [`Host::ensure_can_compile_strings`]. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum DynamicCodeKind { + /// `eval(...)`; `direct` is true for a direct call that sees local scope. + Eval { + /// Whether this was a direct `eval`. + direct: bool, + }, + /// `Function(...)`. + Function, + /// `GeneratorFunction(...)`. + GeneratorFunction, + /// `AsyncFunction(...)`. + AsyncFunction, + /// `AsyncGeneratorFunction(...)`. + AsyncGeneratorFunction, +} + +/// The strings handed to [`Host::ensure_can_compile_strings`]. They are +/// UTF-16 because the program can build them with lone surrogates. +#[derive(Clone, Copy, Debug)] +pub struct CompileStrings<'a> { + /// Which feature is compiling code. + pub kind: DynamicCodeKind, + /// The parameter strings (empty for `eval`). + pub parameters: &'a [Vec], + /// The body, or for `eval` the code. + pub body: &'a [u16], +} + +/// The answer of [`Host::resize_array_buffer`]. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Resize { + /// The host did the resize. + Handled, + /// The host left it to the engine's default, which allocates. + Unhandled, +} + +/// What the embedder supplies. Every method has a default so a program that +/// needs none of the hooks can use [`DefaultHost`], and an embedder +/// overrides what it needs. +/// +/// - **Reentrancy.** A hook gets `&mut self` and a [`Scope`] and may call +/// back into the engine through that scope, including evaluating code. +/// While a hook runs, the host is lent to it, so [`Scope::host_mut`] from +/// code the hook runs gives [`Error::Busy`](crate::Error::Busy). +/// - **Errors.** A hook that returns `Err` makes the operation that called it +/// fail with that error, as ECMA-262 says for an abrupt completion from a +/// host-defined operation. `Err(Error::Terminated)` is passed on as is. +/// - **Threads.** `Host: Send`, which keeps [`Runtime`](crate::Runtime) +/// `Send`. A host that needs a value that is not `Send` keeps an id or a +/// channel in the host and the value elsewhere. +/// - **The event loop is the host's.** Nothing here runs a job: the hooks +/// queue, and the embedder calls [`Runtime::run_jobs`](crate::Runtime::run_jobs) +/// when its loop says to. +/// +/// The defaults named in each method are the engine's behaviour for a host +/// that says nothing. The browser's answers (HTML's, and 7.0(b)'s fixed +/// time zone offset and `en-US`) are the browser's, in `clazel-web`. +/// +/// ```no_run +/// use clazel_js::{ +/// Host, Job, Local, Module, ModuleRequest, LoadPayload, Referrer, RejectionOperation, +/// Result, Scope, +/// }; +/// +/// /// A host with a task queue of its own, rejection reporting, and a fixed clock. +/// struct PageHost { +/// tasks: Vec, +/// unhandled: Vec, +/// } +/// +/// impl Host for PageHost { +/// fn enqueue_promise_job(&mut self, _scope: &mut Scope<'_>, job: Job) -> Result<()> { +/// self.tasks.push(job); +/// Ok(()) +/// } +/// +/// fn promise_rejection_tracker( +/// &mut self, +/// _scope: &mut Scope<'_>, +/// _promise: Local<'_>, +/// operation: RejectionOperation, +/// ) { +/// self.unhandled.push(format!("{operation:?}")); +/// } +/// +/// fn now_ms(&mut self) -> f64 { +/// 1_700_000_000_000.0 +/// } +/// +/// fn random_u64(&mut self) -> u64 { +/// 4 // chosen by fair dice roll +/// } +/// } +/// ``` +pub trait Host: Any + Send { + // ---- Jobs ----------------------------------------------------------- + + /// `HostEnqueuePromiseJob(job, realm)`: queue a promise reaction. + /// + /// Default: append it to the engine's own queue, which + /// [`Runtime::run_jobs`](crate::Runtime::run_jobs) drains in order. A host + /// that overrides this takes over the order and calls + /// [`Scope::run_job`] itself. + fn enqueue_promise_job(&mut self, scope: &mut Scope<'_>, job: Job) -> Result<()> { + scope.enqueue_job_internal(job) + } + + /// `HostEnqueueGenericJob(job, realm)`. Default: as for promise jobs. + fn enqueue_generic_job(&mut self, scope: &mut Scope<'_>, job: Job) -> Result<()> { + scope.enqueue_job_internal(job) + } + + /// `HostEnqueueTimeoutJob(job, realm, milliseconds)`: run `job` after at + /// least `delay_ms`. Only a feature with timers in the language uses it + /// (`Atomics.waitAsync`, which the browser does not ship), so no + /// embedder is required to override it. Default: the engine's own queue, + /// with the delay ignored. + fn enqueue_timeout_job( + &mut self, + scope: &mut Scope<'_>, + job: Job, + delay_ms: f64, + ) -> Result<()> { + let _ = delay_ms; + scope.enqueue_job_internal(job) + } + + /// `HostEnqueueFinalizationRegistryCleanupJob(finalizationRegistry)`: a + /// registry has cells to clean up. The phase plan's list of hooks does not + /// name this one and 7.6 needs it (finalization callbacks are queued as + /// tasks); it is listed under the README's open questions. Default: the + /// engine's own queue. + fn enqueue_finalization_registry_cleanup_job( + &mut self, + scope: &mut Scope<'_>, + job: Job, + ) -> Result<()> { + scope.enqueue_job_internal(job) + } + + /// `HostMakeJobCallback(callback)`. Default: a [`JobCallback`] holding the + /// function and no host data. + fn make_job_callback( + &mut self, + scope: &mut Scope<'_>, + callback: Local<'_>, + ) -> Result { + Ok(JobCallback::new(scope.persist(callback))) + } + + /// `HostCallJobCallback(jobCallback, V, argumentsList)`. Default: call the + /// function with `this` and the arguments. + fn call_job_callback<'s>( + &mut self, + scope: &mut Scope<'s>, + callback: &JobCallback, + this: Local<'_>, + arguments: &[Local<'_>], + ) -> Result> { + let function = scope.local(callback.callback())?; + scope.call(function, this, arguments) + } + + // ---- Modules -------------------------------------------------------- + + /// `HostLoadImportedModule(referrer, moduleRequest, hostDefined, payload)`: + /// find (and fetch, if need be) the module `request` names, then call + /// [`Scope::finish_loading_imported_module`] with it or with the error. + /// It may do so before returning or on a later turn. + /// + /// ECMA-262 requires the same `(referrer, request)` to give the same module + /// every time or fail every time; keeping that is the host's job. + /// + /// Default: finish with a `TypeError` saying this host loads no modules. + fn load_imported_module( + &mut self, + scope: &mut Scope<'_>, + referrer: Referrer<'_>, + request: &ModuleRequest, + payload: LoadPayload, + ) -> Result<()> { + let _ = (referrer, request); + let error = scope.new_exception(ErrorKind::TypeError, "this host does not load modules")?; + scope.finish_loading_imported_module(payload, Err(error)) + } + + /// `HostGetSupportedImportAttributes()`: the attribute keys this host + /// understands (for example `"type"`). The engine refuses an import with + /// any other key with a `SyntaxError`. Default: none. Whether the pinned + /// edition has this hook is checked in 7.4. + fn supported_import_attributes(&self) -> &[&'static str] { + &[] + } + + /// `HostGetImportMetaProperties(moduleRecord)`: the properties of + /// `import.meta` for `module`, as (key, value) pairs. Default: none. + fn get_import_meta_properties<'s>( + &mut self, + scope: &mut Scope<'s>, + module: &Module, + ) -> Result)>> { + let _ = (scope, module); + Ok(Vec::new()) + } + + /// `HostFinalizeImportMeta(importMeta, moduleRecord)`: last chance to change + /// the `import.meta` object. Default: nothing. + fn finalize_import_meta( + &mut self, + scope: &mut Scope<'_>, + import_meta: Local<'_>, + module: &Module, + ) -> Result<()> { + let _ = (scope, import_meta, module); + Ok(()) + } + + // ---- Promises, code from strings, and the like ------------------------ + + /// `HostPromiseRejectionTracker(promise, operation)`: a promise was + /// rejected with no handler, or got its first handler after that. It + /// cannot fail or throw; the host records what it needs. Default: nothing. + fn promise_rejection_tracker( + &mut self, + scope: &mut Scope<'_>, + promise: Local<'_>, + operation: RejectionOperation, + ) { + let _ = (scope, promise, operation); + } + + /// `HostEnsureCanCompileStrings(calleeRealm, ...)`: may `eval` and the + /// `Function` constructors compile this text in `callee`? `Err` refuses, + /// and the error is what the call throws. Default: yes. + fn ensure_can_compile_strings( + &mut self, + scope: &mut Scope<'_>, + callee: &Realm, + strings: &CompileStrings<'_>, + ) -> Result<()> { + let _ = (scope, callee, strings); + Ok(()) + } + + /// `HostHasSourceTextAvailable(func)`: may `Function.prototype.toString` + /// show the source of `function`? Default: yes. + fn has_source_text_available(&mut self, scope: &mut Scope<'_>, function: Local<'_>) -> bool { + let _ = (scope, function); + true + } + + /// `HostEnsureCanAddPrivateElement(O)`: may a private element be added to + /// `object`? `Err` refuses. Default: yes. + fn ensure_can_add_private_element( + &mut self, + scope: &mut Scope<'_>, + object: Local<'_>, + ) -> Result<()> { + let _ = (scope, object); + Ok(()) + } + + /// `HostResizeArrayBuffer(buffer, newByteLength)`. Default: + /// [`Resize::Unhandled`]. + fn resize_array_buffer( + &mut self, + scope: &mut Scope<'_>, + buffer: Local<'_>, + new_byte_length: u64, + ) -> Result { + let _ = (scope, buffer, new_byte_length); + Ok(Resize::Unhandled) + } + + // ---- What the engine needs from the world ----------------------------- + + /// The current time in milliseconds since the Unix epoch, for + /// `Date.now()` and `new Date()`. Default: the system clock. + fn now_ms(&mut self) -> f64 { + match SystemTime::now().duration_since(UNIX_EPOCH) { + Ok(d) => d.as_secs_f64() * 1000.0, + Err(_) => 0.0, + } + } + + /// The local time zone's offset from UTC in milliseconds at `time_ms` + /// (ECMA-262's `LocalTZA`). `is_utc` says whether `time_ms` is a UTC time + /// or a local one to convert back. Default: 0, that is, UTC. + fn local_tza(&mut self, time_ms: f64, is_utc: bool) -> f64 { + let _ = (time_ms, is_utc); + 0.0 + } + + /// Random bits for `Math.random`. Required, because the engine has no + /// source of its own (rule 8: no randomness dependency). It need not be + /// cryptographic. [`DefaultHost`] draws from the standard library's + /// per-process random hash keys. + fn random_u64(&mut self) -> u64; + + /// The default locale, as a BCP 47 tag, for `toLocaleString` and friends. + /// Default: `"en-US"`. + fn default_locale(&self) -> &str { + "en-US" + } + + // ---- The collector ------------------------------------------------------ + + /// Reports the JavaScript values the host keeps alive: for the browser, + /// the wrapper of every node in a document's tree, the task queues and the + /// timers. Called during every collection. See [`Tracer`]. Default: + /// nothing. + fn trace_roots(&mut self, tracer: &mut Tracer<'_>) { + let _ = tracer; + } +} + +/// A host that says nothing: every hook has its default, and the clock and +/// randomness come from the standard library. +/// +/// Test262's runner, small tools and the examples use it. A real embedder +/// supplies its own. +/// +/// ```no_run +/// use clazel_js::{Config, DefaultHost, Limits, Runtime}; +/// +/// fn main() -> Result<(), clazel_js::Error> { +/// let _rt = Runtime::new(Config::new(Limits::unlimited()), DefaultHost::new())?; +/// Ok(()) +/// } +/// ``` +#[derive(Debug, Default)] +pub struct DefaultHost { + draws: u64, +} + +impl DefaultHost { + /// A default host. + pub fn new() -> DefaultHost { + DefaultHost { draws: 0 } + } +} + +impl Host for DefaultHost { + fn random_u64(&mut self) -> u64 { + // A fresh `RandomState` has per-process random keys; hashing a counter + // gives different bits each call. Good enough for `Math.random`, which + // ECMA-262 does not require to be unpredictable. + self.draws = self.draws.wrapping_add(1); + RandomState::new().hash_one(self.draws) + } +} + +// The engine's own queue is reached through this one call, which the default +// hooks use and an embedder that forwards to it may too. +impl Scope<'_> { + /// Appends `job` to the engine's own job queue, the one + /// [`Runtime::run_jobs`](crate::Runtime::run_jobs) drains. What the default + /// `enqueue_*` hooks do, and what an overriding host may call to forward. + pub fn enqueue_job_internal(&mut self, job: Job) -> Result<()> { + not_implemented!("Scope::enqueue_job_internal", job) + } + + /// Runs a job to completion. A job that throws returns the exception. + pub fn run_job(&mut self, job: Job) -> Result<()> { + not_implemented!("Scope::run_job", job) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn default_host_answers_for_the_world() { + let mut host = DefaultHost::new(); + assert_eq!(host.local_tza(0.0, true), 0.0); + assert_eq!(host.default_locale(), "en-US"); + assert!(host.now_ms() > 1.5e12); + assert_ne!(host.random_u64(), host.random_u64()); + assert!(host.supported_import_attributes().is_empty()); + } +} diff --git a/crates/clazel-js/src/lib.rs b/crates/clazel-js/src/lib.rs new file mode 100644 index 00000000..5a664c8d --- /dev/null +++ b/crates/clazel-js/src/lib.rs @@ -0,0 +1,46 @@ +//! The JavaScript engine's embedding API (phase-7.md item 7.8, "The engine as +//! a library"). +//! +//! **This crate is the contract and nothing else.** Every type and signature +//! is the proposed API, and every operation that needs the engine returns +//! [`Error::NotImplemented`]. The README states the rules in prose (threads, +//! rooting, termination, what is left out) and lists the open questions; the +//! doc comments here carry examples that compile (`no_run`, since nothing +//! runs yet). The contract is for review before the bindings build on it. +//! +//! The pieces, in the order a program meets them: +//! +//! - [`Runtime`], [`Config`], [`Limits`] and [`Terminator`]: one agent, its +//! limits, and the handle that stops it from another thread. +//! - [`Scope`]: every operation, inside [`Runtime::scope`]. Its values are +//! [`Local`]s; [`Handle`], [`Weak`] and [`Member`] hold them longer. +//! - [`Realm`], [`Source`], [`Script`] and [`Module`]: code to run. +//! - [`Scope::function`], [`Args`] and [`HostObject`]: Rust inside JavaScript. +//! - [`Host`]: what ECMA-262 leaves to the embedder, and [`DefaultHost`]. +//! - [`Error`], [`Exception`] and [`ErrorReport`]: what goes wrong. +//! +//! An embedder names this crate and no other engine crate. + +mod code; +mod error; +mod host; +mod native; +mod runtime; +mod scope; +mod value; + +pub use code::{ + ImportAttribute, LoadPayload, Module, ModuleRequest, ModuleStatus, Realm, RealmOptions, + Referrer, Script, Source, +}; +pub use error::{Error, ErrorKind, ErrorReport, Exception, Result, StackFrame}; +pub use host::{ + CompileStrings, DefaultHost, DynamicCodeKind, Host, Job, JobCallback, RejectionOperation, + Resize, +}; +pub use native::{Args, Callable, Exotic, HostObject, NativeFn, Tracer}; +pub use runtime::{Config, JitMode, Limits, Runtime, Terminator}; +pub use scope::{Resolvers, Scope}; +pub use value::{ + Handle, Key, Local, Member, PromiseState, PropertyDescriptor, ValueKind, Weak, WellKnownSymbol, +}; diff --git a/crates/clazel-js/src/native.rs b/crates/clazel-js/src/native.rs new file mode 100644 index 00000000..f18f0553 --- /dev/null +++ b/crates/clazel-js/src/native.rs @@ -0,0 +1,237 @@ +//! Native functions and host objects: how Rust code becomes part of a +//! JavaScript program. + +use core::any::Any; +use core::marker::PhantomData; + +use crate::error::Result; +use crate::scope::Scope; +use crate::value::{Key, Local, Member, PropertyDescriptor}; + +/// What a native function is called with. +/// +/// `this` and the arguments are [`Local`]s of the call's own scope, so the +/// function can use them freely and cannot keep them. A missing argument is +/// `undefined`, as for any JavaScript function. +/// +/// ```no_run +/// use clazel_js::{Args, Local, Result, Scope}; +/// +/// /// `add(a, b)` as JavaScript sees it. +/// fn add<'s>(scope: &mut Scope<'s>, args: &Args<'s>) -> Result> { +/// let a = scope.to_number(args.get(0))?; +/// let b = scope.to_number(args.get(1))?; +/// Ok(scope.number(a + b)) +/// } +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Args<'s> { + _scope: PhantomData<&'s ()>, +} + +impl<'s> Args<'s> { + /// The `this` value. + pub fn this(&self) -> Local<'s> { + // Implementation arrives with the frame layout (item 7.8). + Local::placeholder() + } + + /// How many arguments the caller passed. + pub fn len(&self) -> usize { + 0 + } + + /// Whether the caller passed no arguments. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Argument `index`, or `undefined` if the caller passed fewer. + pub fn get(&self, index: usize) -> Local<'s> { + let _ = index; + Local::placeholder() + } + + /// `new.target`: `Some` when the function was called with `new` (or by + /// `Reflect.construct`), and the constructor `new` was applied to, which + /// may be a subclass. `None` for an ordinary call. + pub fn new_target(&self) -> Option> { + None + } +} + +/// Whether a native function can be used with `new`. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub enum Callable { + /// An ordinary function: `new` throws a `TypeError`, and + /// [`Args::new_target`] is always `None`. What WebIDL calls an operation. + #[default] + Function, + /// A constructor: `new` calls it with [`Args::new_target`] set. A call + /// without `new` is the function's own business; it can throw. What + /// WebIDL calls an interface object. + Constructor, +} + +/// A request to run a native function body on behalf of the engine. Boxed +/// closures of this shape are what [`Scope::function`] takes. +/// +/// `Fn`, not `FnMut`: a native function can be re-entered through JavaScript +/// it calls, so mutable state it needs goes in a host object, in the +/// [`Host`](crate::Host), or behind a lock, and not in the closure. `Send` +/// because the [`Runtime`](crate::Runtime) is. +pub type NativeFn = dyn for<'s> Fn(&mut Scope<'s>, &Args<'s>) -> Result> + Send; + +/// An answer from an exotic hook: do what an ordinary object does, or here is +/// the answer. +#[derive(Clone, Copy, Debug)] +pub enum Exotic { + /// No special behaviour for this key: the engine continues as for an + /// ordinary object (looking at the object's own properties, then its + /// prototype). + Ordinary, + /// The embedder's answer. + Handled(T), +} + +/// The data of a host object, and the object's special behaviour. +/// +/// A host object is a JavaScript object that carries a Rust value, which the +/// embedder owns. This is how `clazel-webidl` builds a wrapper for a DOM +/// node: the wrapper is a JavaScript object, and its data says which node. +/// +/// - **Typed.** The data's type is the slot's type. [`Scope::host_data`] and +/// [`Scope::host_data_mut`] check it and give +/// [`Error::WrongType`](crate::Error::WrongType) for any other object, so a +/// method called on the wrong `this` is a defined error and never a +/// reinterpreted pointer. +/// - **Lifetime.** The data is dropped, on the runtime's thread, when the +/// collector frees the object or the runtime is dropped. +/// - **Tracing.** If the data refers to other JavaScript values it reports +/// them from [`trace`](HostObject::trace), using [`Member`]. The default +/// reports nothing. +/// - **Exotic behaviour.** The four hooks let a host object be what WebIDL +/// calls a legacy platform object: `NodeList[0]`, `HTMLCollection.byName`, +/// `localStorage.key`. Each defaults to [`Exotic::Ordinary`], and the +/// engine checks the result against ECMA-262's invariants for the internal +/// method (a non-configurable property cannot be reported missing, and so +/// on), throwing `TypeError` if the hook breaks them. While a hook runs the +/// object's data is lent to it and taken out of the object, so another +/// access to the same data gets [`Error::Busy`](crate::Error::Busy). +/// - **Which hooks exist** is an open question in the README: these four are +/// what WebIDL §3.9 and §3.10 appear to need and the list may grow. +/// +/// ```no_run +/// use clazel_js::{Exotic, HostObject, Key, Local, PropertyDescriptor, Result, Runtime, Scope}; +/// +/// /// The data of a `NodeList` wrapper: the ids of the nodes it holds. +/// struct NodeList { +/// nodes: Vec, +/// } +/// +/// impl HostObject for NodeList { +/// fn get_own_property<'s>( +/// &mut self, +/// scope: &mut Scope<'s>, +/// _this: Local<'s>, +/// key: Key<'_, 's>, +/// ) -> Result>>> { +/// let Key::Index(i) = key else { return Ok(Exotic::Ordinary) }; +/// let Some(id) = self.nodes.get(i as usize) else { +/// return Ok(Exotic::Handled(None)); +/// }; +/// let wrapper = scope.number(*id as f64); // a real binding makes the node's wrapper +/// Ok(Exotic::Handled(Some(PropertyDescriptor { +/// value: Some(wrapper), +/// writable: Some(false), +/// enumerable: Some(true), +/// configurable: Some(true), +/// ..PropertyDescriptor::default() +/// }))) +/// } +/// } +/// +/// fn make(rt: &mut Runtime) -> clazel_js::Result<()> { +/// rt.scope(|scope| { +/// let list = scope.new_host_object(None, NodeList { nodes: vec![1, 2] })?; +/// let n = scope.host_data::(list)?.nodes.len(); +/// assert_eq!(n, 2); +/// Ok(()) +/// }) +/// } +/// ``` +pub trait HostObject: Any + Send { + /// Reports every [`Member`] this data holds. See [`Tracer`]. + fn trace(&self, tracer: &mut Tracer<'_>) { + let _ = tracer; + } + + /// `[[GetOwnProperty]]` for `key`. + fn get_own_property<'s>( + &mut self, + scope: &mut Scope<'s>, + this: Local<'s>, + key: Key<'_, 's>, + ) -> Result>>> { + let _ = (scope, this, key); + Ok(Exotic::Ordinary) + } + + /// `[[DefineOwnProperty]]` for `key`. `Handled(true)` means it succeeded + /// and `Handled(false)` that it was refused. + fn define_own_property<'s>( + &mut self, + scope: &mut Scope<'s>, + this: Local<'s>, + key: Key<'_, 's>, + descriptor: PropertyDescriptor<'s>, + ) -> Result> { + let _ = (scope, this, key, descriptor); + Ok(Exotic::Ordinary) + } + + /// `[[Delete]]` for `key`. + fn delete_property<'s>( + &mut self, + scope: &mut Scope<'s>, + this: Local<'s>, + key: Key<'_, 's>, + ) -> Result> { + let _ = (scope, this, key); + Ok(Exotic::Ordinary) + } + + /// The extra own keys `[[OwnPropertyKeys]]` should list, which the + /// engine puts in front of the object's ordinary keys in the order + /// ECMA-262 fixes (indices first). `Handled` keys that are not strings, + /// symbols or indices are a `TypeError`. + fn own_property_keys<'s>( + &mut self, + scope: &mut Scope<'s>, + this: Local<'s>, + ) -> Result>>> { + let _ = (scope, this); + Ok(Exotic::Ordinary) + } +} + +/// The collector's marker, handed to [`HostObject::trace`] and +/// [`Host::trace_roots`](crate::Host::trace_roots). +/// +/// During a collection the engine calls each live host object's `trace`, and +/// the host's `trace_roots` once. Everything reported is treated as reachable +/// from there. Collection runs only at points the engine chooses (phase-7.md +/// item 7.6), and tracing cannot run JavaScript or allocate: the type gives it +/// no [`Scope`]. +#[derive(Debug)] +pub struct Tracer<'a> { + _collector: PhantomData<&'a mut ()>, +} + +impl Tracer<'_> { + /// Reports that the value is reachable. Reporting one twice is fine, and + /// reporting a stale one is ignored (the generation check). + pub fn mark(&mut self, member: Member) { + let _ = member; + } +} diff --git a/crates/clazel-js/src/runtime.rs b/crates/clazel-js/src/runtime.rs new file mode 100644 index 00000000..82804818 --- /dev/null +++ b/crates/clazel-js/src/runtime.rs @@ -0,0 +1,330 @@ +//! [`Runtime`], its [`Config`] and [`Limits`], and the [`Terminator`]. + +use core::cell::Cell; +use core::marker::PhantomData; +use std::sync::Arc; +use std::sync::atomic::{AtomicBool, Ordering}; + +use crate::error::{Result, not_implemented}; +use crate::host::Host; +use crate::scope::Scope; + +/// Every limit is the embedder's to set, and the engine has no default for +/// any of them (phase-7.md, "Limits and stopping"). +/// +/// A struct literal must name every field, so adding a limit later makes +/// every embedder choose a value. The numbers the browser picks are not in +/// this crate. Each limit has its own report, listed with the field. +/// +/// ```no_run +/// use clazel_js::Limits; +/// +/// // A test harness with limits generous enough never to matter, and one +/// // that is not: a small heap that is meant to be hit. +/// let relaxed = Limits::unlimited(); +/// let strict = Limits { +/// heap_bytes: 64 << 20, +/// ..relaxed +/// }; +/// # let _ = strict; +/// ``` +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct Limits { + /// Heap size in bytes. An allocation that would pass it first runs a full + /// collection, then throws a `RangeError` if it still would. + pub heap_bytes: u64, + /// Size of the value-stack region in bytes. Passing it throws a + /// `RangeError` ("too much recursion"). + pub value_stack_bytes: u64, + /// How many native functions may be on the call stack at once, counting + /// built-ins that call back into JavaScript such as `Array.prototype.map`. + /// Passing it throws a `RangeError`. + pub native_depth: u32, + /// Bytes of generated machine code the JIT may hold. Passing it stops + /// compiling and leaves functions to the interpreter; it is not an error. + /// Ignored when [`JitMode::Off`]. + pub code_bytes: u64, + /// Entries in the RegExp matcher's backtrack stack. Passing it throws a + /// `RangeError` from the match, rather than hanging on `(a+)+b`. + pub regexp_backtrack_entries: u64, + /// Nesting depth of the parser (source text) and of `JSON.parse`. Passing + /// it throws a `SyntaxError` for source and a `RangeError` for JSON. + pub nesting_depth: u32, +} + +impl Limits { + /// Limits that no ordinary program reaches, for tests and for a runner + /// that wants the engine's behaviour without its limits getting in the + /// way. This is a named choice, not a default: nothing in the engine + /// calls it. + pub const fn unlimited() -> Limits { + Limits { + heap_bytes: u64::MAX, + value_stack_bytes: u64::MAX, + native_depth: u32::MAX, + code_bytes: u64::MAX, + regexp_backtrack_entries: u64::MAX, + nesting_depth: u32::MAX, + } + } +} + +/// Whether the JIT is on. Only [`Off`](JitMode::Off) exists until jit.md's +/// `clazel-jit` does; then a variant carrying a `CodeMapper` is added +/// (jit.md J.0(b)): the embedder's choice of how validated code becomes +/// executable. The interpreter is complete without it. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +#[non_exhaustive] +pub enum JitMode { + /// Interpret only. + #[default] + Off, +} + +/// What a [`Runtime`] is built from. +/// +/// ```no_run +/// use clazel_js::{Config, JitMode, Limits}; +/// +/// let config = Config::new(Limits::unlimited()); +/// assert_eq!(config.jit, JitMode::Off); +/// ``` +#[derive(Clone, Copy, Debug)] +pub struct Config { + /// The limits. See [`Limits`]. + pub limits: Limits, + /// Whether to use the JIT. + pub jit: JitMode, +} + +impl Config { + /// A configuration with the given limits and the JIT off. + pub const fn new(limits: Limits) -> Config { + Config { + limits, + jit: JitMode::Off, + } + } +} + +/// A handle that stops a [`Runtime`] from another thread. +/// +/// - **How it works.** `terminate` sets a flag. The interpreter checks it at +/// loop back-edges and at calls, and JIT code checks it at the same points. +/// An evaluation that sees it ends with +/// [`Error::Terminated`](crate::Error::Terminated). +/// - **JavaScript cannot catch it.** `catch` does not run, and neither does +/// `finally`: running either would run JavaScript after being told to stop. +/// Native frames see `Err(Error::Terminated)` and must pass it on. One that +/// does not still stops at the next check, which raises it again. +/// - **It is sticky.** The flag stays set, so every later call into the same +/// `Runtime` also ends in `Terminated`, until [`Terminator::clear`] (an open +/// question in the README is whether a terminated runtime stays usable). +/// - **Cost.** The check is one relaxed atomic load. It is not a way to +/// interrupt a native function that is itself in a long loop; built-ins +/// check it too, and an embedder's native function should +/// [`Scope::check_terminated`] in a long loop. +/// - **It is the embedder's policy.** The browser still ends a stuck renderer +/// from outside, on the user's word (phase-7.md 7.0(g)), and may use this +/// later to keep the tab. +/// +/// A `Terminator` is `Clone`, `Send` and `Sync`. +/// +/// ```no_run +/// use std::thread; +/// use std::time::Duration; +/// use clazel_js::{Config, DefaultHost, Limits, Realm, Runtime}; +/// +/// fn run_for_a_second(rt: &mut Runtime, realm: &Realm) { +/// let terminator = rt.terminator(); +/// let watchdog = thread::spawn(move || { +/// thread::sleep(Duration::from_secs(1)); +/// terminator.terminate(); +/// }); +/// let _ = rt.scope(|scope| { +/// scope.eval_script(realm, clazel_js::Source::new("loop.js", "for (;;) {}"))?; +/// Ok::<(), clazel_js::Error>(()) +/// }); +/// let _ = watchdog.join(); +/// rt.terminator().clear(); +/// } +/// ``` +#[derive(Clone, Debug, Default)] +pub struct Terminator { + flag: Arc, +} + +impl Terminator { + /// Asks the runtime to stop. Safe to call from any thread, any number of + /// times. + pub fn terminate(&self) { + self.flag.store(true, Ordering::Relaxed); + } + + /// Whether `terminate` has been called and not cleared. + pub fn is_terminated(&self) -> bool { + self.flag.load(Ordering::Relaxed) + } + + /// Lets the runtime run again. Call it after an evaluation has returned + /// `Terminated`, never while one is running. + pub fn clear(&self) { + self.flag.store(false, Ordering::Relaxed); + } +} + +/// One ECMAScript agent: a heap, a job queue, limits and a [`Host`]. +/// +/// - **No global state.** Everything the engine knows lives in the `Runtime`, +/// with no `static` and no thread-local, so a process can hold many. +/// - **Threads.** A `Runtime` is `Send` and not `Sync`. It can move to another +/// thread between calls, and only one thread can use it at a time. The +/// browser runs one per renderer, on one thread, as phase-7.md 7.0(e) +/// decided. [`Terminator`] is the one piece usable from other threads. +/// `Host: Send` is what keeps this true, because the host lives inside. +/// - **Calls go through a scope.** [`Runtime::scope`] runs a closure with a +/// [`Scope`], and everything else is a method of that. +/// - **Dropping** frees the whole heap, runs each native closure's and host +/// object's destructor, and does not run any JavaScript (no finalizer). +/// +/// ```compile_fail +/// use clazel_js::Runtime; +/// +/// fn needs_sync() {} +/// +/// // Does not compile: a Runtime is not Sync. +/// fn check() { needs_sync::(); } +/// ``` +/// +/// ```no_run +/// use clazel_js::{Config, DefaultHost, Limits, RealmOptions, Runtime, Source}; +/// +/// fn main() -> Result<(), clazel_js::Error> { +/// let mut rt = Runtime::new(Config::new(Limits::unlimited()), DefaultHost::new())?; +/// let realm = rt.scope(|scope| scope.create_realm(RealmOptions::default()))?; +/// let sum = rt.scope(|scope| { +/// let value = scope.eval_script(&realm, Source::new("sum.js", "1 + 2"))?; +/// Ok(scope.as_number(value)) +/// })?; +/// assert_eq!(sum, Some(3.0)); +/// rt.run_jobs()?; +/// Ok(()) +/// } +/// ``` +/// +/// A `Runtime` moves to another thread as a whole: +/// +/// ```no_run +/// use clazel_js::Runtime; +/// +/// fn assert_send() {} +/// fn check() { assert_send::(); } +/// ``` +pub struct Runtime { + limits: Limits, + terminator: Terminator, + host: Box, + // `Cell` is `Send` and not `Sync`, which is the rule. + _not_sync: PhantomData>, +} + +impl Runtime { + /// Builds a runtime with no realms. The `host` is taken for the life of + /// the runtime; reach it again with [`Runtime::host_mut`] or, from inside + /// a native function, [`Scope::host_mut`]. + pub fn new(config: Config, host: impl Host) -> Result { + not_implemented!("Runtime::new", config, host) + } + + /// Runs `f` with a [`Scope`]. Every [`Local`](crate::Local) made inside is + /// rooted until `f` returns, and cannot leave it; what `f` returns must + /// not borrow from the scope. This is the only way in. + /// + /// `f` cannot call `scope` again, because it has no access to the + /// `Runtime`. Code that wants an inner scope uses [`Scope::nested`]. + pub fn scope(&mut self, f: impl for<'s> FnOnce(&mut Scope<'s>) -> R) -> R { + let mut scope = Scope::new(); + f(&mut scope) + } + + /// Runs queued jobs (promise reactions, generic jobs, finalization + /// callbacks) until the queue is empty, and returns how many ran. This is + /// a microtask checkpoint; the engine never decides when to run one. + /// + /// The queue is the engine's own unless the [`Host`] diverted it: + /// [`Host::enqueue_promise_job`] and its siblings default to appending to + /// it. A job that throws stops the run: the exception comes back as + /// `Err`, the jobs after it stay queued, and calling `run_jobs` again + /// continues with them. A [`Terminator`] stops it as it stops anything. + /// + /// ```no_run + /// use clazel_js::Runtime; + /// + /// fn checkpoint(rt: &mut Runtime) -> clazel_js::Result<()> { + /// // After a script returns, with the host's own tasks still to run: + /// let ran = rt.run_jobs()?; + /// println!("{ran} jobs"); + /// Ok(()) + /// } + /// ``` + pub fn run_jobs(&mut self) -> Result { + not_implemented!("Runtime::run_jobs") + } + + /// A handle that stops this runtime from another thread. Every call gives + /// a handle to the same flag. + pub fn terminator(&self) -> Terminator { + self.terminator.clone() + } + + /// The limits this runtime was built with. + pub fn limits(&self) -> Limits { + self.limits + } + + /// The host, between calls. Not available while a hook is running; there + /// the hook's own `&mut self` is the host. + pub fn host_mut(&mut self) -> &mut dyn Host { + &mut *self.host + } + + /// Bytes the heap holds now, live and not yet swept, for the embedder's + /// own accounting and for tests of [`Limits::heap_bytes`]. + pub fn heap_used(&self) -> Result { + not_implemented!("Runtime::heap_used") + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn is_send() {} + fn is_send_sync() {} + + #[test] + fn terminator_is_a_shared_sticky_flag() { + is_send_sync::(); + let a = Terminator::default(); + let b = a.clone(); + assert!(!a.is_terminated()); + b.terminate(); + assert!(a.is_terminated()); + b.terminate(); + assert!(a.is_terminated()); + a.clear(); + assert!(!b.is_terminated()); + } + + #[test] + fn runtime_is_send() { + is_send::(); + } + + #[test] + fn unlimited_is_the_largest_of_each() { + let l = Limits::unlimited(); + assert_eq!(l.heap_bytes, u64::MAX); + assert_eq!(l.native_depth, u32::MAX); + } +} diff --git a/crates/clazel-js/src/scope.rs b/crates/clazel-js/src/scope.rs new file mode 100644 index 00000000..e34c8dca --- /dev/null +++ b/crates/clazel-js/src/scope.rs @@ -0,0 +1,775 @@ +//! [`Scope`]: every operation on values, realms, code and objects. + +use core::any::Any; +use core::marker::PhantomData; + +use crate::code::{ + LoadPayload, Module, ModuleStatus, Realm, RealmOptions, Referrer, Script, Source, +}; +use crate::error::{Error, ErrorKind, ErrorReport, Exception, Result, not_implemented}; +use crate::host::Host; +use crate::native::{Args, Callable, HostObject}; +use crate::value::{ + Handle, Key, Local, Member, PromiseState, PropertyDescriptor, ValueKind, Weak, WellKnownSymbol, +}; + +/// The resolving functions of a promise made by [`Scope::new_promise`]. +/// +/// Held by the embedder until the work the promise stands for is done: a +/// fetch finishes, a timer fires. It is two [`Handle`]s, `Send` and `Sync`, +/// and settling uses [`Scope::resolve_promise`] and [`Scope::reject_promise`] +/// on the runtime's thread. Settling twice is a no-op, as for JavaScript's own +/// resolving functions. +#[derive(Clone, Debug)] +pub struct Resolvers { + resolve: Handle, + reject: Handle, +} + +impl Resolvers { + /// The `resolve` function. + pub fn resolve_function(&self) -> &Handle { + &self.resolve + } + + /// The `reject` function. + pub fn reject_function(&self) -> &Handle { + &self.reject + } +} + +/// Where all work on a [`Runtime`](crate::Runtime) happens, and the owner of +/// the lifetime `'s` that every [`Local`] it makes carries. +/// +/// A `Scope` exists inside [`Runtime::scope`](crate::Runtime::scope), inside +/// each native function and hook (which get one for their call), and inside +/// [`Scope::nested`]. All the engine's operations are methods of it, grouped +/// below. +/// +/// - **Rooting.** Each `Local` is rooted until its scope ends. A loop that +/// makes many temporary values uses `nested` per iteration so they are not +/// all held until the end. +/// - **Collection.** The collector runs only inside an operation that +/// allocates or that the embedder asks for ([`Scope::gc`]), never between +/// two lines of the embedder's own code, so no `Local` is ever seen half +/// moved. The heap does not move objects (phase-7.md 7.0(f)). +/// - **Errors.** Operations that can run JavaScript, and so throw, return +/// `Result`. Operations that cannot (making a number, reading a kind) do not. +/// +/// ```no_run +/// use clazel_js::{Key, Runtime}; +/// +/// fn sum_squares(rt: &mut Runtime, n: u32) -> clazel_js::Result { +/// rt.scope(|scope| { +/// let list = scope.new_array(0)?; +/// for i in 0..n { +/// // Temporaries die at the end of each pass, not at the end of the call. +/// scope.nested(|inner| { +/// let x = inner.number(f64::from(i) * f64::from(i)); +/// inner.set(list, Key::Index(i), x) +/// })?; +/// } +/// let length = scope.get(list, Key::from("length"))?; +/// Ok(scope.as_number(length).unwrap_or(0.0)) +/// }) +/// } +/// ``` +#[derive(Debug)] +pub struct Scope<'s> { + // Invariant in `'s`, so a `Local<'s>` cannot be coerced to another scope's. + _scope: PhantomData &'s ()>, +} + +impl<'s> Scope<'s> { + pub(crate) fn new() -> Scope<'s> { + Scope { + _scope: PhantomData, + } + } + + /// Runs `f` with an inner scope. The `Local`s `f` makes are released when + /// it returns, and cannot escape it. What `f` returns must be owned + /// (a [`Handle`], a number, an [`Exception`]); to keep a value, call + /// [`Scope::persist`] inside `f`. + pub fn nested(&mut self, f: impl for<'i> FnOnce(&mut Scope<'i>) -> R) -> R { + let mut inner = Scope::new(); + f(&mut inner) + } + + // ---- Holding values ---------------------------------------------------- + + /// Roots `value` beyond this scope. See [`Handle`]. + pub fn persist(&mut self, value: Local<'_>) -> Handle { + let _ = value; + Handle::placeholder() + } + + /// The value a handle names, as a `Local` of this scope. + /// [`Error::WrongRuntime`] if the handle is another runtime's, + /// [`Error::StaleHandle`] if its generation does not match. + pub fn local(&mut self, handle: &Handle) -> Result> { + not_implemented!("Scope::local", handle) + } + + /// A weak reference to `value`. See [`Weak`]. + pub fn downgrade(&mut self, value: Local<'_>) -> Weak { + let _ = value; + Weak::placeholder() + } + + /// The value, if it is still alive. `Ok(None)` once it has been collected. + pub fn upgrade(&mut self, weak: &Weak) -> Result>> { + not_implemented!("Scope::upgrade", weak) + } + + /// A [`Member`] for `value`, to store in a host object's data and report + /// from its `trace`. + pub fn member(&mut self, value: Local<'_>) -> Member { + let _ = value; + Member::placeholder() + } + + /// The value a member names. [`Error::StaleHandle`] if the owner did not + /// report it and it has been collected. + pub fn local_from_member(&mut self, member: Member) -> Result> { + not_implemented!("Scope::local_from_member", member) + } + + // ---- Making and reading primitive values ----------------------------- + + /// `undefined`. + pub fn undefined(&mut self) -> Local<'s> { + Local::placeholder() + } + + /// `null`. + pub fn null(&mut self) -> Local<'s> { + Local::placeholder() + } + + /// A Boolean. + pub fn boolean(&mut self, value: bool) -> Local<'s> { + let _ = value; + Local::placeholder() + } + + /// A Number. NaN is canonicalized, as the value encoding requires. + pub fn number(&mut self, value: f64) -> Local<'s> { + let _ = value; + Local::placeholder() + } + + /// A String from Rust text. + pub fn string(&mut self, value: &str) -> Local<'s> { + let _ = value; + Local::placeholder() + } + + /// A String from UTF-16 code units, which may hold lone surrogates that a + /// Rust `&str` cannot. This is the exact form JavaScript strings take, + /// and what WebIDL's `DOMString` and `USVString` conversions start from. + pub fn string_utf16(&mut self, units: &[u16]) -> Local<'s> { + let _ = units; + Local::placeholder() + } + + /// A BigInt from an `i64`. + pub fn bigint_from_i64(&mut self, value: i64) -> Local<'s> { + let _ = value; + Local::placeholder() + } + + /// A BigInt from a `u64`. + pub fn bigint_from_u64(&mut self, value: u64) -> Local<'s> { + let _ = value; + Local::placeholder() + } + + /// A new unique Symbol with an optional description. + pub fn new_symbol(&mut self, description: Option<&str>) -> Local<'s> { + let _ = description; + Local::placeholder() + } + + /// A well-known symbol. The same symbol in every call and every realm of + /// this runtime, as ECMA-262 says. + pub fn well_known_symbol(&mut self, symbol: WellKnownSymbol) -> Local<'s> { + let _ = symbol; + Local::placeholder() + } + + /// What kind of value this is. Never throws and never runs JavaScript. + pub fn kind(&self, value: Local<'_>) -> ValueKind { + let _ = value; + ValueKind::Undefined + } + + /// The Boolean, or `None` if the value is not one. + pub fn as_boolean(&self, value: Local<'_>) -> Option { + let _ = value; + None + } + + /// The Number, or `None` if the value is not one. + pub fn as_number(&self, value: Local<'_>) -> Option { + let _ = value; + None + } + + /// A String's UTF-16 code units, exactly. `Err(WrongType)` for a + /// non-string. + pub fn string_to_utf16(&self, value: Local<'_>) -> Result> { + not_implemented!("Scope::string_to_utf16", value) + } + + /// A String as Rust text, with each lone surrogate replaced by U+FFFD. + /// `Err(WrongType)` for a non-string. + pub fn string_to_string_lossy(&self, value: Local<'_>) -> Result { + not_implemented!("Scope::string_to_string_lossy", value) + } + + // ---- Conversions and tests (what WebIDL's conversions are built from) -- + + /// `ToBoolean`. Cannot throw. + pub fn to_boolean(&mut self, value: Local<'_>) -> bool { + let _ = value; + false + } + + /// `ToNumber`. Can throw: a Symbol, a BigInt, or an object whose + /// `valueOf` throws. + pub fn to_number(&mut self, value: Local<'_>) -> Result { + not_implemented!("Scope::to_number", value) + } + + /// `ToString`, as a String value. Can throw. + pub fn to_string(&mut self, value: Local<'_>) -> Result> { + not_implemented!("Scope::to_string", value) + } + + /// `ToObject`. Throws a `TypeError` for `undefined` and `null`. + pub fn to_object(&mut self, value: Local<'_>) -> Result> { + not_implemented!("Scope::to_object", value) + } + + /// `IsCallable`. + pub fn is_callable(&self, value: Local<'_>) -> bool { + let _ = value; + false + } + + /// `IsConstructor`. + pub fn is_constructor(&self, value: Local<'_>) -> bool { + let _ = value; + false + } + + /// `IsArray`. Throws for a revoked proxy. + pub fn is_array(&mut self, value: Local<'_>) -> Result { + not_implemented!("Scope::is_array", value) + } + + /// `IsStrictlyEqual` (`===`). + pub fn strict_equals(&self, a: Local<'_>, b: Local<'_>) -> bool { + let _ = (a, b); + false + } + + /// `SameValue` (`Object.is`). + pub fn same_value(&self, a: Local<'_>, b: Local<'_>) -> bool { + let _ = (a, b); + false + } + + /// `InstanceofOperator` (`value instanceof constructor`). Can throw. + pub fn instance_of(&mut self, value: Local<'_>, constructor: Local<'_>) -> Result { + not_implemented!("Scope::instance_of", value, constructor) + } + + // ---- Objects ------------------------------------------------------------ + + /// A new ordinary object, as `{}` in the current realm. + pub fn new_object(&mut self) -> Result> { + not_implemented!("Scope::new_object") + } + + /// A new Array of the given length, as `new Array(length)`. + pub fn new_array(&mut self, length: u32) -> Result> { + not_implemented!("Scope::new_array", length) + } + + /// A new Array holding these values. + pub fn new_array_from(&mut self, elements: &[Local<'_>]) -> Result> { + not_implemented!("Scope::new_array_from", elements) + } + + /// `Get(object, key)`. Runs getters and proxy traps, so can throw. + pub fn get(&mut self, object: Local<'_>, key: Key<'_, '_>) -> Result> { + not_implemented!("Scope::get", object, key) + } + + /// `Set(object, key, value, true)`: throws in the cases strict-mode + /// assignment throws (a read-only property, a frozen object). + pub fn set(&mut self, object: Local<'_>, key: Key<'_, '_>, value: Local<'_>) -> Result<()> { + not_implemented!("Scope::set", object, key, value) + } + + /// `HasProperty` (`key in object`). + pub fn has_property(&mut self, object: Local<'_>, key: Key<'_, '_>) -> Result { + not_implemented!("Scope::has_property", object, key) + } + + /// `DeletePropertyOrThrow`, but returning `false` for a refusal instead of + /// throwing, as sloppy-mode `delete` does. + pub fn delete_property(&mut self, object: Local<'_>, key: Key<'_, '_>) -> Result { + not_implemented!("Scope::delete_property", object, key) + } + + /// `DefinePropertyOrThrow`: `Object.defineProperty`. + pub fn define_property( + &mut self, + object: Local<'_>, + key: Key<'_, '_>, + descriptor: PropertyDescriptor<'_>, + ) -> Result<()> { + not_implemented!("Scope::define_property", object, key, descriptor) + } + + /// `GetPrototypeOf`. `null` is returned as the `null` value. + pub fn get_prototype_of(&mut self, object: Local<'_>) -> Result> { + not_implemented!("Scope::get_prototype_of", object) + } + + /// `SetPrototypeOf`: throws if the object refuses (not extensible, or a + /// cycle). + pub fn set_prototype_of(&mut self, object: Local<'_>, prototype: Local<'_>) -> Result<()> { + not_implemented!("Scope::set_prototype_of", object, prototype) + } + + /// `GetMethod(value, key)`: `Ok(None)` if the property is `undefined` or + /// `null`, a `TypeError` if it is anything else but callable. + pub fn get_method(&mut self, value: Local<'_>, key: Key<'_, '_>) -> Result>> { + not_implemented!("Scope::get_method", value, key) + } + + /// `Call(function, this, arguments)`. + pub fn call( + &mut self, + function: Local<'_>, + this: Local<'_>, + arguments: &[Local<'_>], + ) -> Result> { + not_implemented!("Scope::call", function, this, arguments) + } + + /// `Construct(constructor, arguments, newTarget)`; `new_target` of `None` + /// is the constructor itself. + pub fn construct( + &mut self, + constructor: Local<'_>, + arguments: &[Local<'_>], + new_target: Option>, + ) -> Result> { + not_implemented!("Scope::construct", constructor, arguments, new_target) + } + + /// Runs the iterator protocol over `iterable`, calling `f` with each value + /// until it returns `Ok(false)` or the iterator ends. If `f` returns `Err`, + /// or `Ok(false)`, the iterator is closed (`IteratorClose`) first. This is + /// the operation WebIDL's `sequence` and `iterable` conversions need. + /// + /// ```no_run + /// use clazel_js::Runtime; + /// + /// fn count(rt: &mut Runtime, iterable: &clazel_js::Handle) -> clazel_js::Result { + /// rt.scope(|scope| { + /// let iterable = scope.local(iterable)?; + /// let mut n = 0; + /// scope.iterate(iterable, |_scope, _item| { + /// n += 1; + /// Ok(true) + /// })?; + /// Ok(n) + /// }) + /// } + /// ``` + pub fn iterate( + &mut self, + iterable: Local<'_>, + f: impl for<'i> FnMut(&mut Scope<'i>, Local<'i>) -> Result, + ) -> Result<()> { + not_implemented!("Scope::iterate", iterable, f) + } + + // ---- Native functions and host objects ------------------------------------ + + /// A JavaScript function that runs `f`. + /// + /// `name` and `length` are the function's `name` and `length`. `callable` + /// says whether `new` works on it. `f` gets a fresh scope for the call, + /// the arguments, and returns the result or an [`Error`]. Panics in `f` + /// are not caught: the lints forbid them in this repository, and an + /// embedder that panics gets its own panic. + /// + /// ```no_run + /// use clazel_js::{Args, Callable, Key, Local, Result, Runtime, Scope}; + /// + /// fn install(rt: &mut Runtime, realm: &clazel_js::Realm) -> Result<()> { + /// rt.scope(|scope| { + /// let global = scope.global(realm)?; + /// let greet = scope.function("greet", 1, Callable::Function, |scope, args| { + /// let who = scope.to_string(args.get(0))?; + /// let who = scope.string_to_string_lossy(who)?; + /// Ok(scope.string(&format!("hello, {who}"))) + /// })?; + /// scope.set(global, Key::from("greet"), greet) + /// }) + /// } + /// ``` + pub fn function( + &mut self, + name: &str, + length: u32, + callable: Callable, + f: impl for<'a> Fn(&mut Scope<'a>, &Args<'a>) -> Result> + Send + 'static, + ) -> Result> { + not_implemented!("Scope::function", name, length, callable, f) + } + + /// Makes a function with [`Scope::function`] and defines it as a method + /// of `object`: writable, non-enumerable, configurable, as WebIDL + /// operations and built-in methods are. + pub fn define_method( + &mut self, + object: Local<'_>, + name: &str, + length: u32, + f: impl for<'a> Fn(&mut Scope<'a>, &Args<'a>) -> Result> + Send + 'static, + ) -> Result<()> { + not_implemented!("Scope::define_method", object, name, length, f) + } + + /// A new host object carrying `data`, with this prototype (`None` is + /// `null`). See [`HostObject`]. + pub fn new_host_object( + &mut self, + prototype: Option>, + data: impl HostObject, + ) -> Result> { + not_implemented!("Scope::new_host_object", prototype, data) + } + + /// The data of a host object of type `T`. [`Error::WrongType`] if the + /// value is anything else (another type of host object included), and + /// [`Error::Busy`] if one of its own hooks is running. + pub fn host_data(&self, object: Local<'_>) -> Result<&T> { + not_implemented!("Scope::host_data", object) + } + + /// As [`Scope::host_data`], mutably. + pub fn host_data_mut(&mut self, object: Local<'_>) -> Result<&mut T> { + not_implemented!("Scope::host_data_mut", object) + } + + /// `GetPrototypeFromConstructor(newTarget, ...)`: the `prototype` of + /// `new_target` if it is an object, else `fallback`. A constructor that + /// makes a host object calls this with its [`Args::new_target`] so that a + /// subclass (`class X extends Node`) gets its own prototype. + pub fn get_prototype_from_constructor( + &mut self, + new_target: Local<'_>, + fallback: Local<'_>, + ) -> Result> { + not_implemented!( + "Scope::get_prototype_from_constructor", + new_target, + fallback + ) + } + + /// The embedder's [`Host`] as its own type. [`Error::WrongType`] if the + /// host is another type, and [`Error::Busy`] while a hook of the host is + /// running (the hook already has the host as `&mut self`). + pub fn host_mut(&mut self) -> Result<&mut H> { + not_implemented!("Scope::host_mut") + } + + /// For a native function: ends the call with [`Error::Terminated`] if a + /// [`Terminator`](crate::Terminator) has been used. Call it in any native + /// loop that can run long. + pub fn check_terminated(&self) -> Result<()> { + not_implemented!("Scope::check_terminated") + } + + // ---- Errors --------------------------------------------------------------- + + /// A new error object of `kind` with `message`, as an [`Exception`] ready to + /// throw or to refuse a module load with. + pub fn new_exception(&mut self, kind: ErrorKind, message: &str) -> Result { + not_implemented!("Scope::new_exception", kind, message) + } + + /// The `Err` for throwing a new error: `return Err(scope.throw_error(...))`. + /// If creating the error object itself fails, that failure is returned. + pub fn throw_error(&mut self, kind: ErrorKind, message: &str) -> Error { + match self.new_exception(kind, message) { + Ok(exception) => Error::Thrown(exception), + Err(other) => other, + } + } + + /// The `Err` for throwing any value, for example a `DOMException` the + /// embedder made. + pub fn throw(&mut self, value: Local<'_>) -> Error { + Error::Thrown(Exception::from_handle(self.persist(value))) + } + + /// The value inside an exception, as a `Local` of this scope. + pub fn exception_value(&mut self, exception: &Exception) -> Result> { + self.local(exception.value()) + } + + /// Describes a thrown value. See [`ErrorReport`]. Reads `name`, `message` + /// and `stack` as data properties and does not call getters, so it cannot + /// run JavaScript or throw. + pub fn report(&mut self, exception: &Exception) -> Result { + not_implemented!("Scope::report", exception) + } + + // ---- Promises --------------------------------------------------------------- + + /// A new pending promise and its resolving functions. For an API that + /// returns a promise and settles it later (`fetch`). + /// + /// ```no_run + /// use clazel_js::{Handle, Resolvers, Runtime}; + /// + /// // `fetch()` returns the promise now and keeps the resolvers for later. + /// fn start_fetch(rt: &mut Runtime) -> clazel_js::Result<(Handle, Resolvers)> { + /// rt.scope(|scope| { + /// let (promise, resolvers) = scope.new_promise()?; + /// Ok((scope.persist(promise), resolvers)) + /// }) + /// } + /// + /// // The kernel answered; settle it, then let the reactions run. + /// fn finish_fetch(rt: &mut Runtime, resolvers: &Resolvers) -> clazel_js::Result<()> { + /// rt.scope(|scope| { + /// let response = scope.new_object()?; + /// scope.resolve_promise(resolvers, response) + /// })?; + /// rt.run_jobs()?; + /// Ok(()) + /// } + /// ``` + pub fn new_promise(&mut self) -> Result<(Local<'s>, Resolvers)> { + not_implemented!("Scope::new_promise") + } + + /// Calls the promise's `resolve` with `value`. If the value is a thenable + /// the promise follows it, as for any resolve. + pub fn resolve_promise(&mut self, resolvers: &Resolvers, value: Local<'_>) -> Result<()> { + not_implemented!("Scope::resolve_promise", resolvers, value) + } + + /// Calls the promise's `reject` with `reason`. + pub fn reject_promise(&mut self, resolvers: &Resolvers, reason: Local<'_>) -> Result<()> { + not_implemented!("Scope::reject_promise", resolvers, reason) + } + + /// `Promise.resolve(value)` in the current realm. + pub fn promise_resolve(&mut self, value: Local<'_>) -> Result> { + not_implemented!("Scope::promise_resolve", value) + } + + /// `PerformPromiseThen` on `promise` with these reactions (each a function + /// or `None`), returning the derived promise. This is how the embedder + /// continues after a promise it did not make, such as the one + /// [`Scope::evaluate_module`] returns. + pub fn promise_then( + &mut self, + promise: Local<'_>, + on_fulfilled: Option>, + on_rejected: Option>, + ) -> Result> { + not_implemented!("Scope::promise_then", promise, on_fulfilled, on_rejected) + } + + /// A promise's state now. Reading it never marks a rejection handled. + pub fn promise_state(&self, promise: Local<'_>) -> Result> { + not_implemented!("Scope::promise_state", promise) + } + + // ---- ArrayBuffers ------------------------------------------------------------ + + /// A new `ArrayBuffer` that owns `bytes`. + pub fn new_array_buffer(&mut self, bytes: Vec) -> Result> { + not_implemented!("Scope::new_array_buffer", bytes) + } + + /// An `ArrayBuffer`'s bytes. Empty for a detached one. The borrow ends + /// before any call that can run JavaScript, which could detach or resize it. + pub fn array_buffer_bytes(&self, buffer: Local<'_>) -> Result<&[u8]> { + not_implemented!("Scope::array_buffer_bytes", buffer) + } + + /// `DetachArrayBuffer(buffer, key)`: after it the buffer has length 0. + /// `key` must be the `ArrayBuffer`'s detach key if it has one, else a + /// `TypeError`. This is Test262's `$262.detachArrayBuffer`, and what + /// `postMessage` transfers and `structuredClone` use later. + pub fn detach_array_buffer(&mut self, buffer: Local<'_>, key: Option>) -> Result<()> { + not_implemented!("Scope::detach_array_buffer", buffer, key) + } + + // ---- Realms --------------------------------------------------------------------- + + /// `CreateRealm` plus `SetDefaultGlobalBindings`: a new realm with its own + /// built-ins. This is `$262.createRealm`. + pub fn create_realm(&mut self, options: RealmOptions) -> Result { + not_implemented!("Scope::create_realm", options) + } + + /// The realm of the function being run. Inside a native function, the + /// function's own realm; inside a hook, the realm of the code that + /// triggered it, if there is one. + pub fn current_realm(&mut self) -> Result { + not_implemented!("Scope::current_realm") + } + + /// The realm's global object. Add properties to it with [`Scope::set`] and + /// [`Scope::define_property`]; that is how an embedder installs `console` + /// or `window`. + pub fn global(&mut self, realm: &Realm) -> Result> { + not_implemented!("Scope::global", realm) + } + + /// Attaches the embedder's data to a realm (HTML's environment settings + /// object), replacing what was there. + pub fn set_realm_host_defined( + &mut self, + realm: &Realm, + data: Box, + ) -> Result<()> { + not_implemented!("Scope::set_realm_host_defined", realm, data) + } + + /// The data attached with [`Scope::set_realm_host_defined`]. + pub fn realm_host_defined(&self, realm: &Realm) -> Result> { + not_implemented!("Scope::realm_host_defined", realm) + } + + // ---- Scripts and modules ------------------------------------------------------------ + + /// `ParseScript`: compiles `source`. A syntax error is + /// [`Error::Thrown`] holding a `SyntaxError` of `realm`. + pub fn compile_script(&mut self, realm: &Realm, source: Source<'_>) -> Result