wat_service 0.9.0

WebAssembly Text Format language service.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::{Diagnostic, FastPlainInstr};
use crate::data_set::INSTR_OP_CODES;

const DIAGNOSTIC_CODE: &str = "unknown-instr";

pub fn check(instr: &FastPlainInstr) -> Option<Diagnostic> {
    if INSTR_OP_CODES.contains_key(instr.name) {
        None
    } else {
        Some(Diagnostic {
            range: instr.name_range,
            code: DIAGNOSTIC_CODE.into(),
            message: format!("unknown instruction `{}`", instr.name),
            ..Default::default()
        })
    }
}