mirror of
https://github.com/hanzoai/swc.git
synced 2026-10-30 19:42:53 +00:00
**Description:** Following our previous discussion, I am trying to introduce a self-describing serialization encoding for ast to replace https://github.com/swc-project/swc/pull/11069 . Since `serde` is currently used for json serialization, it is hard to modify serde to support both json and binary encodings (due to the `untagged` and `flatten` attr). So I made our own `Encode` and `Decode` proc macro, which also facilitate unknown variant support. <img width="1804" height="1776" alt="benchmark" src="https://github.com/user-attachments/assets/73e294cd-be88-43a0-a390-fdd24c8f464f" /> I've done some simple benchmarks with a modified swc ast, and I believe we don't have an unacceptable performance loss relative to `rkyv`. I'm using `cbor4ii` here, which I developed, so I'd prefer it if there's no performance difference. but it's easy to migrate to `bincode` or other scheme. This also introduces an `unknown` feature for `ecma_ast` crate, which should only be enabled by the wasm plugin to ensure that old plugins can decode new AST.
291 lines
7.2 KiB
Plaintext
291 lines
7.2 KiB
Plaintext
x Stylesheet
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | ,-> div {
|
|
2 | | prod: fn(100px);
|
|
3 | | prod: --fn(100px);
|
|
4 | | prod: --fn--fn(100px);
|
|
5 | `-> }
|
|
`----
|
|
x Rule
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | ,-> div {
|
|
2 | | prod: fn(100px);
|
|
3 | | prod: --fn(100px);
|
|
4 | | prod: --fn--fn(100px);
|
|
5 | `-> }
|
|
`----
|
|
x QualifiedRule
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | ,-> div {
|
|
2 | | prod: fn(100px);
|
|
3 | | prod: --fn(100px);
|
|
4 | | prod: --fn--fn(100px);
|
|
5 | `-> }
|
|
`----
|
|
x SelectorList
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | div {
|
|
: ^^^
|
|
2 | prod: fn(100px);
|
|
`----
|
|
x ComplexSelector
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | div {
|
|
: ^^^
|
|
2 | prod: fn(100px);
|
|
`----
|
|
x CompoundSelector
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | div {
|
|
: ^^^
|
|
2 | prod: fn(100px);
|
|
`----
|
|
x TypeSelector
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | div {
|
|
: ^^^
|
|
2 | prod: fn(100px);
|
|
`----
|
|
x TagNameSelector
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | div {
|
|
: ^^^
|
|
2 | prod: fn(100px);
|
|
`----
|
|
x WqName
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | div {
|
|
: ^^^
|
|
2 | prod: fn(100px);
|
|
`----
|
|
x Ident
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | div {
|
|
: ^^^
|
|
2 | prod: fn(100px);
|
|
`----
|
|
x SimpleBlock
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | ,-> div {
|
|
2 | | prod: fn(100px);
|
|
3 | | prod: --fn(100px);
|
|
4 | | prod: --fn--fn(100px);
|
|
5 | `-> }
|
|
`----
|
|
x LBrace
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:1:1]
|
|
1 | div {
|
|
: ^
|
|
2 | prod: fn(100px);
|
|
`----
|
|
x ComponentValue
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^^^^^^^^^^^^^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x Declaration
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^^^^^^^^^^^^^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x DeclarationName
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x Ident
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x ComponentValue
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^^^^^^^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x Function
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^^^^^^^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x Ident
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x ComponentValue
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^^^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x Dimension
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^^^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x Length
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^^^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x Number
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x Ident
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:2:1]
|
|
1 | div {
|
|
2 | prod: fn(100px);
|
|
: ^^
|
|
3 | prod: --fn(100px);
|
|
`----
|
|
x ComponentValue
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:3:1]
|
|
2 | prod: fn(100px);
|
|
3 | prod: --fn(100px);
|
|
: ^^^^^^^^^^^^^^^^^
|
|
4 | prod: --fn--fn(100px);
|
|
`----
|
|
x Declaration
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:3:1]
|
|
2 | prod: fn(100px);
|
|
3 | prod: --fn(100px);
|
|
: ^^^^^^^^^^^^^^^^^
|
|
4 | prod: --fn--fn(100px);
|
|
`----
|
|
x DeclarationName
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:3:1]
|
|
2 | prod: fn(100px);
|
|
3 | prod: --fn(100px);
|
|
: ^^^^
|
|
4 | prod: --fn--fn(100px);
|
|
`----
|
|
x Ident
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:3:1]
|
|
2 | prod: fn(100px);
|
|
3 | prod: --fn(100px);
|
|
: ^^^^
|
|
4 | prod: --fn--fn(100px);
|
|
`----
|
|
x ComponentValue
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:3:1]
|
|
2 | prod: fn(100px);
|
|
3 | prod: --fn(100px);
|
|
: ^^^^^^^^^^^
|
|
4 | prod: --fn--fn(100px);
|
|
`----
|
|
x Function
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:3:1]
|
|
2 | prod: fn(100px);
|
|
3 | prod: --fn(100px);
|
|
: ^^^^^^^^^^^
|
|
4 | prod: --fn--fn(100px);
|
|
`----
|
|
x DashedIdent
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:3:1]
|
|
2 | prod: fn(100px);
|
|
3 | prod: --fn(100px);
|
|
: ^^^^
|
|
4 | prod: --fn--fn(100px);
|
|
`----
|
|
x ComponentValue
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:3:1]
|
|
2 | prod: fn(100px);
|
|
3 | prod: --fn(100px);
|
|
: ^^^^^
|
|
4 | prod: --fn--fn(100px);
|
|
`----
|
|
x Dimension { dimension: DimensionToken { value: 100.0, raw_value: "100", unit: "px", type_flag: Integer, raw_unit: "px" } }
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:3:1]
|
|
2 | prod: fn(100px);
|
|
3 | prod: --fn(100px);
|
|
: ^^^^^
|
|
4 | prod: --fn--fn(100px);
|
|
`----
|
|
x ComponentValue
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:4:1]
|
|
3 | prod: --fn(100px);
|
|
4 | prod: --fn--fn(100px);
|
|
: ^^^^^^^^^^^^^^^^^^^^^
|
|
5 | }
|
|
`----
|
|
x Declaration
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:4:1]
|
|
3 | prod: --fn(100px);
|
|
4 | prod: --fn--fn(100px);
|
|
: ^^^^^^^^^^^^^^^^^^^^^
|
|
5 | }
|
|
`----
|
|
x DeclarationName
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:4:1]
|
|
3 | prod: --fn(100px);
|
|
4 | prod: --fn--fn(100px);
|
|
: ^^^^
|
|
5 | }
|
|
`----
|
|
x Ident
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:4:1]
|
|
3 | prod: --fn(100px);
|
|
4 | prod: --fn--fn(100px);
|
|
: ^^^^
|
|
5 | }
|
|
`----
|
|
x ComponentValue
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:4:1]
|
|
3 | prod: --fn(100px);
|
|
4 | prod: --fn--fn(100px);
|
|
: ^^^^^^^^^^^^^^^
|
|
5 | }
|
|
`----
|
|
x Function
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:4:1]
|
|
3 | prod: --fn(100px);
|
|
4 | prod: --fn--fn(100px);
|
|
: ^^^^^^^^^^^^^^^
|
|
5 | }
|
|
`----
|
|
x DashedIdent
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:4:1]
|
|
3 | prod: --fn(100px);
|
|
4 | prod: --fn--fn(100px);
|
|
: ^^^^^^^^
|
|
5 | }
|
|
`----
|
|
x ComponentValue
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:4:1]
|
|
3 | prod: --fn(100px);
|
|
4 | prod: --fn--fn(100px);
|
|
: ^^^^^
|
|
5 | }
|
|
`----
|
|
x Dimension { dimension: DimensionToken { value: 100.0, raw_value: "100", unit: "px", type_flag: Integer, raw_unit: "px" } }
|
|
,-[$DIR/tests/fixture/function/unknown/input.css:4:1]
|
|
3 | prod: --fn(100px);
|
|
4 | prod: --fn--fn(100px);
|
|
: ^^^^^
|
|
5 | }
|
|
`----
|