Sha256: 07a090fa366769fd30690d85ea1c73260929dd07c96d9938a6597a263d6c6f09

Contents?: true

Size: 1.3 KB

Versions: 38

Compression:

Stored size: 1.3 KB

Contents

use crate::ast::{self, kw};
use crate::parser::{Parse, Parser, Result};

/// A WebAssembly event directive, part of the exception handling proposal.
#[derive(Debug)]
pub struct Event<'a> {
    /// Where this event was defined
    pub span: ast::Span,
    /// An optional name by which to refer to this event in name resolution.
    pub id: Option<ast::Id<'a>>,
    /// Optional export directives for this event.
    pub exports: ast::InlineExport<'a>,
    /// The type of event that is defined.
    pub ty: EventType<'a>,
}

/// Listing of various types of events that can be defined in a wasm module.
#[derive(Clone, Debug)]
pub enum EventType<'a> {
    /// An exception event, where the payload is the type signature of the event
    /// (constructor parameters, etc).
    Exception(ast::TypeUse<'a, ast::FunctionType<'a>>),
}

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()?;
        Ok(Event {
            span,
            id,
            exports,
            ty,
        })
    }
}

impl<'a> Parse<'a> for EventType<'a> {
    fn parse(parser: Parser<'a>) -> Result<Self> {
        Ok(EventType::Exception(parser.parse()?))
    }
}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-28.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-27.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-26.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-25.0.2 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-25.0.1 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-25.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-24.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-23.0.2 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-22.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-21.0.1 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-20.0.2 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-20.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-18.0.3 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-17.0.1 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-17.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-16.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-15.0.1 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-15.0.0 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs
wasmtime-14.0.4 ./ext/cargo-vendor/wast-35.0.2/src/ast/event.rs