зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1716869 - Part 2, vendor the latest wat r=rhunt
Depends on D118082 Differential Revision: https://phabricator.services.mozilla.com/D118083
This commit is contained in:
Родитель
2647ce5160
Коммит
539a058be7
|
@ -5561,18 +5561,18 @@ checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65"
|
|||
|
||||
[[package]]
|
||||
name = "wast"
|
||||
version = "35.0.2"
|
||||
version = "36.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68"
|
||||
checksum = "8b5d7ba374a364571da1cb0a379a3dc302582a2d9937a183bfe35b68ad5bb9c4"
|
||||
dependencies = [
|
||||
"leb128",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wat"
|
||||
version = "1.0.37"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02"
|
||||
checksum = "16383df7f0e3901484c2dda6294ed6895caa3627ce4f6584141dcf30a33a23e6"
|
||||
dependencies = [
|
||||
"wast",
|
||||
]
|
||||
|
|
|
@ -20,5 +20,5 @@ smoosh = ['jsrust_shared/smoosh']
|
|||
jsrust_shared = { path = "./shared" }
|
||||
# Workaround for https://github.com/rust-lang/rust/issues/58393
|
||||
mozglue-static = { path = "../../../mozglue/static/rust" }
|
||||
wat = { version = "1.0.37" }
|
||||
wat = { version = "1.0.38" }
|
||||
wasmparser = { version = "0.78.2" }
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -13,7 +13,7 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "wast"
|
||||
version = "35.0.2"
|
||||
version = "36.0.0"
|
||||
authors = ["Alex Crichton <alex@alexcrichton.com>"]
|
||||
description = "Customizable Rust parsers for the WebAssembly Text formats WAT and WAST\n"
|
||||
homepage = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wast"
|
||||
|
|
|
@ -0,0 +1,220 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
--- LLVM Exceptions to the Apache 2.0 License ----
|
||||
|
||||
As an exception, if, as a result of your compiling your source code, portions
|
||||
of this Software are embedded into an Object form of such source code, you
|
||||
may redistribute such embedded portions in such Object form without complying
|
||||
with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
|
||||
|
||||
In addition, if you combine or link compiled forms of this Software with
|
||||
software that is licensed under the GPLv2 ("Combined Software") and if a
|
||||
court of competent jurisdiction determines that the patent provision (Section
|
||||
3), the indemnity provision (Section 9) or other Section of the License
|
||||
conflicts with the conditions of the GPLv2, you may retroactively and
|
||||
prospectively choose to deem waived or otherwise exclude such Section(s) of
|
||||
the License, but only in their entirety and only with respect to the Combined
|
||||
Software.
|
||||
|
|
@ -12,6 +12,8 @@ pub struct Event<'a> {
|
|||
pub exports: ast::InlineExport<'a>,
|
||||
/// The type of event that is defined.
|
||||
pub ty: EventType<'a>,
|
||||
/// What kind of event this is defined as.
|
||||
pub kind: EventKind<'a>,
|
||||
}
|
||||
|
||||
/// Listing of various types of events that can be defined in a wasm module.
|
||||
|
@ -22,17 +24,36 @@ pub enum EventType<'a> {
|
|||
Exception(ast::TypeUse<'a, ast::FunctionType<'a>>),
|
||||
}
|
||||
|
||||
/// Different kinds of events that can be defined in a module.
|
||||
#[derive(Debug)]
|
||||
pub enum EventKind<'a> {
|
||||
/// An event which is actually defined as an import, such as:
|
||||
///
|
||||
/// ```text
|
||||
/// (event (type 0) (import "foo" "bar"))
|
||||
/// ```
|
||||
Import(ast::InlineImport<'a>),
|
||||
|
||||
/// An event defined inline in the module itself
|
||||
Inline(),
|
||||
}
|
||||
|
||||
impl<'a> Parse<'a> for Event<'a> {
|
||||
fn parse(parser: Parser<'a>) -> Result<Self> {
|
||||
let span = parser.parse::<kw::event>()?.0;
|
||||
let id = parser.parse()?;
|
||||
let exports = parser.parse()?;
|
||||
let ty = parser.parse()?;
|
||||
let (ty, kind) = if let Some(import) = parser.parse()? {
|
||||
(parser.parse()?, EventKind::Import(import))
|
||||
} else {
|
||||
(parser.parse()?, EventKind::Inline())
|
||||
};
|
||||
Ok(Event {
|
||||
span,
|
||||
id,
|
||||
exports,
|
||||
ty,
|
||||
kind,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,8 +84,8 @@ enum If<'a> {
|
|||
enum Try<'a> {
|
||||
/// Next thing to parse is the `do` block.
|
||||
Do(Instruction<'a>),
|
||||
/// Next thing to parse is `catch`/`catch_all`, `unwind`, or `delegate`.
|
||||
CatchUnwindOrDelegate,
|
||||
/// Next thing to parse is `catch`/`catch_all`, or `delegate`.
|
||||
CatchOrDelegate,
|
||||
/// Next thing to parse is a `catch` block or `catch_all`.
|
||||
Catch,
|
||||
/// Finished parsing like the `End` case, but does not push `end` opcode.
|
||||
|
@ -193,17 +193,12 @@ impl<'a> ExpressionParser<'a> {
|
|||
self.instrs.push(Instruction::End(None));
|
||||
}
|
||||
|
||||
// Both `do` and `catch` are required in a `try` statement, so
|
||||
// we will signal those errors here. Otherwise, terminate with
|
||||
// The `do` clause is required in a `try` statement, so
|
||||
// we will signal that error here. Otherwise, terminate with
|
||||
// an `end` or `delegate` instruction.
|
||||
Level::Try(Try::Do(_)) => {
|
||||
return Err(parser.error("previous `try` had no `do`"));
|
||||
}
|
||||
Level::Try(Try::CatchUnwindOrDelegate) => {
|
||||
return Err(parser.error(
|
||||
"previous `try` had no `catch`, `catch_all`, `unwind`, or `delegate`",
|
||||
));
|
||||
}
|
||||
Level::Try(Try::Delegate) => {}
|
||||
Level::Try(_) => {
|
||||
self.instrs.push(Instruction::End(None));
|
||||
|
@ -335,7 +330,7 @@ impl<'a> ExpressionParser<'a> {
|
|||
if parser.parse::<Option<kw::r#do>>()?.is_some() {
|
||||
// The state is advanced here only if the parse succeeds in
|
||||
// order to strictly require the keyword.
|
||||
*i = Try::CatchUnwindOrDelegate;
|
||||
*i = Try::CatchOrDelegate;
|
||||
self.stack.push(Level::TryArm);
|
||||
return Ok(true);
|
||||
}
|
||||
|
@ -346,7 +341,7 @@ impl<'a> ExpressionParser<'a> {
|
|||
}
|
||||
|
||||
// After a try's `do`, there are several possible kinds of handlers.
|
||||
if let Try::CatchUnwindOrDelegate = i {
|
||||
if let Try::CatchOrDelegate = i {
|
||||
// `catch` may be followed by more `catch`s or `catch_all`.
|
||||
if parser.parse::<Option<kw::catch>>()?.is_some() {
|
||||
let evt = parser.parse::<ast::Index<'a>>()?;
|
||||
|
@ -362,13 +357,6 @@ impl<'a> ExpressionParser<'a> {
|
|||
self.stack.push(Level::TryArm);
|
||||
return Ok(true);
|
||||
}
|
||||
// `unwind` is similar to `catch_all`.
|
||||
if parser.parse::<Option<kw::unwind>>()?.is_some() {
|
||||
self.instrs.push(Instruction::Unwind);
|
||||
*i = Try::End;
|
||||
self.stack.push(Level::TryArm);
|
||||
return Ok(true);
|
||||
}
|
||||
// `delegate` has an index, and also ends the block like `end`.
|
||||
if parser.parse::<Option<kw::delegate>>()?.is_some() {
|
||||
let depth = parser.parse::<ast::Index<'a>>()?;
|
||||
|
@ -379,7 +367,7 @@ impl<'a> ExpressionParser<'a> {
|
|||
Paren::Right => return Ok(true),
|
||||
}
|
||||
}
|
||||
return Ok(false);
|
||||
return Err(parser.error("expected a `catch`, `catch_all`, or `delegate`"));
|
||||
}
|
||||
|
||||
if let Try::Catch = i {
|
||||
|
@ -1132,7 +1120,6 @@ instructions! {
|
|||
Catch(ast::Index<'a>) : [0x07] : "catch",
|
||||
Throw(ast::Index<'a>) : [0x08] : "throw",
|
||||
Rethrow(ast::Index<'a>) : [0x09] : "rethrow",
|
||||
Unwind : [0x0a] : "unwind",
|
||||
Delegate(ast::Index<'a>) : [0x18] : "delegate",
|
||||
CatchAll : [0x19] : "catch_all",
|
||||
}
|
||||
|
@ -1311,6 +1298,8 @@ fn idx_zero<T>(span: ast::Span, mk_kind: fn(ast::Span) -> T) -> ast::ItemRef<'st
|
|||
kind: mk_kind(span),
|
||||
idx: ast::Index::Num(0, span),
|
||||
exports: Vec::new(),
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,6 +145,8 @@ impl<'a> Parse<'a> for Data<'a> {
|
|||
kind: kw::memory(parser.prev_span()),
|
||||
idx: ast::Index::Num(0, span),
|
||||
exports: Vec::new(),
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: false,
|
||||
}
|
||||
};
|
||||
let offset = parser.parens(|parser| {
|
||||
|
|
|
@ -419,7 +419,6 @@ pub mod kw {
|
|||
custom_keyword!(table);
|
||||
custom_keyword!(then);
|
||||
custom_keyword!(r#try = "try");
|
||||
custom_keyword!(unwind);
|
||||
custom_keyword!(v128);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ pub use crate::resolve::Names;
|
|||
/// This is the top-level type which you'll frequently parse when working with
|
||||
/// this crate. A `*.wat` file is either one `module` s-expression or a sequence
|
||||
/// of s-expressions that are module fields.
|
||||
#[derive(Debug)]
|
||||
pub struct Wat<'a> {
|
||||
#[allow(missing_docs)]
|
||||
pub module: Module<'a>,
|
||||
|
@ -36,6 +37,7 @@ impl<'a> Parse<'a> for Wat<'a> {
|
|||
}
|
||||
|
||||
/// A parsed WebAssembly module.
|
||||
#[derive(Debug)]
|
||||
pub struct Module<'a> {
|
||||
/// Where this `module` was defined
|
||||
pub span: ast::Span,
|
||||
|
@ -48,6 +50,7 @@ pub struct Module<'a> {
|
|||
}
|
||||
|
||||
/// The different kinds of ways to define a module.
|
||||
#[derive(Debug)]
|
||||
pub enum ModuleKind<'a> {
|
||||
/// A module defined in the textual s-expression format.
|
||||
Text(Vec<ModuleField<'a>>),
|
||||
|
|
|
@ -146,6 +146,8 @@ impl<'a> Parse<'a> for Elem<'a> {
|
|||
kind: kw::table(parser.prev_span()),
|
||||
idx: ast::Index::Num(0, span),
|
||||
exports: Vec::new(),
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: false,
|
||||
}
|
||||
};
|
||||
let offset = parser.parens(|parser| {
|
||||
|
|
|
@ -232,6 +232,8 @@ pub enum ItemRef<'a, K> {
|
|||
kind: K,
|
||||
idx: Index<'a>,
|
||||
exports: Vec<&'a str>,
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: bool,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -266,7 +268,13 @@ impl<'a, K: Parse<'a>> Parse<'a> for ItemRef<'a, K> {
|
|||
while !parser.is_empty() {
|
||||
exports.push(parser.parse()?);
|
||||
}
|
||||
Ok(ItemRef::Item { kind, idx, exports })
|
||||
Ok(ItemRef::Item {
|
||||
kind,
|
||||
idx,
|
||||
exports,
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: false,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -299,6 +307,8 @@ where
|
|||
kind: K::default(),
|
||||
idx: parser.parse()?,
|
||||
exports: Vec::new(),
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: false,
|
||||
}))
|
||||
} else {
|
||||
Ok(IndexOrRef(parser.parse()?))
|
||||
|
|
|
@ -777,6 +777,8 @@ impl<'a, T> TypeUse<'a, T> {
|
|||
idx,
|
||||
kind: kw::r#type::default(),
|
||||
exports: Vec::new(),
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: true,
|
||||
}),
|
||||
inline: None,
|
||||
}
|
||||
|
|
|
@ -509,7 +509,15 @@ impl<T> Encode for ItemRef<'_, T> {
|
|||
fn encode(&self, e: &mut Vec<u8>) {
|
||||
match self {
|
||||
ItemRef::Outer { .. } => panic!("should be expanded previously"),
|
||||
ItemRef::Item { idx, exports, .. } => {
|
||||
ItemRef::Item {
|
||||
idx,
|
||||
exports,
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited,
|
||||
..
|
||||
} => {
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
assert!(*visited);
|
||||
assert!(exports.is_empty());
|
||||
idx.encode(e);
|
||||
}
|
||||
|
@ -1122,6 +1130,10 @@ impl Encode for Custom<'_> {
|
|||
impl Encode for Event<'_> {
|
||||
fn encode(&self, e: &mut Vec<u8>) {
|
||||
self.ty.encode(e);
|
||||
match &self.kind {
|
||||
EventKind::Inline() => {}
|
||||
_ => panic!("EventKind should be inline during encoding"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,10 +144,15 @@ impl<'a> Expander<'a> {
|
|||
NestedModuleKind::Inline { fields } => run(fields),
|
||||
},
|
||||
|
||||
ModuleField::Custom(_)
|
||||
| ModuleField::Memory(_)
|
||||
| ModuleField::Table(_)
|
||||
| ModuleField::Type(_) => {}
|
||||
ModuleField::Type(t) => match &mut t.def {
|
||||
TypeDef::Func(f) => f.expand(self),
|
||||
TypeDef::Struct(_) => {}
|
||||
TypeDef::Array(_) => {}
|
||||
TypeDef::Module(m) => m.expand(self),
|
||||
TypeDef::Instance(i) => i.expand(self),
|
||||
},
|
||||
|
||||
ModuleField::Custom(_) | ModuleField::Memory(_) | ModuleField::Table(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,14 +164,19 @@ impl<'a> Expander<'a> {
|
|||
ItemKind::Table(_) => {}
|
||||
ItemKind::Memory(_) => {}
|
||||
ItemKind::Global(_) => {}
|
||||
ItemKind::Event(_) => {}
|
||||
ItemKind::Event(t) => match t {
|
||||
EventType::Exception(t) => self.expand_type_use(t),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn expand_type_use<T>(&mut self, ty: &mut TypeUse<'a, T>) {
|
||||
fn expand_type_use<T: Expand<'a>>(&mut self, ty: &mut TypeUse<'a, T>) {
|
||||
if let Some(index) = &mut ty.index {
|
||||
self.expand(index);
|
||||
}
|
||||
if let Some(inline) = &mut ty.inline {
|
||||
inline.expand(self);
|
||||
}
|
||||
}
|
||||
|
||||
fn expand_expr(&mut self, expr: &mut Expression<'a>) {
|
||||
|
@ -209,6 +219,8 @@ impl<'a> Expander<'a> {
|
|||
|
||||
Block(bt) | If(bt) | Loop(bt) | Try(bt) => self.expand_type_use(&mut bt.ty),
|
||||
|
||||
FuncBind(t) => self.expand_type_use(&mut t.ty),
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -242,9 +254,21 @@ impl<'a> Expander<'a> {
|
|||
kind: *kind,
|
||||
idx,
|
||||
exports: Vec::new(),
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: true,
|
||||
};
|
||||
}
|
||||
ItemRef::Item { kind, idx, exports } => {
|
||||
ItemRef::Item {
|
||||
kind,
|
||||
idx,
|
||||
exports,
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited,
|
||||
} => {
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
{
|
||||
*visited = true;
|
||||
}
|
||||
let mut cur = *idx;
|
||||
let len = exports.len();
|
||||
for (i, export) in exports.drain(..).enumerate() {
|
||||
|
@ -269,6 +293,8 @@ impl<'a> Expander<'a> {
|
|||
kind: kw::instance(span),
|
||||
idx: cur,
|
||||
exports: Vec::new(),
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: true,
|
||||
},
|
||||
export,
|
||||
},
|
||||
|
@ -282,3 +308,30 @@ impl<'a> Expander<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait Expand<'a> {
|
||||
fn expand(&mut self, cx: &mut Expander<'a>);
|
||||
}
|
||||
|
||||
impl<'a> Expand<'a> for FunctionType<'a> {
|
||||
fn expand(&mut self, _cx: &mut Expander<'a>) {}
|
||||
}
|
||||
|
||||
impl<'a> Expand<'a> for ModuleType<'a> {
|
||||
fn expand(&mut self, cx: &mut Expander<'a>) {
|
||||
for i in self.imports.iter_mut() {
|
||||
cx.expand_item_sig(&mut i.item);
|
||||
}
|
||||
for e in self.exports.iter_mut() {
|
||||
cx.expand_item_sig(&mut e.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Expand<'a> for InstanceType<'a> {
|
||||
fn expand(&mut self, cx: &mut Expander<'a>) {
|
||||
for e in self.exports.iter_mut() {
|
||||
cx.expand_item_sig(&mut e.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,11 @@ pub fn run(fields: &mut Vec<ModuleField>) {
|
|||
kind: DataKind::Active {
|
||||
memory: item_ref(kw::memory(m.span), id),
|
||||
offset: Expression {
|
||||
instrs: Box::new([Instruction::I32Const(0)]),
|
||||
instrs: Box::new([if is_32 {
|
||||
Instruction::I32Const(0)
|
||||
} else {
|
||||
Instruction::I64Const(0)
|
||||
}]),
|
||||
},
|
||||
},
|
||||
data,
|
||||
|
@ -172,6 +176,22 @@ pub fn run(fields: &mut Vec<ModuleField>) {
|
|||
for name in e.exports.names.drain(..) {
|
||||
to_append.push(export(e.span, name, ExportKind::Event, &mut e.id));
|
||||
}
|
||||
match e.kind {
|
||||
EventKind::Import(import) => {
|
||||
*item = ModuleField::Import(Import {
|
||||
span: e.span,
|
||||
module: import.module,
|
||||
field: import.field,
|
||||
item: ItemSig {
|
||||
span: e.span,
|
||||
id: e.id,
|
||||
name: None,
|
||||
kind: ItemKind::Event(e.ty.clone()),
|
||||
},
|
||||
});
|
||||
}
|
||||
EventKind::Inline { .. } => {}
|
||||
}
|
||||
}
|
||||
|
||||
ModuleField::Instance(i) => {
|
||||
|
@ -266,5 +286,7 @@ fn item_ref<'a, K>(kind: K, id: impl Into<Index<'a>>) -> ItemRef<'a, K> {
|
|||
kind,
|
||||
idx: id.into(),
|
||||
exports: Vec::new(),
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,19 +55,20 @@ pub fn resolve<'a>(module: &mut Module<'a>) -> Result<Names<'a>, Error> {
|
|||
|
||||
// With a canonical form of imports make sure that imports are all listed
|
||||
// first.
|
||||
for i in 1..fields.len() {
|
||||
let span = match &fields[i] {
|
||||
ModuleField::Import(i) => i.span,
|
||||
let mut last = None;
|
||||
for field in fields.iter() {
|
||||
match field {
|
||||
ModuleField::Import(i) => {
|
||||
if let Some(name) = last {
|
||||
return Err(Error::new(i.span, format!("import after {}", name)));
|
||||
}
|
||||
}
|
||||
ModuleField::Memory(_) => last = Some("memory"),
|
||||
ModuleField::Func(_) => last = Some("function"),
|
||||
ModuleField::Table(_) => last = Some("table"),
|
||||
ModuleField::Global(_) => last = Some("global"),
|
||||
_ => continue,
|
||||
};
|
||||
let name = match &fields[i - 1] {
|
||||
ModuleField::Memory(_) => "memory",
|
||||
ModuleField::Func(_) => "function",
|
||||
ModuleField::Table(_) => "table",
|
||||
ModuleField::Global(_) => "global",
|
||||
_ => continue,
|
||||
};
|
||||
return Err(Error::new(span, format!("import after {}", name)));
|
||||
}
|
||||
}
|
||||
|
||||
// Expand all `TypeUse` annotations so all necessary `type` nodes are
|
||||
|
|
|
@ -430,7 +430,22 @@ impl<'a> Resolver<'a> {
|
|||
K: Into<ExportKind> + Copy,
|
||||
{
|
||||
match item {
|
||||
ItemRef::Item { idx, kind, exports } => {
|
||||
ItemRef::Item {
|
||||
idx,
|
||||
kind,
|
||||
exports,
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited,
|
||||
} => {
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
{
|
||||
if !*visited {
|
||||
return Err(Error::new(
|
||||
idx.span(),
|
||||
format!("BUG: this index wasn't visited"),
|
||||
));
|
||||
}
|
||||
}
|
||||
debug_assert!(exports.len() == 0);
|
||||
self.resolve(
|
||||
idx,
|
||||
|
|
|
@ -244,6 +244,8 @@ impl<'a> Expander<'a> {
|
|||
idx,
|
||||
kind: kw::r#type(span),
|
||||
exports: Vec::new(),
|
||||
#[cfg(wast_check_exhaustive)]
|
||||
visited: true,
|
||||
});
|
||||
return idx;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"d7c42a752448eafe3bbd07c9c36af786d035e1dc2853a42793efa4d23f4822bc","README.md":"6653a386a2210f0f7e36964f15214bc441e2c723c42867dfe90dfcedcd301814","src/lib.rs":"b272ee59a5a1b713625cdf4443e5055d888966b9ec78014e01087895e9fc09bc"},"package":"8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02"}
|
||||
{"files":{"Cargo.toml":"27c1c0a14f9e28e8adef321408dc76a9e2c10fe658c91c0e7a74da453ed46dd5","LICENSE":"268872b9816f90fd8e85db5a28d33f8150ebb8dd016653fb39ef1f94f2686bc5","README.md":"86861dc59a785c0eb143e1798668e29076e25f69d7e802b5425054862c635be3","src/lib.rs":"b272ee59a5a1b713625cdf4443e5055d888966b9ec78014e01087895e9fc09bc"},"package":"16383df7f0e3901484c2dda6294ed6895caa3627ce4f6584141dcf30a33a23e6"}
|
|
@ -13,7 +13,7 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "wat"
|
||||
version = "1.0.37"
|
||||
version = "1.0.38"
|
||||
authors = ["Alex Crichton <alex@alexcrichton.com>"]
|
||||
description = "Rust parser for the WebAssembly Text format, WAT\n"
|
||||
homepage = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wat"
|
||||
|
@ -22,4 +22,4 @@ readme = "README.md"
|
|||
license = "Apache-2.0 WITH LLVM-exception"
|
||||
repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wat"
|
||||
[dependencies.wast]
|
||||
version = "35.0.0"
|
||||
version = "36.0.0"
|
||||
|
|
|
@ -0,0 +1,220 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
--- LLVM Exceptions to the Apache 2.0 License ----
|
||||
|
||||
As an exception, if, as a result of your compiling your source code, portions
|
||||
of this Software are embedded into an Object form of such source code, you
|
||||
may redistribute such embedded portions in such Object form without complying
|
||||
with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
|
||||
|
||||
In addition, if you combine or link compiled forms of this Software with
|
||||
software that is licensed under the GPLv2 ("Combined Software") and if a
|
||||
court of competent jurisdiction determines that the patent provision (Section
|
||||
3), the indemnity provision (Section 9) or other Section of the License
|
||||
conflicts with the conditions of the GPLv2, you may retroactively and
|
||||
prospectively choose to deem waived or otherwise exclude such Section(s) of
|
||||
the License, but only in their entirety and only with respect to the Combined
|
||||
Software.
|
||||
|
|
@ -65,7 +65,7 @@ break if the upstream spec changes.
|
|||
# License
|
||||
|
||||
This project is licensed under the Apache 2.0 license with the LLVM exception.
|
||||
See [LICENSE](../../LICENSE) for more details.
|
||||
See [LICENSE](LICENSE) for more details.
|
||||
|
||||
### Contribution
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче