Skip to main content

oak_msil/language/
mod.rs

1use oak_core::{Language, LanguageCategory};
2use serde::{Deserialize, Serialize};
3
4/// MSIL 语言实现
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
6pub struct MsilLanguage {
7    /// 是否允许扩展指令
8    pub extended_instructions: bool,
9    /// 是否允许调试信息
10    pub debug_info: bool,
11    /// 是否严格模式
12    pub strict_mode: bool,
13}
14
15impl MsilLanguage {
16    /// 创建新的 MSIL 语言实例
17    pub fn new() -> Self {
18        Self::default()
19    }
20
21    /// 创建标准 MSIL 语言实例
22    pub fn standard() -> Self {
23        Self { extended_instructions: false, debug_info: false, strict_mode: true }
24    }
25
26    /// 创建扩展 MSIL 语言实例
27    pub fn extended() -> Self {
28        Self { extended_instructions: true, debug_info: true, strict_mode: false }
29    }
30}
31
32impl Default for MsilLanguage {
33    fn default() -> Self {
34        Self { extended_instructions: false, debug_info: false, strict_mode: false }
35    }
36}
37
38impl Language for MsilLanguage {
39    const NAME: &'static str = "msil";
40    const CATEGORY: LanguageCategory = LanguageCategory::Programming;
41
42    type TokenType = crate::kind::MsilSyntaxKind;
43    type ElementType = crate::kind::MsilSyntaxKind;
44    type TypedRoot = crate::ast::MsilRoot;
45}