mdgaziur001

yal(wtf!)

Nov 6th, 2022
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 266.82 KB | None | 0 0
  1. #![feature(prelude_import)]
  2. #![feature(fmt_internals)]
  3. #![feature(fmt_helpers_for_derive)]
  4. #![feature(print_internals)]
  5. #![feature(core_intrinsics)]
  6. #![feature(core_panic)]
  7. #![feature(derive_clone_copy)]
  8. #![feature(structural_match)]
  9. #![feature(no_coverage)]
  10. #![feature(derive_eq)]
  11. #![feature(rustc_attrs)]
  12. #[prelude_import]
  13. use std::prelude::rust_2021::*;
  14. #[macro_use]
  15. extern crate std;
  16. extern crate alloc;
  17. use crate::interp::Interpreter;
  18. use crate::session::Session;
  19. mod analyzer {
  20.     use crate::ast::{Stmt, StmtContainer};
  21.     use crate::diagnostics::{Diagnostic, ErrorCode, Severity, Span};
  22.     use std::cell::RefCell;
  23.     pub struct Analyzer<'tcx> {
  24.        ast: &'tcx [StmtContainer],
  25.         context: RefCell<AnalyzerContext>,
  26.     }
  27.     struct AnalyzerContext {
  28.         diagnostics: Vec<Diagnostic>,
  29.         context: Vec<Context>,
  30.     }
  31.     #[automatically_derived]
  32.     impl ::core::fmt::Debug for AnalyzerContext {
  33.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  34.             ::core::fmt::Formatter::debug_struct_field2_finish(
  35.                 f,
  36.                 "AnalyzerContext",
  37.                 "diagnostics",
  38.                 &&self.diagnostics,
  39.                 "context",
  40.                 &&self.context,
  41.             )
  42.         }
  43.     }
  44.     #[automatically_derived]
  45.     impl ::core::clone::Clone for AnalyzerContext {
  46.         #[inline]
  47.         fn clone(&self) -> AnalyzerContext {
  48.             AnalyzerContext {
  49.                 diagnostics: ::core::clone::Clone::clone(&self.diagnostics),
  50.                 context: ::core::clone::Clone::clone(&self.context),
  51.             }
  52.         }
  53.     }
  54.     impl<'tcx> Analyzer<'tcx> {
  55.         pub fn new(ast: &'tcx [StmtContainer]) -> Self {
  56.            Self {
  57.                ast,
  58.                context: RefCell::new(AnalyzerContext {
  59.                    diagnostics: alloc::vec::Vec::new(),
  60.                    context: <[_]>::into_vec(
  61.                        #[rustc_box]
  62.                        alloc::boxed::Box::new([Context::Root]),
  63.                    ),
  64.                }),
  65.            }
  66.        }
  67.        pub fn analyze(&self) {
  68.            for stmt in self.ast {
  69.                self.analyze_stmt(stmt);
  70.            }
  71.        }
  72.        fn get_block_stmt<'a>(&'a self, stmt: &'a Stmt) -> &'a [StmtContainer] {
  73.            match stmt {
  74.                Stmt::Block(stmts) => stmts,
  75.                _ => ::core::panicking::panic_fmt(::core::fmt::Arguments::new_v1(
  76.                    &["Cannot get block stmt from non block stmt"],
  77.                    &[],
  78.                )),
  79.            }
  80.        }
  81.        fn analyze_stmt(&self, stmt: &StmtContainer) {
  82.            match &stmt.stmt {
  83.                Stmt::Fun(fun_stmt) => {
  84.                    self.context
  85.                        .borrow_mut()
  86.                        .context
  87.                        .push(Context::Fun(stmt.span));
  88.                    for stmt in self.get_block_stmt(&fun_stmt.body.stmt) {
  89.                        self.analyze_stmt(stmt);
  90.                    }
  91.                    self.context.borrow_mut().context.pop();
  92.                }
  93.                Stmt::Data(_) => {}
  94.                Stmt::Methods(method_stmt) => {
  95.                    for method in &method_stmt.methods {
  96.                        self.context
  97.                            .borrow_mut()
  98.                            .context
  99.                            .push(Context::Method(method.span));
  100.                        self.analyze_stmt(method);
  101.                        self.context.borrow_mut().context.pop();
  102.                    }
  103.                }
  104.                Stmt::If(if_stmt) => {
  105.                    let body = self.get_block_stmt(&if_stmt.block.stmt);
  106.                    for stmt in body {
  107.                        self.analyze_stmt(stmt);
  108.                    }
  109.                    if let Some(then) = &if_stmt.then {
  110.                        self.analyze_stmt(then);
  111.                    }
  112.                    if let Some(else_) = &if_stmt.else_ {
  113.                        let body = self.get_block_stmt(match &else_.stmt {
  114.                            Stmt::If(if_stmt) => &if_stmt.block.stmt,
  115.                            _ => {
  116.                                ::core::panicking::panic("internal error: entered unreachable code")
  117.                            }
  118.                        });
  119.                        for stmt in body {
  120.                            self.analyze_stmt(stmt);
  121.                        }
  122.                    }
  123.                }
  124.                Stmt::Loop(loop_stmt) => {
  125.                    self.context
  126.                        .borrow_mut()
  127.                        .context
  128.                        .push(Context::Loop(stmt.span));
  129.                    for stmt in self.get_block_stmt(&loop_stmt.stmt) {
  130.                        self.analyze_stmt(stmt);
  131.                    }
  132.                    self.context.borrow_mut().context.pop();
  133.                }
  134.                Stmt::Iter(iter_stmt) => {
  135.                    self.context
  136.                        .borrow_mut()
  137.                        .context
  138.                        .push(Context::Loop(stmt.span));
  139.                    for stmt in self.get_block_stmt(&iter_stmt.block.stmt) {
  140.                        self.analyze_stmt(stmt);
  141.                    }
  142.                    self.context.borrow_mut().context.pop();
  143.                }
  144.                Stmt::Continue | Stmt::Break => {
  145.                    if !match self.context.borrow_mut().context.last() {
  146.                        Some(Context::Loop(_)) => true,
  147.                        _ => false,
  148.                    } {
  149.                        self.context.borrow_mut().diagnostics.push(Diagnostic {
  150.                            severity: Severity::Error,
  151.                            code: ErrorCode::InvalidLoopControl,
  152.                            message: String::from("Found `continue` or `break` outside loop"),
  153.                            span: stmt.span,
  154.                        });
  155.                    }
  156.                }
  157.                _ => (),
  158.            }
  159.        }
  160.        pub fn get_diagnostics(self) -> Vec<Diagnostic> {
  161.            self.context.into_inner().diagnostics
  162.        }
  163.    }
  164.    enum Context {
  165.        Root,
  166.        Fun(Span),
  167.        Method(Span),
  168.        Loop(Span),
  169.    }
  170.    #[automatically_derived]
  171.    impl ::core::fmt::Debug for Context {
  172.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  173.            match self {
  174.                Context::Root => ::core::fmt::Formatter::write_str(f, "Root"),
  175.                Context::Fun(__self_0) => {
  176.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Fun", &__self_0)
  177.                }
  178.                Context::Method(__self_0) => {
  179.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Method", &__self_0)
  180.                }
  181.                Context::Loop(__self_0) => {
  182.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Loop", &__self_0)
  183.                }
  184.            }
  185.        }
  186.    }
  187.    #[automatically_derived]
  188.    impl ::core::clone::Clone for Context {
  189.        #[inline]
  190.        fn clone(&self) -> Context {
  191.            let _: ::core::clone::AssertParamIsClone<Span>;
  192.            *self
  193.        }
  194.    }
  195.    #[automatically_derived]
  196.    impl ::core::marker::Copy for Context {}
  197.    #[automatically_derived]
  198.    impl ::core::cmp::Ord for Context {
  199.        #[inline]
  200.        fn cmp(&self, other: &Context) -> ::core::cmp::Ordering {
  201.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  202.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  203.            match ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) {
  204.                ::core::cmp::Ordering::Equal => match (self, other) {
  205.                    (Context::Fun(__self_0), Context::Fun(__arg1_0)) => {
  206.                        ::core::cmp::Ord::cmp(__self_0, __arg1_0)
  207.                    }
  208.                    (Context::Method(__self_0), Context::Method(__arg1_0)) => {
  209.                        ::core::cmp::Ord::cmp(__self_0, __arg1_0)
  210.                    }
  211.                    (Context::Loop(__self_0), Context::Loop(__arg1_0)) => {
  212.                        ::core::cmp::Ord::cmp(__self_0, __arg1_0)
  213.                    }
  214.                    _ => ::core::cmp::Ordering::Equal,
  215.                },
  216.                cmp => cmp,
  217.            }
  218.        }
  219.    }
  220.    #[automatically_derived]
  221.    impl ::core::cmp::PartialOrd for Context {
  222.        #[inline]
  223.        fn partial_cmp(&self, other: &Context) -> ::core::option::Option<::core::cmp::Ordering> {
  224.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  225.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  226.            match ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag) {
  227.                ::core::option::Option::Some(::core::cmp::Ordering::Equal) => match (self, other) {
  228.                    (Context::Fun(__self_0), Context::Fun(__arg1_0)) => {
  229.                        ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0)
  230.                    }
  231.                    (Context::Method(__self_0), Context::Method(__arg1_0)) => {
  232.                        ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0)
  233.                    }
  234.                    (Context::Loop(__self_0), Context::Loop(__arg1_0)) => {
  235.                        ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0)
  236.                    }
  237.                    _ => ::core::option::Option::Some(::core::cmp::Ordering::Equal),
  238.                },
  239.                cmp => cmp,
  240.            }
  241.        }
  242.    }
  243.    impl ::core::marker::StructuralEq for Context {}
  244.    #[automatically_derived]
  245.    impl ::core::cmp::Eq for Context {
  246.        #[inline]
  247.        #[doc(hidden)]
  248.        #[no_coverage]
  249.        fn assert_receiver_is_total_eq(&self) -> () {
  250.            let _: ::core::cmp::AssertParamIsEq<Span>;
  251.        }
  252.    }
  253.    impl ::core::marker::StructuralPartialEq for Context {}
  254.    #[automatically_derived]
  255.    impl ::core::cmp::PartialEq for Context {
  256.        #[inline]
  257.        fn eq(&self, other: &Context) -> bool {
  258.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  259.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  260.            __self_tag == __arg1_tag
  261.                && match (self, other) {
  262.                    (Context::Fun(__self_0), Context::Fun(__arg1_0)) => *__self_0 == *__arg1_0,
  263.                    (Context::Method(__self_0), Context::Method(__arg1_0)) => {
  264.                        *__self_0 == *__arg1_0
  265.                    }
  266.                    (Context::Loop(__self_0), Context::Loop(__arg1_0)) => *__self_0 == *__arg1_0,
  267.                    _ => true,
  268.                }
  269.        }
  270.        #[inline]
  271.        fn ne(&self, other: &Context) -> bool {
  272.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  273.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  274.            __self_tag != __arg1_tag
  275.                || match (self, other) {
  276.                    (Context::Fun(__self_0), Context::Fun(__arg1_0)) => *__self_0 != *__arg1_0,
  277.                    (Context::Method(__self_0), Context::Method(__arg1_0)) => {
  278.                        *__self_0 != *__arg1_0
  279.                    }
  280.                    (Context::Loop(__self_0), Context::Loop(__arg1_0)) => *__self_0 != *__arg1_0,
  281.                    _ => false,
  282.                }
  283.        }
  284.    }
  285. }
  286. mod ast {
  287.    use crate::diagnostics::Span;
  288.    use crate::interner::InternedString;
  289.    use crate::lexer::{NumberKind, TokenKind};
  290.    use std::collections::HashMap;
  291.    pub struct StmtContainer {
  292.        pub stmt: Stmt,
  293.        pub span: Span,
  294.    }
  295.    #[automatically_derived]
  296.    impl ::core::fmt::Debug for StmtContainer {
  297.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  298.            ::core::fmt::Formatter::debug_struct_field2_finish(
  299.                f,
  300.                "StmtContainer",
  301.                "stmt",
  302.                &&self.stmt,
  303.                "span",
  304.                &&self.span,
  305.            )
  306.        }
  307.    }
  308.    #[automatically_derived]
  309.    impl ::core::clone::Clone for StmtContainer {
  310.        #[inline]
  311.        fn clone(&self) -> StmtContainer {
  312.            StmtContainer {
  313.                stmt: ::core::clone::Clone::clone(&self.stmt),
  314.                span: ::core::clone::Clone::clone(&self.span),
  315.            }
  316.        }
  317.    }
  318.    impl ::core::marker::StructuralPartialEq for StmtContainer {}
  319.    #[automatically_derived]
  320.    impl ::core::cmp::PartialEq for StmtContainer {
  321.        #[inline]
  322.        fn eq(&self, other: &StmtContainer) -> bool {
  323.            self.stmt == other.stmt && self.span == other.span
  324.        }
  325.        #[inline]
  326.        fn ne(&self, other: &StmtContainer) -> bool {
  327.            self.stmt != other.stmt || self.span != other.span
  328.        }
  329.    }
  330.    impl StmtContainer {
  331.        pub fn new(stmt: Stmt, span: Span) -> Self {
  332.            Self { stmt, span }
  333.        }
  334.    }
  335.    pub enum Stmt {
  336.        Var(Box<VarStmt>),
  337.        Fun(Box<FunStmt>),
  338.        Data(Box<DataStmt>),
  339.        Methods(Box<MethodsStmt>),
  340.        Block(Vec<StmtContainer>),
  341.        Loop(Box<StmtContainer>),
  342.        Iter(Box<IterStmt>),
  343.        If(Box<IfStmt>),
  344.        Expr(ExprContainer),
  345.        Ret(ExprContainer),
  346.        Continue,
  347.        Break,
  348.    }
  349.    #[automatically_derived]
  350.    impl ::core::fmt::Debug for Stmt {
  351.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  352.            match self {
  353.                Stmt::Var(__self_0) => {
  354.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Var", &__self_0)
  355.                }
  356.                Stmt::Fun(__self_0) => {
  357.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Fun", &__self_0)
  358.                }
  359.                Stmt::Data(__self_0) => {
  360.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Data", &__self_0)
  361.                }
  362.                Stmt::Methods(__self_0) => {
  363.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Methods", &__self_0)
  364.                }
  365.                Stmt::Block(__self_0) => {
  366.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Block", &__self_0)
  367.                }
  368.                Stmt::Loop(__self_0) => {
  369.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Loop", &__self_0)
  370.                }
  371.                Stmt::Iter(__self_0) => {
  372.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Iter", &__self_0)
  373.                }
  374.                Stmt::If(__self_0) => {
  375.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "If", &__self_0)
  376.                }
  377.                Stmt::Expr(__self_0) => {
  378.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Expr", &__self_0)
  379.                }
  380.                Stmt::Ret(__self_0) => {
  381.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ret", &__self_0)
  382.                }
  383.                Stmt::Continue => ::core::fmt::Formatter::write_str(f, "Continue"),
  384.                Stmt::Break => ::core::fmt::Formatter::write_str(f, "Break"),
  385.            }
  386.        }
  387.    }
  388.    #[automatically_derived]
  389.    impl ::core::clone::Clone for Stmt {
  390.        #[inline]
  391.        fn clone(&self) -> Stmt {
  392.            match self {
  393.                Stmt::Var(__self_0) => Stmt::Var(::core::clone::Clone::clone(__self_0)),
  394.                Stmt::Fun(__self_0) => Stmt::Fun(::core::clone::Clone::clone(__self_0)),
  395.                Stmt::Data(__self_0) => Stmt::Data(::core::clone::Clone::clone(__self_0)),
  396.                Stmt::Methods(__self_0) => Stmt::Methods(::core::clone::Clone::clone(__self_0)),
  397.                Stmt::Block(__self_0) => Stmt::Block(::core::clone::Clone::clone(__self_0)),
  398.                Stmt::Loop(__self_0) => Stmt::Loop(::core::clone::Clone::clone(__self_0)),
  399.                Stmt::Iter(__self_0) => Stmt::Iter(::core::clone::Clone::clone(__self_0)),
  400.                Stmt::If(__self_0) => Stmt::If(::core::clone::Clone::clone(__self_0)),
  401.                Stmt::Expr(__self_0) => Stmt::Expr(::core::clone::Clone::clone(__self_0)),
  402.                Stmt::Ret(__self_0) => Stmt::Ret(::core::clone::Clone::clone(__self_0)),
  403.                Stmt::Continue => Stmt::Continue,
  404.                Stmt::Break => Stmt::Break,
  405.            }
  406.        }
  407.    }
  408.    impl ::core::marker::StructuralPartialEq for Stmt {}
  409.    #[automatically_derived]
  410.    impl ::core::cmp::PartialEq for Stmt {
  411.        #[inline]
  412.        fn eq(&self, other: &Stmt) -> bool {
  413.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  414.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  415.            __self_tag == __arg1_tag
  416.                && match (self, other) {
  417.                    (Stmt::Var(__self_0), Stmt::Var(__arg1_0)) => *__self_0 == *__arg1_0,
  418.                    (Stmt::Fun(__self_0), Stmt::Fun(__arg1_0)) => *__self_0 == *__arg1_0,
  419.                    (Stmt::Data(__self_0), Stmt::Data(__arg1_0)) => *__self_0 == *__arg1_0,
  420.                    (Stmt::Methods(__self_0), Stmt::Methods(__arg1_0)) => *__self_0 == *__arg1_0,
  421.                    (Stmt::Block(__self_0), Stmt::Block(__arg1_0)) => *__self_0 == *__arg1_0,
  422.                    (Stmt::Loop(__self_0), Stmt::Loop(__arg1_0)) => *__self_0 == *__arg1_0,
  423.                    (Stmt::Iter(__self_0), Stmt::Iter(__arg1_0)) => *__self_0 == *__arg1_0,
  424.                    (Stmt::If(__self_0), Stmt::If(__arg1_0)) => *__self_0 == *__arg1_0,
  425.                    (Stmt::Expr(__self_0), Stmt::Expr(__arg1_0)) => *__self_0 == *__arg1_0,
  426.                    (Stmt::Ret(__self_0), Stmt::Ret(__arg1_0)) => *__self_0 == *__arg1_0,
  427.                    _ => true,
  428.                }
  429.        }
  430.        #[inline]
  431.        fn ne(&self, other: &Stmt) -> bool {
  432.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  433.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  434.            __self_tag != __arg1_tag
  435.                || match (self, other) {
  436.                    (Stmt::Var(__self_0), Stmt::Var(__arg1_0)) => *__self_0 != *__arg1_0,
  437.                    (Stmt::Fun(__self_0), Stmt::Fun(__arg1_0)) => *__self_0 != *__arg1_0,
  438.                    (Stmt::Data(__self_0), Stmt::Data(__arg1_0)) => *__self_0 != *__arg1_0,
  439.                    (Stmt::Methods(__self_0), Stmt::Methods(__arg1_0)) => *__self_0 != *__arg1_0,
  440.                    (Stmt::Block(__self_0), Stmt::Block(__arg1_0)) => *__self_0 != *__arg1_0,
  441.                    (Stmt::Loop(__self_0), Stmt::Loop(__arg1_0)) => *__self_0 != *__arg1_0,
  442.                    (Stmt::Iter(__self_0), Stmt::Iter(__arg1_0)) => *__self_0 != *__arg1_0,
  443.                    (Stmt::If(__self_0), Stmt::If(__arg1_0)) => *__self_0 != *__arg1_0,
  444.                    (Stmt::Expr(__self_0), Stmt::Expr(__arg1_0)) => *__self_0 != *__arg1_0,
  445.                    (Stmt::Ret(__self_0), Stmt::Ret(__arg1_0)) => *__self_0 != *__arg1_0,
  446.                    _ => false,
  447.                }
  448.        }
  449.    }
  450.    impl Stmt {
  451.        pub fn into_container(self, span: Span) -> StmtContainer {
  452.            StmtContainer { stmt: self, span }
  453.        }
  454.    }
  455.    pub struct IfStmt {
  456.        pub condition: ExprContainer,
  457.        pub block: StmtContainer,
  458.        pub else_: Option<StmtContainer>,
  459.        pub then: Option<StmtContainer>,
  460.    }
  461.    #[automatically_derived]
  462.    impl ::core::fmt::Debug for IfStmt {
  463.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  464.            ::core::fmt::Formatter::debug_struct_field4_finish(
  465.                f,
  466.                "IfStmt",
  467.                "condition",
  468.                &&self.condition,
  469.                "block",
  470.                &&self.block,
  471.                "else_",
  472.                &&self.else_,
  473.                "then",
  474.                &&self.then,
  475.            )
  476.        }
  477.    }
  478.    #[automatically_derived]
  479.    impl ::core::clone::Clone for IfStmt {
  480.        #[inline]
  481.        fn clone(&self) -> IfStmt {
  482.            IfStmt {
  483.                condition: ::core::clone::Clone::clone(&self.condition),
  484.                block: ::core::clone::Clone::clone(&self.block),
  485.                else_: ::core::clone::Clone::clone(&self.else_),
  486.                then: ::core::clone::Clone::clone(&self.then),
  487.            }
  488.        }
  489.    }
  490.    impl ::core::marker::StructuralPartialEq for IfStmt {}
  491.    #[automatically_derived]
  492.    impl ::core::cmp::PartialEq for IfStmt {
  493.        #[inline]
  494.        fn eq(&self, other: &IfStmt) -> bool {
  495.            self.condition == other.condition
  496.                && self.block == other.block
  497.                && self.else_ == other.else_
  498.                && self.then == other.then
  499.        }
  500.        #[inline]
  501.        fn ne(&self, other: &IfStmt) -> bool {
  502.            self.condition != other.condition
  503.                || self.block != other.block
  504.                || self.else_ != other.else_
  505.                || self.then != other.then
  506.        }
  507.    }
  508.    pub struct IterStmt {
  509.        pub iterable: ExprContainer,
  510.        pub binding: InternedString,
  511.        pub block: StmtContainer,
  512.    }
  513.    #[automatically_derived]
  514.    impl ::core::fmt::Debug for IterStmt {
  515.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  516.            ::core::fmt::Formatter::debug_struct_field3_finish(
  517.                f,
  518.                "IterStmt",
  519.                "iterable",
  520.                &&self.iterable,
  521.                "binding",
  522.                &&self.binding,
  523.                "block",
  524.                &&self.block,
  525.            )
  526.        }
  527.    }
  528.    #[automatically_derived]
  529.    impl ::core::clone::Clone for IterStmt {
  530.        #[inline]
  531.        fn clone(&self) -> IterStmt {
  532.            IterStmt {
  533.                iterable: ::core::clone::Clone::clone(&self.iterable),
  534.                binding: ::core::clone::Clone::clone(&self.binding),
  535.                block: ::core::clone::Clone::clone(&self.block),
  536.            }
  537.        }
  538.    }
  539.    impl ::core::marker::StructuralPartialEq for IterStmt {}
  540.    #[automatically_derived]
  541.    impl ::core::cmp::PartialEq for IterStmt {
  542.        #[inline]
  543.        fn eq(&self, other: &IterStmt) -> bool {
  544.            self.iterable == other.iterable
  545.                && self.binding == other.binding
  546.                && self.block == other.block
  547.        }
  548.        #[inline]
  549.        fn ne(&self, other: &IterStmt) -> bool {
  550.            self.iterable != other.iterable
  551.                || self.binding != other.binding
  552.                || self.block != other.block
  553.        }
  554.    }
  555.    pub struct VarStmt {
  556.        pub name: InternedString,
  557.        pub value: ExprContainer,
  558.        pub mutable: Mutable,
  559.    }
  560.    #[automatically_derived]
  561.    impl ::core::fmt::Debug for VarStmt {
  562.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  563.            ::core::fmt::Formatter::debug_struct_field3_finish(
  564.                f,
  565.                "VarStmt",
  566.                "name",
  567.                &&self.name,
  568.                "value",
  569.                &&self.value,
  570.                "mutable",
  571.                &&self.mutable,
  572.            )
  573.        }
  574.    }
  575.    #[automatically_derived]
  576.    impl ::core::clone::Clone for VarStmt {
  577.        #[inline]
  578.        fn clone(&self) -> VarStmt {
  579.            VarStmt {
  580.                name: ::core::clone::Clone::clone(&self.name),
  581.                value: ::core::clone::Clone::clone(&self.value),
  582.                mutable: ::core::clone::Clone::clone(&self.mutable),
  583.            }
  584.        }
  585.    }
  586.    impl ::core::marker::StructuralPartialEq for VarStmt {}
  587.    #[automatically_derived]
  588.    impl ::core::cmp::PartialEq for VarStmt {
  589.        #[inline]
  590.        fn eq(&self, other: &VarStmt) -> bool {
  591.            self.name == other.name && self.value == other.value && self.mutable == other.mutable
  592.        }
  593.        #[inline]
  594.        fn ne(&self, other: &VarStmt) -> bool {
  595.            self.name != other.name || self.value != other.value || self.mutable != other.mutable
  596.        }
  597.    }
  598.    pub enum Mutable {
  599.        Yes,
  600.        No,
  601.    }
  602.    #[automatically_derived]
  603.    impl ::core::fmt::Debug for Mutable {
  604.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  605.            match self {
  606.                Mutable::Yes => ::core::fmt::Formatter::write_str(f, "Yes"),
  607.                Mutable::No => ::core::fmt::Formatter::write_str(f, "No"),
  608.            }
  609.        }
  610.    }
  611.    #[automatically_derived]
  612.    impl ::core::clone::Clone for Mutable {
  613.        #[inline]
  614.        fn clone(&self) -> Mutable {
  615.            *self
  616.        }
  617.    }
  618.    #[automatically_derived]
  619.    impl ::core::marker::Copy for Mutable {}
  620.    impl ::core::marker::StructuralPartialEq for Mutable {}
  621.    #[automatically_derived]
  622.    impl ::core::cmp::PartialEq for Mutable {
  623.        #[inline]
  624.        fn eq(&self, other: &Mutable) -> bool {
  625.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  626.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  627.            __self_tag == __arg1_tag
  628.        }
  629.    }
  630.    pub struct FunStmt {
  631.        pub name: InternedString,
  632.        pub arguments: Vec<InternedString>,
  633.        pub body: StmtContainer,
  634.        pub is_method: bool,
  635.    }
  636.    #[automatically_derived]
  637.    impl ::core::fmt::Debug for FunStmt {
  638.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  639.            ::core::fmt::Formatter::debug_struct_field4_finish(
  640.                f,
  641.                "FunStmt",
  642.                "name",
  643.                &&self.name,
  644.                "arguments",
  645.                &&self.arguments,
  646.                "body",
  647.                &&self.body,
  648.                "is_method",
  649.                &&self.is_method,
  650.            )
  651.        }
  652.    }
  653.    #[automatically_derived]
  654.    impl ::core::clone::Clone for FunStmt {
  655.        #[inline]
  656.        fn clone(&self) -> FunStmt {
  657.            FunStmt {
  658.                name: ::core::clone::Clone::clone(&self.name),
  659.                arguments: ::core::clone::Clone::clone(&self.arguments),
  660.                body: ::core::clone::Clone::clone(&self.body),
  661.                is_method: ::core::clone::Clone::clone(&self.is_method),
  662.            }
  663.        }
  664.    }
  665.    impl ::core::marker::StructuralPartialEq for FunStmt {}
  666.    #[automatically_derived]
  667.    impl ::core::cmp::PartialEq for FunStmt {
  668.        #[inline]
  669.        fn eq(&self, other: &FunStmt) -> bool {
  670.            self.name == other.name
  671.                && self.arguments == other.arguments
  672.                && self.body == other.body
  673.                && self.is_method == other.is_method
  674.        }
  675.        #[inline]
  676.        fn ne(&self, other: &FunStmt) -> bool {
  677.            self.name != other.name
  678.                || self.arguments != other.arguments
  679.                || self.body != other.body
  680.                || self.is_method != other.is_method
  681.        }
  682.    }
  683.    pub struct DataStmt {
  684.        pub name: InternedString,
  685.        pub fields: Vec<InternedString>,
  686.    }
  687.    #[automatically_derived]
  688.    impl ::core::fmt::Debug for DataStmt {
  689.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  690.            ::core::fmt::Formatter::debug_struct_field2_finish(
  691.                f,
  692.                "DataStmt",
  693.                "name",
  694.                &&self.name,
  695.                "fields",
  696.                &&self.fields,
  697.            )
  698.        }
  699.    }
  700.    #[automatically_derived]
  701.    impl ::core::clone::Clone for DataStmt {
  702.        #[inline]
  703.        fn clone(&self) -> DataStmt {
  704.            DataStmt {
  705.                name: ::core::clone::Clone::clone(&self.name),
  706.                fields: ::core::clone::Clone::clone(&self.fields),
  707.            }
  708.        }
  709.    }
  710.    impl ::core::marker::StructuralPartialEq for DataStmt {}
  711.    #[automatically_derived]
  712.    impl ::core::cmp::PartialEq for DataStmt {
  713.        #[inline]
  714.        fn eq(&self, other: &DataStmt) -> bool {
  715.            self.name == other.name && self.fields == other.fields
  716.        }
  717.        #[inline]
  718.        fn ne(&self, other: &DataStmt) -> bool {
  719.            self.name != other.name || self.fields != other.fields
  720.        }
  721.    }
  722.    pub struct MethodsStmt {
  723.        pub data: InternedString,
  724.        pub methods: Vec<StmtContainer>,
  725.    }
  726.    #[automatically_derived]
  727.    impl ::core::fmt::Debug for MethodsStmt {
  728.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  729.            ::core::fmt::Formatter::debug_struct_field2_finish(
  730.                f,
  731.                "MethodsStmt",
  732.                "data",
  733.                &&self.data,
  734.                "methods",
  735.                &&self.methods,
  736.            )
  737.        }
  738.    }
  739.    #[automatically_derived]
  740.    impl ::core::clone::Clone for MethodsStmt {
  741.        #[inline]
  742.        fn clone(&self) -> MethodsStmt {
  743.            MethodsStmt {
  744.                data: ::core::clone::Clone::clone(&self.data),
  745.                methods: ::core::clone::Clone::clone(&self.methods),
  746.            }
  747.        }
  748.    }
  749.    impl ::core::marker::StructuralPartialEq for MethodsStmt {}
  750.    #[automatically_derived]
  751.    impl ::core::cmp::PartialEq for MethodsStmt {
  752.        #[inline]
  753.        fn eq(&self, other: &MethodsStmt) -> bool {
  754.            self.data == other.data && self.methods == other.methods
  755.        }
  756.        #[inline]
  757.        fn ne(&self, other: &MethodsStmt) -> bool {
  758.            self.data != other.data || self.methods != other.methods
  759.        }
  760.    }
  761.    pub struct ExprContainer {
  762.        pub expr: Expr,
  763.        pub span: Span,
  764.    }
  765.    #[automatically_derived]
  766.    impl ::core::fmt::Debug for ExprContainer {
  767.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  768.            ::core::fmt::Formatter::debug_struct_field2_finish(
  769.                f,
  770.                "ExprContainer",
  771.                "expr",
  772.                &&self.expr,
  773.                "span",
  774.                &&self.span,
  775.            )
  776.        }
  777.    }
  778.    #[automatically_derived]
  779.    impl ::core::clone::Clone for ExprContainer {
  780.        #[inline]
  781.        fn clone(&self) -> ExprContainer {
  782.            ExprContainer {
  783.                expr: ::core::clone::Clone::clone(&self.expr),
  784.                span: ::core::clone::Clone::clone(&self.span),
  785.            }
  786.        }
  787.    }
  788.    impl ::core::marker::StructuralPartialEq for ExprContainer {}
  789.    #[automatically_derived]
  790.    impl ::core::cmp::PartialEq for ExprContainer {
  791.        #[inline]
  792.        fn eq(&self, other: &ExprContainer) -> bool {
  793.            self.expr == other.expr && self.span == other.span
  794.        }
  795.        #[inline]
  796.        fn ne(&self, other: &ExprContainer) -> bool {
  797.            self.expr != other.expr || self.span != other.span
  798.        }
  799.    }
  800.    pub enum Expr {
  801.        Data(Box<DataExpr>),
  802.        Assignment(Box<AssignmentExpr>),
  803.        Get(Box<GetExpr>),
  804.        Index(Box<IndexExpr>),
  805.        IndexSet(Box<IndexSetExpr>),
  806.        Set(Box<SetExpr>),
  807.        Logical(Box<LogicalExpr>),
  808.        Binary(Box<BinaryExpr>),
  809.        Unary(Box<UnaryExpr>),
  810.        Call(Box<CallExpr>),
  811.        Boolean(bool),
  812.        None,
  813.        String(InternedString),
  814.        Number(NumberExpr),
  815.        Grouping(Box<ExprContainer>),
  816.        Array(Vec<ExprContainer>),
  817.        Variable(InternedString),
  818.    }
  819.    #[automatically_derived]
  820.    impl ::core::fmt::Debug for Expr {
  821.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  822.            match self {
  823.                Expr::Data(__self_0) => {
  824.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Data", &__self_0)
  825.                }
  826.                Expr::Assignment(__self_0) => {
  827.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Assignment", &__self_0)
  828.                }
  829.                Expr::Get(__self_0) => {
  830.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Get", &__self_0)
  831.                }
  832.                Expr::Index(__self_0) => {
  833.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Index", &__self_0)
  834.                }
  835.                Expr::IndexSet(__self_0) => {
  836.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "IndexSet", &__self_0)
  837.                }
  838.                Expr::Set(__self_0) => {
  839.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Set", &__self_0)
  840.                }
  841.                Expr::Logical(__self_0) => {
  842.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Logical", &__self_0)
  843.                }
  844.                Expr::Binary(__self_0) => {
  845.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Binary", &__self_0)
  846.                }
  847.                Expr::Unary(__self_0) => {
  848.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Unary", &__self_0)
  849.                }
  850.                Expr::Call(__self_0) => {
  851.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Call", &__self_0)
  852.                }
  853.                Expr::Boolean(__self_0) => {
  854.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Boolean", &__self_0)
  855.                }
  856.                Expr::None => ::core::fmt::Formatter::write_str(f, "None"),
  857.                Expr::String(__self_0) => {
  858.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "String", &__self_0)
  859.                }
  860.                Expr::Number(__self_0) => {
  861.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Number", &__self_0)
  862.                }
  863.                Expr::Grouping(__self_0) => {
  864.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Grouping", &__self_0)
  865.                }
  866.                Expr::Array(__self_0) => {
  867.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Array", &__self_0)
  868.                }
  869.                Expr::Variable(__self_0) => {
  870.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Variable", &__self_0)
  871.                }
  872.            }
  873.        }
  874.    }
  875.    #[automatically_derived]
  876.    impl ::core::clone::Clone for Expr {
  877.        #[inline]
  878.        fn clone(&self) -> Expr {
  879.            match self {
  880.                Expr::Data(__self_0) => Expr::Data(::core::clone::Clone::clone(__self_0)),
  881.                Expr::Assignment(__self_0) => {
  882.                    Expr::Assignment(::core::clone::Clone::clone(__self_0))
  883.                }
  884.                Expr::Get(__self_0) => Expr::Get(::core::clone::Clone::clone(__self_0)),
  885.                Expr::Index(__self_0) => Expr::Index(::core::clone::Clone::clone(__self_0)),
  886.                Expr::IndexSet(__self_0) => Expr::IndexSet(::core::clone::Clone::clone(__self_0)),
  887.                Expr::Set(__self_0) => Expr::Set(::core::clone::Clone::clone(__self_0)),
  888.                Expr::Logical(__self_0) => Expr::Logical(::core::clone::Clone::clone(__self_0)),
  889.                Expr::Binary(__self_0) => Expr::Binary(::core::clone::Clone::clone(__self_0)),
  890.                Expr::Unary(__self_0) => Expr::Unary(::core::clone::Clone::clone(__self_0)),
  891.                Expr::Call(__self_0) => Expr::Call(::core::clone::Clone::clone(__self_0)),
  892.                Expr::Boolean(__self_0) => Expr::Boolean(::core::clone::Clone::clone(__self_0)),
  893.                Expr::None => Expr::None,
  894.                Expr::String(__self_0) => Expr::String(::core::clone::Clone::clone(__self_0)),
  895.                Expr::Number(__self_0) => Expr::Number(::core::clone::Clone::clone(__self_0)),
  896.                Expr::Grouping(__self_0) => Expr::Grouping(::core::clone::Clone::clone(__self_0)),
  897.                Expr::Array(__self_0) => Expr::Array(::core::clone::Clone::clone(__self_0)),
  898.                Expr::Variable(__self_0) => Expr::Variable(::core::clone::Clone::clone(__self_0)),
  899.            }
  900.        }
  901.    }
  902.    impl ::core::marker::StructuralPartialEq for Expr {}
  903.    #[automatically_derived]
  904.    impl ::core::cmp::PartialEq for Expr {
  905.        #[inline]
  906.        fn eq(&self, other: &Expr) -> bool {
  907.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  908.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  909.            __self_tag == __arg1_tag
  910.                && match (self, other) {
  911.                    (Expr::Data(__self_0), Expr::Data(__arg1_0)) => *__self_0 == *__arg1_0,
  912.                    (Expr::Assignment(__self_0), Expr::Assignment(__arg1_0)) => {
  913.                        *__self_0 == *__arg1_0
  914.                    }
  915.                    (Expr::Get(__self_0), Expr::Get(__arg1_0)) => *__self_0 == *__arg1_0,
  916.                    (Expr::Index(__self_0), Expr::Index(__arg1_0)) => *__self_0 == *__arg1_0,
  917.                    (Expr::IndexSet(__self_0), Expr::IndexSet(__arg1_0)) => *__self_0 == *__arg1_0,
  918.                    (Expr::Set(__self_0), Expr::Set(__arg1_0)) => *__self_0 == *__arg1_0,
  919.                    (Expr::Logical(__self_0), Expr::Logical(__arg1_0)) => *__self_0 == *__arg1_0,
  920.                    (Expr::Binary(__self_0), Expr::Binary(__arg1_0)) => *__self_0 == *__arg1_0,
  921.                    (Expr::Unary(__self_0), Expr::Unary(__arg1_0)) => *__self_0 == *__arg1_0,
  922.                    (Expr::Call(__self_0), Expr::Call(__arg1_0)) => *__self_0 == *__arg1_0,
  923.                    (Expr::Boolean(__self_0), Expr::Boolean(__arg1_0)) => *__self_0 == *__arg1_0,
  924.                    (Expr::String(__self_0), Expr::String(__arg1_0)) => *__self_0 == *__arg1_0,
  925.                    (Expr::Number(__self_0), Expr::Number(__arg1_0)) => *__self_0 == *__arg1_0,
  926.                    (Expr::Grouping(__self_0), Expr::Grouping(__arg1_0)) => *__self_0 == *__arg1_0,
  927.                    (Expr::Array(__self_0), Expr::Array(__arg1_0)) => *__self_0 == *__arg1_0,
  928.                    (Expr::Variable(__self_0), Expr::Variable(__arg1_0)) => *__self_0 == *__arg1_0,
  929.                    _ => true,
  930.                }
  931.        }
  932.        #[inline]
  933.        fn ne(&self, other: &Expr) -> bool {
  934.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  935.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  936.            __self_tag != __arg1_tag
  937.                || match (self, other) {
  938.                    (Expr::Data(__self_0), Expr::Data(__arg1_0)) => *__self_0 != *__arg1_0,
  939.                    (Expr::Assignment(__self_0), Expr::Assignment(__arg1_0)) => {
  940.                        *__self_0 != *__arg1_0
  941.                    }
  942.                    (Expr::Get(__self_0), Expr::Get(__arg1_0)) => *__self_0 != *__arg1_0,
  943.                    (Expr::Index(__self_0), Expr::Index(__arg1_0)) => *__self_0 != *__arg1_0,
  944.                    (Expr::IndexSet(__self_0), Expr::IndexSet(__arg1_0)) => *__self_0 != *__arg1_0,
  945.                    (Expr::Set(__self_0), Expr::Set(__arg1_0)) => *__self_0 != *__arg1_0,
  946.                    (Expr::Logical(__self_0), Expr::Logical(__arg1_0)) => *__self_0 != *__arg1_0,
  947.                    (Expr::Binary(__self_0), Expr::Binary(__arg1_0)) => *__self_0 != *__arg1_0,
  948.                    (Expr::Unary(__self_0), Expr::Unary(__arg1_0)) => *__self_0 != *__arg1_0,
  949.                    (Expr::Call(__self_0), Expr::Call(__arg1_0)) => *__self_0 != *__arg1_0,
  950.                    (Expr::Boolean(__self_0), Expr::Boolean(__arg1_0)) => *__self_0 != *__arg1_0,
  951.                    (Expr::String(__self_0), Expr::String(__arg1_0)) => *__self_0 != *__arg1_0,
  952.                    (Expr::Number(__self_0), Expr::Number(__arg1_0)) => *__self_0 != *__arg1_0,
  953.                    (Expr::Grouping(__self_0), Expr::Grouping(__arg1_0)) => *__self_0 != *__arg1_0,
  954.                    (Expr::Array(__self_0), Expr::Array(__arg1_0)) => *__self_0 != *__arg1_0,
  955.                    (Expr::Variable(__self_0), Expr::Variable(__arg1_0)) => *__self_0 != *__arg1_0,
  956.                    _ => false,
  957.                }
  958.        }
  959.    }
  960.    impl Expr {
  961.        pub fn into_container(self, span: Span) -> ExprContainer {
  962.            ExprContainer { expr: self, span }
  963.        }
  964.    }
  965.    pub struct DataExpr {
  966.        pub name: InternedString,
  967.        pub props: HashMap<InternedString, ExprContainer>,
  968.    }
  969.    #[automatically_derived]
  970.    impl ::core::fmt::Debug for DataExpr {
  971.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  972.            ::core::fmt::Formatter::debug_struct_field2_finish(
  973.                f,
  974.                "DataExpr",
  975.                "name",
  976.                &&self.name,
  977.                "props",
  978.                &&self.props,
  979.            )
  980.        }
  981.    }
  982.    #[automatically_derived]
  983.    impl ::core::clone::Clone for DataExpr {
  984.        #[inline]
  985.        fn clone(&self) -> DataExpr {
  986.            DataExpr {
  987.                name: ::core::clone::Clone::clone(&self.name),
  988.                props: ::core::clone::Clone::clone(&self.props),
  989.            }
  990.        }
  991.    }
  992.    impl ::core::marker::StructuralPartialEq for DataExpr {}
  993.    #[automatically_derived]
  994.    impl ::core::cmp::PartialEq for DataExpr {
  995.        #[inline]
  996.        fn eq(&self, other: &DataExpr) -> bool {
  997.            self.name == other.name && self.props == other.props
  998.        }
  999.        #[inline]
  1000.        fn ne(&self, other: &DataExpr) -> bool {
  1001.            self.name != other.name || self.props != other.props
  1002.        }
  1003.    }
  1004.    pub struct AssignmentExpr {
  1005.        pub lvalue: ExprContainer,
  1006.        pub rvalue: ExprContainer,
  1007.        pub data_member: bool,
  1008.    }
  1009.    #[automatically_derived]
  1010.    impl ::core::fmt::Debug for AssignmentExpr {
  1011.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1012.            ::core::fmt::Formatter::debug_struct_field3_finish(
  1013.                f,
  1014.                "AssignmentExpr",
  1015.                "lvalue",
  1016.                &&self.lvalue,
  1017.                "rvalue",
  1018.                &&self.rvalue,
  1019.                "data_member",
  1020.                &&self.data_member,
  1021.            )
  1022.        }
  1023.    }
  1024.    #[automatically_derived]
  1025.    impl ::core::clone::Clone for AssignmentExpr {
  1026.        #[inline]
  1027.        fn clone(&self) -> AssignmentExpr {
  1028.            AssignmentExpr {
  1029.                lvalue: ::core::clone::Clone::clone(&self.lvalue),
  1030.                rvalue: ::core::clone::Clone::clone(&self.rvalue),
  1031.                data_member: ::core::clone::Clone::clone(&self.data_member),
  1032.            }
  1033.        }
  1034.    }
  1035.    impl ::core::marker::StructuralPartialEq for AssignmentExpr {}
  1036.    #[automatically_derived]
  1037.    impl ::core::cmp::PartialEq for AssignmentExpr {
  1038.        #[inline]
  1039.        fn eq(&self, other: &AssignmentExpr) -> bool {
  1040.            self.lvalue == other.lvalue
  1041.                && self.rvalue == other.rvalue
  1042.                && self.data_member == other.data_member
  1043.        }
  1044.        #[inline]
  1045.        fn ne(&self, other: &AssignmentExpr) -> bool {
  1046.            self.lvalue != other.lvalue
  1047.                || self.rvalue != other.rvalue
  1048.                || self.data_member != other.data_member
  1049.        }
  1050.    }
  1051.    pub struct GetExpr {
  1052.        pub property: InternedString,
  1053.        pub object: ExprContainer,
  1054.    }
  1055.    #[automatically_derived]
  1056.    impl ::core::fmt::Debug for GetExpr {
  1057.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1058.            ::core::fmt::Formatter::debug_struct_field2_finish(
  1059.                f,
  1060.                "GetExpr",
  1061.                "property",
  1062.                &&self.property,
  1063.                "object",
  1064.                &&self.object,
  1065.            )
  1066.        }
  1067.    }
  1068.    #[automatically_derived]
  1069.    impl ::core::clone::Clone for GetExpr {
  1070.        #[inline]
  1071.        fn clone(&self) -> GetExpr {
  1072.            GetExpr {
  1073.                property: ::core::clone::Clone::clone(&self.property),
  1074.                object: ::core::clone::Clone::clone(&self.object),
  1075.            }
  1076.        }
  1077.    }
  1078.    impl ::core::marker::StructuralPartialEq for GetExpr {}
  1079.    #[automatically_derived]
  1080.    impl ::core::cmp::PartialEq for GetExpr {
  1081.        #[inline]
  1082.        fn eq(&self, other: &GetExpr) -> bool {
  1083.            self.property == other.property && self.object == other.object
  1084.        }
  1085.        #[inline]
  1086.        fn ne(&self, other: &GetExpr) -> bool {
  1087.            self.property != other.property || self.object != other.object
  1088.        }
  1089.    }
  1090.    pub struct IndexExpr {
  1091.        pub index: ExprContainer,
  1092.        pub object: ExprContainer,
  1093.    }
  1094.    #[automatically_derived]
  1095.    impl ::core::fmt::Debug for IndexExpr {
  1096.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1097.            ::core::fmt::Formatter::debug_struct_field2_finish(
  1098.                f,
  1099.                "IndexExpr",
  1100.                "index",
  1101.                &&self.index,
  1102.                "object",
  1103.                &&self.object,
  1104.            )
  1105.        }
  1106.    }
  1107.    #[automatically_derived]
  1108.    impl ::core::clone::Clone for IndexExpr {
  1109.        #[inline]
  1110.        fn clone(&self) -> IndexExpr {
  1111.            IndexExpr {
  1112.                index: ::core::clone::Clone::clone(&self.index),
  1113.                object: ::core::clone::Clone::clone(&self.object),
  1114.            }
  1115.        }
  1116.    }
  1117.    impl ::core::marker::StructuralPartialEq for IndexExpr {}
  1118.    #[automatically_derived]
  1119.    impl ::core::cmp::PartialEq for IndexExpr {
  1120.        #[inline]
  1121.        fn eq(&self, other: &IndexExpr) -> bool {
  1122.            self.index == other.index && self.object == other.object
  1123.        }
  1124.        #[inline]
  1125.        fn ne(&self, other: &IndexExpr) -> bool {
  1126.            self.index != other.index || self.object != other.object
  1127.        }
  1128.    }
  1129.    pub struct IndexSetExpr {
  1130.        pub object: ExprContainer,
  1131.        pub value: ExprContainer,
  1132.    }
  1133.    #[automatically_derived]
  1134.    impl ::core::fmt::Debug for IndexSetExpr {
  1135.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1136.            ::core::fmt::Formatter::debug_struct_field2_finish(
  1137.                f,
  1138.                "IndexSetExpr",
  1139.                "object",
  1140.                &&self.object,
  1141.                "value",
  1142.                &&self.value,
  1143.            )
  1144.        }
  1145.    }
  1146.    #[automatically_derived]
  1147.    impl ::core::clone::Clone for IndexSetExpr {
  1148.        #[inline]
  1149.        fn clone(&self) -> IndexSetExpr {
  1150.            IndexSetExpr {
  1151.                object: ::core::clone::Clone::clone(&self.object),
  1152.                value: ::core::clone::Clone::clone(&self.value),
  1153.            }
  1154.        }
  1155.    }
  1156.    impl ::core::marker::StructuralPartialEq for IndexSetExpr {}
  1157.    #[automatically_derived]
  1158.    impl ::core::cmp::PartialEq for IndexSetExpr {
  1159.        #[inline]
  1160.        fn eq(&self, other: &IndexSetExpr) -> bool {
  1161.            self.object == other.object && self.value == other.value
  1162.        }
  1163.        #[inline]
  1164.        fn ne(&self, other: &IndexSetExpr) -> bool {
  1165.            self.object != other.object || self.value != other.value
  1166.        }
  1167.    }
  1168.    pub struct SetExpr {
  1169.        pub object: ExprContainer,
  1170.        pub property: InternedString,
  1171.        pub value: ExprContainer,
  1172.    }
  1173.    #[automatically_derived]
  1174.    impl ::core::fmt::Debug for SetExpr {
  1175.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1176.            ::core::fmt::Formatter::debug_struct_field3_finish(
  1177.                f,
  1178.                "SetExpr",
  1179.                "object",
  1180.                &&self.object,
  1181.                "property",
  1182.                &&self.property,
  1183.                "value",
  1184.                &&self.value,
  1185.            )
  1186.        }
  1187.    }
  1188.    #[automatically_derived]
  1189.    impl ::core::clone::Clone for SetExpr {
  1190.        #[inline]
  1191.        fn clone(&self) -> SetExpr {
  1192.            SetExpr {
  1193.                object: ::core::clone::Clone::clone(&self.object),
  1194.                property: ::core::clone::Clone::clone(&self.property),
  1195.                value: ::core::clone::Clone::clone(&self.value),
  1196.            }
  1197.        }
  1198.    }
  1199.    impl ::core::marker::StructuralPartialEq for SetExpr {}
  1200.    #[automatically_derived]
  1201.    impl ::core::cmp::PartialEq for SetExpr {
  1202.        #[inline]
  1203.        fn eq(&self, other: &SetExpr) -> bool {
  1204.            self.object == other.object
  1205.                && self.property == other.property
  1206.                && self.value == other.value
  1207.        }
  1208.        #[inline]
  1209.        fn ne(&self, other: &SetExpr) -> bool {
  1210.            self.object != other.object
  1211.                || self.property != other.property
  1212.                || self.value != other.value
  1213.        }
  1214.    }
  1215.    pub struct LogicalExpr {
  1216.        pub lhs: ExprContainer,
  1217.        pub op: LogicalOperation,
  1218.        pub rhs: ExprContainer,
  1219.    }
  1220.    #[automatically_derived]
  1221.    impl ::core::fmt::Debug for LogicalExpr {
  1222.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1223.            ::core::fmt::Formatter::debug_struct_field3_finish(
  1224.                f,
  1225.                "LogicalExpr",
  1226.                "lhs",
  1227.                &&self.lhs,
  1228.                "op",
  1229.                &&self.op,
  1230.                "rhs",
  1231.                &&self.rhs,
  1232.            )
  1233.        }
  1234.    }
  1235.    #[automatically_derived]
  1236.    impl ::core::clone::Clone for LogicalExpr {
  1237.        #[inline]
  1238.        fn clone(&self) -> LogicalExpr {
  1239.            LogicalExpr {
  1240.                lhs: ::core::clone::Clone::clone(&self.lhs),
  1241.                op: ::core::clone::Clone::clone(&self.op),
  1242.                rhs: ::core::clone::Clone::clone(&self.rhs),
  1243.            }
  1244.        }
  1245.    }
  1246.    impl ::core::marker::StructuralPartialEq for LogicalExpr {}
  1247.    #[automatically_derived]
  1248.    impl ::core::cmp::PartialEq for LogicalExpr {
  1249.        #[inline]
  1250.        fn eq(&self, other: &LogicalExpr) -> bool {
  1251.            self.lhs == other.lhs && self.op == other.op && self.rhs == other.rhs
  1252.        }
  1253.        #[inline]
  1254.        fn ne(&self, other: &LogicalExpr) -> bool {
  1255.            self.lhs != other.lhs || self.op != other.op || self.rhs != other.rhs
  1256.        }
  1257.    }
  1258.    pub enum LogicalOperation {
  1259.        And,
  1260.        Or,
  1261.        Equals,
  1262.        NotEquals,
  1263.        GreaterThan,
  1264.        GreaterThanOrEquals,
  1265.        LessThan,
  1266.        LessThanOrEquals,
  1267.    }
  1268.    #[automatically_derived]
  1269.    impl ::core::fmt::Debug for LogicalOperation {
  1270.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1271.            match self {
  1272.                LogicalOperation::And => ::core::fmt::Formatter::write_str(f, "And"),
  1273.                LogicalOperation::Or => ::core::fmt::Formatter::write_str(f, "Or"),
  1274.                LogicalOperation::Equals => ::core::fmt::Formatter::write_str(f, "Equals"),
  1275.                LogicalOperation::NotEquals => ::core::fmt::Formatter::write_str(f, "NotEquals"),
  1276.                LogicalOperation::GreaterThan => {
  1277.                    ::core::fmt::Formatter::write_str(f, "GreaterThan")
  1278.                }
  1279.                LogicalOperation::GreaterThanOrEquals => {
  1280.                    ::core::fmt::Formatter::write_str(f, "GreaterThanOrEquals")
  1281.                }
  1282.                LogicalOperation::LessThan => ::core::fmt::Formatter::write_str(f, "LessThan"),
  1283.                LogicalOperation::LessThanOrEquals => {
  1284.                    ::core::fmt::Formatter::write_str(f, "LessThanOrEquals")
  1285.                }
  1286.            }
  1287.        }
  1288.    }
  1289.    #[automatically_derived]
  1290.    impl ::core::clone::Clone for LogicalOperation {
  1291.        #[inline]
  1292.        fn clone(&self) -> LogicalOperation {
  1293.            *self
  1294.        }
  1295.    }
  1296.    #[automatically_derived]
  1297.    impl ::core::marker::Copy for LogicalOperation {}
  1298.    impl ::core::marker::StructuralEq for LogicalOperation {}
  1299.    #[automatically_derived]
  1300.    impl ::core::cmp::Eq for LogicalOperation {
  1301.        #[inline]
  1302.        #[doc(hidden)]
  1303.        #[no_coverage]
  1304.        fn assert_receiver_is_total_eq(&self) -> () {}
  1305.    }
  1306.    #[automatically_derived]
  1307.    impl ::core::cmp::Ord for LogicalOperation {
  1308.        #[inline]
  1309.        fn cmp(&self, other: &LogicalOperation) -> ::core::cmp::Ordering {
  1310.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  1311.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  1312.            ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
  1313.        }
  1314.    }
  1315.    #[automatically_derived]
  1316.    impl ::core::cmp::PartialOrd for LogicalOperation {
  1317.        #[inline]
  1318.        fn partial_cmp(
  1319.            &self,
  1320.            other: &LogicalOperation,
  1321.        ) -> ::core::option::Option<::core::cmp::Ordering> {
  1322.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  1323.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  1324.            ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
  1325.        }
  1326.    }
  1327.    impl ::core::marker::StructuralPartialEq for LogicalOperation {}
  1328.    #[automatically_derived]
  1329.    impl ::core::cmp::PartialEq for LogicalOperation {
  1330.        #[inline]
  1331.        fn eq(&self, other: &LogicalOperation) -> bool {
  1332.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  1333.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  1334.            __self_tag == __arg1_tag
  1335.        }
  1336.    }
  1337.    impl TryFrom<TokenKind> for LogicalOperation {
  1338.        type Error = ();
  1339.        fn try_from(kind: TokenKind) -> Result<Self, Self::Error> {
  1340.            match kind {
  1341.                TokenKind::DoubleAmpersand => Ok(Self::And),
  1342.                TokenKind::DoublePipe => Ok(Self::Or),
  1343.                TokenKind::DoubleEqual => Ok(Self::Equals),
  1344.                TokenKind::ExclamationEq => Ok(Self::NotEquals),
  1345.                TokenKind::RightAngle => Ok(Self::GreaterThan),
  1346.                TokenKind::RightAngleEq => Ok(Self::GreaterThanOrEquals),
  1347.                TokenKind::LeftAngle => Ok(Self::LessThan),
  1348.                TokenKind::LeftAngleEq => Ok(Self::LessThanOrEquals),
  1349.                _ => Err(()),
  1350.            }
  1351.        }
  1352.    }
  1353.    pub struct BinaryExpr {
  1354.        pub lhs: ExprContainer,
  1355.        pub op: BinaryOperation,
  1356.        pub rhs: ExprContainer,
  1357.    }
  1358.    #[automatically_derived]
  1359.    impl ::core::fmt::Debug for BinaryExpr {
  1360.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1361.            ::core::fmt::Formatter::debug_struct_field3_finish(
  1362.                f,
  1363.                "BinaryExpr",
  1364.                "lhs",
  1365.                &&self.lhs,
  1366.                "op",
  1367.                &&self.op,
  1368.                "rhs",
  1369.                &&self.rhs,
  1370.            )
  1371.        }
  1372.    }
  1373.    #[automatically_derived]
  1374.    impl ::core::clone::Clone for BinaryExpr {
  1375.        #[inline]
  1376.        fn clone(&self) -> BinaryExpr {
  1377.            BinaryExpr {
  1378.                lhs: ::core::clone::Clone::clone(&self.lhs),
  1379.                op: ::core::clone::Clone::clone(&self.op),
  1380.                rhs: ::core::clone::Clone::clone(&self.rhs),
  1381.            }
  1382.        }
  1383.    }
  1384.    impl ::core::marker::StructuralPartialEq for BinaryExpr {}
  1385.    #[automatically_derived]
  1386.    impl ::core::cmp::PartialEq for BinaryExpr {
  1387.        #[inline]
  1388.        fn eq(&self, other: &BinaryExpr) -> bool {
  1389.            self.lhs == other.lhs && self.op == other.op && self.rhs == other.rhs
  1390.        }
  1391.        #[inline]
  1392.        fn ne(&self, other: &BinaryExpr) -> bool {
  1393.            self.lhs != other.lhs || self.op != other.op || self.rhs != other.rhs
  1394.        }
  1395.    }
  1396.    pub enum BinaryOperation {
  1397.        Plus,
  1398.        Minus,
  1399.        Multiply,
  1400.        Divide,
  1401.        Modulus,
  1402.        And,
  1403.        Or,
  1404.        Xor,
  1405.        LeftShift,
  1406.        RightShift,
  1407.    }
  1408.    #[automatically_derived]
  1409.    impl ::core::fmt::Debug for BinaryOperation {
  1410.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1411.            match self {
  1412.                BinaryOperation::Plus => ::core::fmt::Formatter::write_str(f, "Plus"),
  1413.                BinaryOperation::Minus => ::core::fmt::Formatter::write_str(f, "Minus"),
  1414.                BinaryOperation::Multiply => ::core::fmt::Formatter::write_str(f, "Multiply"),
  1415.                BinaryOperation::Divide => ::core::fmt::Formatter::write_str(f, "Divide"),
  1416.                BinaryOperation::Modulus => ::core::fmt::Formatter::write_str(f, "Modulus"),
  1417.                BinaryOperation::And => ::core::fmt::Formatter::write_str(f, "And"),
  1418.                BinaryOperation::Or => ::core::fmt::Formatter::write_str(f, "Or"),
  1419.                BinaryOperation::Xor => ::core::fmt::Formatter::write_str(f, "Xor"),
  1420.                BinaryOperation::LeftShift => ::core::fmt::Formatter::write_str(f, "LeftShift"),
  1421.                BinaryOperation::RightShift => ::core::fmt::Formatter::write_str(f, "RightShift"),
  1422.            }
  1423.        }
  1424.    }
  1425.    #[automatically_derived]
  1426.    impl ::core::clone::Clone for BinaryOperation {
  1427.        #[inline]
  1428.        fn clone(&self) -> BinaryOperation {
  1429.            *self
  1430.        }
  1431.    }
  1432.    #[automatically_derived]
  1433.    impl ::core::marker::Copy for BinaryOperation {}
  1434.    impl ::core::marker::StructuralEq for BinaryOperation {}
  1435.    #[automatically_derived]
  1436.    impl ::core::cmp::Eq for BinaryOperation {
  1437.        #[inline]
  1438.        #[doc(hidden)]
  1439.        #[no_coverage]
  1440.        fn assert_receiver_is_total_eq(&self) -> () {}
  1441.    }
  1442.    #[automatically_derived]
  1443.    impl ::core::cmp::Ord for BinaryOperation {
  1444.        #[inline]
  1445.        fn cmp(&self, other: &BinaryOperation) -> ::core::cmp::Ordering {
  1446.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  1447.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  1448.            ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
  1449.        }
  1450.    }
  1451.    #[automatically_derived]
  1452.    impl ::core::cmp::PartialOrd for BinaryOperation {
  1453.        #[inline]
  1454.        fn partial_cmp(
  1455.            &self,
  1456.            other: &BinaryOperation,
  1457.        ) -> ::core::option::Option<::core::cmp::Ordering> {
  1458.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  1459.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  1460.            ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
  1461.        }
  1462.    }
  1463.    impl ::core::marker::StructuralPartialEq for BinaryOperation {}
  1464.    #[automatically_derived]
  1465.    impl ::core::cmp::PartialEq for BinaryOperation {
  1466.        #[inline]
  1467.        fn eq(&self, other: &BinaryOperation) -> bool {
  1468.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  1469.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  1470.            __self_tag == __arg1_tag
  1471.        }
  1472.    }
  1473.    impl TryFrom<TokenKind> for BinaryOperation {
  1474.        type Error = ();
  1475.        fn try_from(value: TokenKind) -> Result<Self, Self::Error> {
  1476.            match value {
  1477.                TokenKind::Plus => Ok(Self::Plus),
  1478.                TokenKind::Minus => Ok(Self::Minus),
  1479.                TokenKind::Asterisk => Ok(Self::Multiply),
  1480.                TokenKind::Slash => Ok(Self::Divide),
  1481.                TokenKind::Percent => Ok(Self::Modulus),
  1482.                TokenKind::Ampersand => Ok(Self::And),
  1483.                TokenKind::Pipe => Ok(Self::Or),
  1484.                TokenKind::Caret => Ok(Self::Xor),
  1485.                TokenKind::DoubleLeftAngle => Ok(Self::LeftShift),
  1486.                TokenKind::DoubleRightAngle => Ok(Self::RightShift),
  1487.                _ => Err(()),
  1488.            }
  1489.        }
  1490.    }
  1491.    pub struct UnaryExpr {
  1492.        pub op: UnaryOperation,
  1493.        pub expr: ExprContainer,
  1494.    }
  1495.    #[automatically_derived]
  1496.    impl ::core::fmt::Debug for UnaryExpr {
  1497.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1498.            ::core::fmt::Formatter::debug_struct_field2_finish(
  1499.                f,
  1500.                "UnaryExpr",
  1501.                "op",
  1502.                &&self.op,
  1503.                "expr",
  1504.                &&self.expr,
  1505.            )
  1506.        }
  1507.    }
  1508.    #[automatically_derived]
  1509.    impl ::core::clone::Clone for UnaryExpr {
  1510.        #[inline]
  1511.        fn clone(&self) -> UnaryExpr {
  1512.            UnaryExpr {
  1513.                op: ::core::clone::Clone::clone(&self.op),
  1514.                expr: ::core::clone::Clone::clone(&self.expr),
  1515.            }
  1516.        }
  1517.    }
  1518.    impl ::core::marker::StructuralPartialEq for UnaryExpr {}
  1519.    #[automatically_derived]
  1520.    impl ::core::cmp::PartialEq for UnaryExpr {
  1521.        #[inline]
  1522.        fn eq(&self, other: &UnaryExpr) -> bool {
  1523.            self.op == other.op && self.expr == other.expr
  1524.        }
  1525.        #[inline]
  1526.        fn ne(&self, other: &UnaryExpr) -> bool {
  1527.            self.op != other.op || self.expr != other.expr
  1528.        }
  1529.    }
  1530.    pub enum UnaryOperation {
  1531.        Not,
  1532.        Negate,
  1533.    }
  1534.    #[automatically_derived]
  1535.    impl ::core::fmt::Debug for UnaryOperation {
  1536.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1537.            match self {
  1538.                UnaryOperation::Not => ::core::fmt::Formatter::write_str(f, "Not"),
  1539.                UnaryOperation::Negate => ::core::fmt::Formatter::write_str(f, "Negate"),
  1540.            }
  1541.        }
  1542.    }
  1543.    #[automatically_derived]
  1544.    impl ::core::clone::Clone for UnaryOperation {
  1545.        #[inline]
  1546.        fn clone(&self) -> UnaryOperation {
  1547.            *self
  1548.        }
  1549.    }
  1550.    #[automatically_derived]
  1551.    impl ::core::marker::Copy for UnaryOperation {}
  1552.    impl ::core::marker::StructuralEq for UnaryOperation {}
  1553.    #[automatically_derived]
  1554.    impl ::core::cmp::Eq for UnaryOperation {
  1555.        #[inline]
  1556.        #[doc(hidden)]
  1557.        #[no_coverage]
  1558.        fn assert_receiver_is_total_eq(&self) -> () {}
  1559.    }
  1560.    #[automatically_derived]
  1561.    impl ::core::cmp::Ord for UnaryOperation {
  1562.        #[inline]
  1563.        fn cmp(&self, other: &UnaryOperation) -> ::core::cmp::Ordering {
  1564.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  1565.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  1566.            ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
  1567.        }
  1568.    }
  1569.    #[automatically_derived]
  1570.    impl ::core::cmp::PartialOrd for UnaryOperation {
  1571.        #[inline]
  1572.        fn partial_cmp(
  1573.            &self,
  1574.            other: &UnaryOperation,
  1575.        ) -> ::core::option::Option<::core::cmp::Ordering> {
  1576.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  1577.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  1578.            ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
  1579.        }
  1580.    }
  1581.    impl ::core::marker::StructuralPartialEq for UnaryOperation {}
  1582.    #[automatically_derived]
  1583.    impl ::core::cmp::PartialEq for UnaryOperation {
  1584.        #[inline]
  1585.        fn eq(&self, other: &UnaryOperation) -> bool {
  1586.            let __self_tag = ::core::intrinsics::discriminant_value(self);
  1587.            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  1588.            __self_tag == __arg1_tag
  1589.        }
  1590.    }
  1591.    impl TryFrom<TokenKind> for UnaryOperation {
  1592.        type Error = ();
  1593.        fn try_from(value: TokenKind) -> Result<Self, Self::Error> {
  1594.            match value {
  1595.                TokenKind::Exclamation => Ok(Self::Not),
  1596.                TokenKind::Minus => Ok(Self::Negate),
  1597.                _ => Err(()),
  1598.            }
  1599.        }
  1600.    }
  1601.    pub struct CallExpr {
  1602.        pub callee: ExprContainer,
  1603.        pub args: Vec<ExprContainer>,
  1604.    }
  1605.    #[automatically_derived]
  1606.    impl ::core::fmt::Debug for CallExpr {
  1607.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1608.            ::core::fmt::Formatter::debug_struct_field2_finish(
  1609.                f,
  1610.                "CallExpr",
  1611.                "callee",
  1612.                &&self.callee,
  1613.                "args",
  1614.                &&self.args,
  1615.            )
  1616.        }
  1617.    }
  1618.    #[automatically_derived]
  1619.    impl ::core::clone::Clone for CallExpr {
  1620.        #[inline]
  1621.        fn clone(&self) -> CallExpr {
  1622.            CallExpr {
  1623.                callee: ::core::clone::Clone::clone(&self.callee),
  1624.                args: ::core::clone::Clone::clone(&self.args),
  1625.            }
  1626.        }
  1627.    }
  1628.    impl ::core::marker::StructuralPartialEq for CallExpr {}
  1629.    #[automatically_derived]
  1630.    impl ::core::cmp::PartialEq for CallExpr {
  1631.        #[inline]
  1632.        fn eq(&self, other: &CallExpr) -> bool {
  1633.            self.callee == other.callee && self.args == other.args
  1634.        }
  1635.        #[inline]
  1636.        fn ne(&self, other: &CallExpr) -> bool {
  1637.            self.callee != other.callee || self.args != other.args
  1638.        }
  1639.    }
  1640.    pub struct NumberExpr {
  1641.        pub value: InternedString,
  1642.        pub kind: NumberKind,
  1643.    }
  1644.    #[automatically_derived]
  1645.    impl ::core::fmt::Debug for NumberExpr {
  1646.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1647.            ::core::fmt::Formatter::debug_struct_field2_finish(
  1648.                f,
  1649.                "NumberExpr",
  1650.                "value",
  1651.                &&self.value,
  1652.                "kind",
  1653.                &&self.kind,
  1654.            )
  1655.        }
  1656.    }
  1657.    #[automatically_derived]
  1658.    impl ::core::clone::Clone for NumberExpr {
  1659.        #[inline]
  1660.        fn clone(&self) -> NumberExpr {
  1661.            NumberExpr {
  1662.                value: ::core::clone::Clone::clone(&self.value),
  1663.                kind: ::core::clone::Clone::clone(&self.kind),
  1664.            }
  1665.        }
  1666.    }
  1667.    impl ::core::marker::StructuralPartialEq for NumberExpr {}
  1668.    #[automatically_derived]
  1669.    impl ::core::cmp::PartialEq for NumberExpr {
  1670.        #[inline]
  1671.        fn eq(&self, other: &NumberExpr) -> bool {
  1672.            self.value == other.value && self.kind == other.kind
  1673.        }
  1674.        #[inline]
  1675.        fn ne(&self, other: &NumberExpr) -> bool {
  1676.            self.value != other.value || self.kind != other.kind
  1677.        }
  1678.    }
  1679. }
  1680. mod diagnostics {
  1681.    use crate::memory::ValueAddr;
  1682.    use owo_colors::OwoColorize;
  1683.    use std::cmp::max;
  1684.    use std::fmt::{Display, Formatter};
  1685.    pub struct Diagnostic {
  1686.        pub span: Span,
  1687.        pub message: String,
  1688.        pub severity: Severity,
  1689.        pub code: ErrorCode,
  1690.    }
  1691.    #[automatically_derived]
  1692.    impl ::core::fmt::Debug for Diagnostic {
  1693.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1694.            ::core::fmt::Formatter::debug_struct_field4_finish(
  1695.                f,
  1696.                "Diagnostic",
  1697.                "span",
  1698.                &&self.span,
  1699.                "message",
  1700.                &&self.message,
  1701.                "severity",
  1702.                &&self.severity,
  1703.                "code",
  1704.                &&self.code,
  1705.            )
  1706.        }
  1707.    }
  1708.    #[automatically_derived]
  1709.    impl ::core::clone::Clone for Diagnostic {
  1710.        #[inline]
  1711.        fn clone(&self) -> Diagnostic {
  1712.            Diagnostic {
  1713.                span: ::core::clone::Clone::clone(&self.span),
  1714.                message: ::core::clone::Clone::clone(&self.message),
  1715.                severity: ::core::clone::Clone::clone(&self.severity),
  1716.                code: ::core::clone::Clone::clone(&self.code),
  1717.            }
  1718.        }
  1719.    }
  1720.    struct Pos {
  1721.        line: usize,
  1722.        column: usize,
  1723.    }
  1724.    #[automatically_derived]
  1725.    impl ::core::fmt::Debug for Pos {
  1726.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  1727.            ::core::fmt::Formatter::debug_struct_field2_finish(
  1728.                f,
  1729.                "Pos",
  1730.                "line",
  1731.                &&self.line,
  1732.                "column",
  1733.                &&self.column,
  1734.            )
  1735.        }
  1736.    }
  1737.    #[automatically_derived]
  1738.    impl ::core::clone::Clone for Pos {
  1739.        #[inline]
  1740.        fn clone(&self) -> Pos {
  1741.            let _: ::core::clone::AssertParamIsClone<usize>;
  1742.            *self
  1743.        }
  1744.    }
  1745.    #[automatically_derived]
  1746.    impl ::core::marker::Copy for Pos {}
  1747.    #[automatically_derived]
  1748.    impl ::core::cmp::Ord for Pos {
  1749.        #[inline]
  1750.        fn cmp(&self, other: &Pos) -> ::core::cmp::Ordering {
  1751.            match ::core::cmp::Ord::cmp(&self.line, &other.line) {
  1752.                ::core::cmp::Ordering::Equal => ::core::cmp::Ord::cmp(&self.column, &other.column),
  1753.                cmp => cmp,
  1754.            }
  1755.        }
  1756.    }
  1757.    #[automatically_derived]
  1758.    impl ::core::cmp::PartialOrd for Pos {
  1759.        #[inline]
  1760.        fn partial_cmp(&self, other: &Pos) -> ::core::option::Option<::core::cmp::Ordering> {
  1761.            match ::core::cmp::PartialOrd::partial_cmp(&self.line, &other.line) {
  1762.                ::core::option::Option::Some(::core::cmp::Ordering::Equal) => {
  1763.                    ::core::cmp::PartialOrd::partial_cmp(&self.column, &other.column)
  1764.                }
  1765.                cmp => cmp,
  1766.            }
  1767.        }
  1768.    }
  1769.    impl ::core::marker::StructuralEq for Pos {}
  1770.    #[automatically_derived]
  1771.    impl ::core::cmp::Eq for Pos {
  1772.        #[inline]
  1773.        #[doc(hidden)]
  1774.        #[no_coverage]
  1775.        fn assert_receiver_is_total_eq(&self) -> () {
  1776.            let _: ::core::cmp::AssertParamIsEq<usize>;
  1777.        }
  1778.    }
  1779.    impl ::core::marker::StructuralPartialEq for Pos {}
  1780.    #[automatically_derived]
  1781.    impl ::core::cmp::PartialEq for Pos {
  1782.        #[inline]
  1783.        fn eq(&self, other: &Pos) -> bool {
  1784.            self.line == other.line && self.column == other.column
  1785.        }
  1786.        #[inline]
  1787.        fn ne(&self, other: &Pos) -> bool {
  1788.            self.line != other.line || self.column != other.column
  1789.        }
  1790.    }
  1791.    impl Diagnostic {
  1792.        fn calculate_pos_for_n(&self, file: &str, n: usize) -> Pos {
  1793.            let mut line = 1;
  1794.            let mut column = 1;
  1795.            for (idx, ch) in file.chars().enumerate() {
  1796.                if idx == n {
  1797.                    break;
  1798.                }
  1799.                if ch == '\n' {
  1800.                    line += 1;
  1801.                    column = 1;
  1802.                } else {
  1803.                    column += 1;
  1804.                }
  1805.            }
  1806.            Pos { line, column }
  1807.        }
  1808.        fn max_line_number_size(pos1: Pos, pos2: Pos) -> usize {
  1809.            max(pos1.line.literal_size(), pos2.line.literal_size())
  1810.        }
  1811.        fn generate_line(
  1812.            buf: &mut String,
  1813.            line: &str,
  1814.            line_number: usize,
  1815.            max_line_number_size: usize,
  1816.        ) {
  1817.            buf.push_str(&{
  1818.                let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  1819.                    &["", " ", "\n"],
  1820.                    &[
  1821.                        ::core::fmt::ArgumentV1::new_display(
  1822.                            &{
  1823.                                let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  1824.                                    &["", "", "|"],
  1825.                                    &[
  1826.                                        ::core::fmt::ArgumentV1::new_display(&line_number),
  1827.                                        ::core::fmt::ArgumentV1::new_display(&" ".repeat(
  1828.                                            max_line_number_size - line_number.literal_size() + 1,
  1829.                                        )),
  1830.                                    ],
  1831.                                ));
  1832.                                res
  1833.                            }
  1834.                            .bright_blue()
  1835.                            .bold(),
  1836.                        ),
  1837.                        ::core::fmt::ArgumentV1::new_display(&line),
  1838.                    ],
  1839.                ));
  1840.                res
  1841.            });
  1842.        }
  1843.        fn write_marker(buf: &mut String, blank_line: &str, padding: usize, count: usize) {
  1844.            if count == 0 {
  1845.                return;
  1846.            }
  1847.            buf.push_str(&{
  1848.                let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  1849.                    &["", "", "", "\n"],
  1850.                    &[
  1851.                        ::core::fmt::ArgumentV1::new_display(&blank_line),
  1852.                        ::core::fmt::ArgumentV1::new_display(&" ".repeat(padding - 1)),
  1853.                        ::core::fmt::ArgumentV1::new_display(
  1854.                            &"^".repeat(count).bright_yellow().bold(),
  1855.                        ),
  1856.                    ],
  1857.                ));
  1858.                res
  1859.            });
  1860.        }
  1861.        fn write_pos(
  1862.            &self,
  1863.            buf: &mut String,
  1864.            lines: &[&str],
  1865.            blank_line: &str,
  1866.            starting_pos: Pos,
  1867.            ending_pos: Pos,
  1868.            max_line_num_size: usize,
  1869.            print_trailing_empty_line: bool,
  1870.        ) {
  1871.            for line_num in starting_pos.line..ending_pos.line + 1 {
  1872.                let line = lines[line_num - 1].replace('\t', "    ");
  1873.                if !print_trailing_empty_line && line_num == ending_pos.line && line.is_empty() {
  1874.                    break;
  1875.                }
  1876.                let tab_count = count_tab_until(lines[line_num - 1], starting_pos.column);
  1877.                let padding = if line_num == starting_pos.line {
  1878.                    (starting_pos.column + tab_count * 4)
  1879.                        .checked_sub(tab_count)
  1880.                        .unwrap_or_default()
  1881.                } else {
  1882.                    0
  1883.                };
  1884.                let count;
  1885.                if starting_pos.line == ending_pos.line {
  1886.                    if starting_pos.column == ending_pos.column {
  1887.                        count = 1;
  1888.                    } else {
  1889.                        let tab_count_until_end =
  1890.                            tab_count - count_tab_until(lines[line_num - 1], ending_pos.column);
  1891.                        count =
  1892.                            (ending_pos.column - starting_pos.column) + 1 + 4 * tab_count_until_end
  1893.                                - tab_count_until_end;
  1894.                    }
  1895.                } else if line_num == starting_pos.line {
  1896.                    count = line.len() - padding;
  1897.                } else if line_num == ending_pos.line {
  1898.                    let tab_count_until_end =
  1899.                        count_tab_until(lines[line_num - 1], ending_pos.column);
  1900.                    count = ending_pos.column + 1 + tab_count_until_end * 4 - tab_count_until_end;
  1901.                } else {
  1902.                    count = line.len() - padding;
  1903.                }
  1904.                Self::generate_line(buf, &line, line_num, max_line_num_size);
  1905.                Self::write_marker(buf, blank_line, padding + 1, count);
  1906.            }
  1907.        }
  1908.        fn pos_to_string(pos1: Pos, pos2: Pos) -> String {
  1909.            if pos1 == pos2 {
  1910.                {
  1911.                    let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  1912.                        &["", ":"],
  1913.                        &[
  1914.                            ::core::fmt::ArgumentV1::new_display(&pos1.line),
  1915.                            ::core::fmt::ArgumentV1::new_display(&pos1.column),
  1916.                        ],
  1917.                    ));
  1918.                    res
  1919.                }
  1920.            } else {
  1921.                {
  1922.                    let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  1923.                        &["", ":", "-", ":"],
  1924.                        &[
  1925.                            ::core::fmt::ArgumentV1::new_display(&pos1.line),
  1926.                            ::core::fmt::ArgumentV1::new_display(&pos1.column),
  1927.                            ::core::fmt::ArgumentV1::new_display(&pos2.line),
  1928.                            ::core::fmt::ArgumentV1::new_display(&pos2.column),
  1929.                        ],
  1930.                    ));
  1931.                    res
  1932.                }
  1933.            }
  1934.        }
  1935.        pub fn display(&self, file_name: &str, file_content: &str) -> String {
  1936.            let mut buf = String::new();
  1937.            let lines = file_content.split('\n').collect::<Vec<&str>>();
  1938.            let starting_pos = self.calculate_pos_for_n(file_content, self.span.lo);
  1939.            let ending_pos = self.calculate_pos_for_n(file_content, self.span.hi);
  1940.            let max_line_num_size = Self::max_line_number_size(starting_pos, ending_pos);
  1941.            let blank_line = {
  1942.                let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  1943.                    &["", " |"],
  1944.                    &[::core::fmt::ArgumentV1::new_display(
  1945.                        &" ".repeat(max_line_num_size),
  1946.                    )],
  1947.                ));
  1948.                res
  1949.            }
  1950.            .bright_blue()
  1951.            .bold()
  1952.            .to_string();
  1953.            let blank_line_with_newline = blank_line.clone() + "\n";
  1954.            buf.push_str(&{
  1955.                let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  1956.                    &["", ": ", "\n"],
  1957.                    &[
  1958.                        ::core::fmt::ArgumentV1::new_display(
  1959.                            &if self.severity == Severity::Error {
  1960.                                {
  1961.                                    let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  1962.                                        &["", "[", "]"],
  1963.                                        &[
  1964.                                            ::core::fmt::ArgumentV1::new_display(&"error"),
  1965.                                            ::core::fmt::ArgumentV1::new_display(&self.code),
  1966.                                        ],
  1967.                                    ));
  1968.                                    res
  1969.                                }
  1970.                                .bright_red()
  1971.                                .bold()
  1972.                                .to_string()
  1973.                            } else if self.severity == Severity::Warning {
  1974.                                {
  1975.                                    let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  1976.                                        &["", "[", "]"],
  1977.                                        &[
  1978.                                            ::core::fmt::ArgumentV1::new_display(&"warning"),
  1979.                                            ::core::fmt::ArgumentV1::new_display(&self.code),
  1980.                                        ],
  1981.                                    ));
  1982.                                    res
  1983.                                }
  1984.                                .bright_yellow()
  1985.                                .bold()
  1986.                                .to_string()
  1987.                            } else {
  1988.                                "info".to_string().bright_blue().bold().to_string()
  1989.                            },
  1990.                        ),
  1991.                        ::core::fmt::ArgumentV1::new_display(&self.message),
  1992.                    ],
  1993.                ));
  1994.                res
  1995.            });
  1996.            buf.push_str(&{
  1997.                let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  1998.                    &["", "", " ", ":", "\n"],
  1999.                    &[
  2000.                        ::core::fmt::ArgumentV1::new_display(&" ".repeat(max_line_num_size)),
  2001.                        ::core::fmt::ArgumentV1::new_display(&"-->".bright_blue().bold()),
  2002.                        ::core::fmt::ArgumentV1::new_display(&file_name),
  2003.                        ::core::fmt::ArgumentV1::new_display(&Self::pos_to_string(
  2004.                            starting_pos,
  2005.                            ending_pos,
  2006.                        )),
  2007.                    ],
  2008.                ));
  2009.                res
  2010.            });
  2011.            buf.push_str(&blank_line_with_newline);
  2012.            self.write_pos(
  2013.                &mut buf,
  2014.                &lines,
  2015.                &blank_line,
  2016.                starting_pos,
  2017.                ending_pos,
  2018.                max_line_num_size,
  2019.                true,
  2020.            );
  2021.            buf.push_str(&blank_line_with_newline);
  2022.            buf.push_str(
  2023.                &{
  2024.                    let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  2025.                        &[
  2026.                            "For more information about this error, try `",
  2027.                            " explain ",
  2028.                            "`\n",
  2029.                        ],
  2030.                        &[
  2031.                            ::core::fmt::ArgumentV1::new_display(&std::env::args().next().unwrap()),
  2032.                            ::core::fmt::ArgumentV1::new_display(&self.code),
  2033.                        ],
  2034.                    ));
  2035.                    res
  2036.                }
  2037.                .bold()
  2038.                .to_string(),
  2039.            );
  2040.            buf
  2041.        }
  2042.    }
  2043.    fn count_tab_until(line: &str, offset: usize) -> usize {
  2044.        let mut count = 0;
  2045.        for (idx, ch) in line.chars().enumerate() {
  2046.            if ch == '\t' {
  2047.                count += 1;
  2048.            }
  2049.            if idx == offset {
  2050.                break;
  2051.            }
  2052.        }
  2053.        count
  2054.    }
  2055.    pub enum ErrorCode {
  2056.        UnknownToken,
  2057.        InvalidNumber,
  2058.        UnterminatedString,
  2059.        UnexpectedToken,
  2060.        InvalidAssignment,
  2061.        InvalidLoopControl,
  2062.        UndefinedVariable,
  2063.        UndefinedFunction,
  2064.        InvalidBinaryOperation,
  2065.        InvalidUnaryOperation,
  2066.        InvalidEscapeCharacter,
  2067.        InvalidType,
  2068.        ArityError,
  2069.        Return(ValueAddr),
  2070.        InvalidDataPropertySet,
  2071.        MissingProp,
  2072.        UnknownProp,
  2073.        MutabilityError,
  2074.        Break,
  2075.        Continue,
  2076.    }
  2077.    #[automatically_derived]
  2078.    impl ::core::fmt::Debug for ErrorCode {
  2079.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  2080.            match self {
  2081.                ErrorCode::UnknownToken => ::core::fmt::Formatter::write_str(f, "UnknownToken"),
  2082.                ErrorCode::InvalidNumber => ::core::fmt::Formatter::write_str(f, "InvalidNumber"),
  2083.                ErrorCode::UnterminatedString => {
  2084.                    ::core::fmt::Formatter::write_str(f, "UnterminatedString")
  2085.                }
  2086.                ErrorCode::UnexpectedToken => {
  2087.                    ::core::fmt::Formatter::write_str(f, "UnexpectedToken")
  2088.                }
  2089.                ErrorCode::InvalidAssignment => {
  2090.                    ::core::fmt::Formatter::write_str(f, "InvalidAssignment")
  2091.                }
  2092.                ErrorCode::InvalidLoopControl => {
  2093.                    ::core::fmt::Formatter::write_str(f, "InvalidLoopControl")
  2094.                }
  2095.                ErrorCode::UndefinedVariable => {
  2096.                    ::core::fmt::Formatter::write_str(f, "UndefinedVariable")
  2097.                }
  2098.                ErrorCode::UndefinedFunction => {
  2099.                    ::core::fmt::Formatter::write_str(f, "UndefinedFunction")
  2100.                }
  2101.                ErrorCode::InvalidBinaryOperation => {
  2102.                    ::core::fmt::Formatter::write_str(f, "InvalidBinaryOperation")
  2103.                }
  2104.                ErrorCode::InvalidUnaryOperation => {
  2105.                    ::core::fmt::Formatter::write_str(f, "InvalidUnaryOperation")
  2106.                }
  2107.                ErrorCode::InvalidEscapeCharacter => {
  2108.                    ::core::fmt::Formatter::write_str(f, "InvalidEscapeCharacter")
  2109.                }
  2110.                ErrorCode::InvalidType => ::core::fmt::Formatter::write_str(f, "InvalidType"),
  2111.                ErrorCode::ArityError => ::core::fmt::Formatter::write_str(f, "ArityError"),
  2112.                ErrorCode::Return(__self_0) => {
  2113.                    ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Return", &__self_0)
  2114.                }
  2115.                ErrorCode::InvalidDataPropertySet => {
  2116.                    ::core::fmt::Formatter::write_str(f, "InvalidDataPropertySet")
  2117.                }
  2118.                ErrorCode::MissingProp => ::core::fmt::Formatter::write_str(f, "MissingProp"),
  2119.                ErrorCode::UnknownProp => ::core::fmt::Formatter::write_str(f, "UnknownProp"),
  2120.                ErrorCode::MutabilityError => {
  2121.                    ::core::fmt::Formatter::write_str(f, "MutabilityError")
  2122.                }
  2123.                ErrorCode::Break => ::core::fmt::Formatter::write_str(f, "Break"),
  2124.                ErrorCode::Continue => ::core::fmt::Formatter::write_str(f, "Continue"),
  2125.            }
  2126.        }
  2127.    }
  2128.    #[automatically_derived]
  2129.    impl ::core::marker::Copy for ErrorCode {}
  2130.    #[automatically_derived]
  2131.    impl ::core::clone::Clone for ErrorCode {
  2132.        #[inline]
  2133.        fn clone(&self) -> ErrorCode {
  2134.            let _: ::core::clone::AssertParamIsClone<ValueAddr>;
  2135.            *self
  2136.        }
  2137.    }
  2138.    impl Display for ErrorCode {
  2139.        fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
  2140.             match self {
  2141.                 ErrorCode::UnknownToken => {
  2142.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0001"], &[]))
  2143.                 }
  2144.                 ErrorCode::InvalidNumber => {
  2145.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0002"], &[]))
  2146.                 }
  2147.                 ErrorCode::UnterminatedString => {
  2148.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0003"], &[]))
  2149.                 }
  2150.                 ErrorCode::UnexpectedToken => {
  2151.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0004"], &[]))
  2152.                 }
  2153.                 ErrorCode::InvalidAssignment => {
  2154.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0005"], &[]))
  2155.                 }
  2156.                 ErrorCode::InvalidLoopControl => {
  2157.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0006"], &[]))
  2158.                 }
  2159.                 ErrorCode::UndefinedVariable => {
  2160.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0007"], &[]))
  2161.                 }
  2162.                 ErrorCode::UndefinedFunction => {
  2163.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0008"], &[]))
  2164.                 }
  2165.                 ErrorCode::InvalidBinaryOperation => {
  2166.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0009"], &[]))
  2167.                 }
  2168.                 ErrorCode::InvalidEscapeCharacter => {
  2169.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0010"], &[]))
  2170.                 }
  2171.                 ErrorCode::InvalidUnaryOperation => {
  2172.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0012"], &[]))
  2173.                 }
  2174.                 ErrorCode::InvalidType => {
  2175.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0013"], &[]))
  2176.                 }
  2177.                 ErrorCode::ArityError => {
  2178.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0014"], &[]))
  2179.                 }
  2180.                 ErrorCode::Return(_) => {
  2181.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0000"], &[]))
  2182.                 }
  2183.                 ErrorCode::InvalidDataPropertySet => {
  2184.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0015"], &[]))
  2185.                 }
  2186.                 ErrorCode::MissingProp => {
  2187.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0016"], &[]))
  2188.                 }
  2189.                 ErrorCode::UnknownProp => {
  2190.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0017"], &[]))
  2191.                 }
  2192.                 ErrorCode::MutabilityError => {
  2193.                     f.write_fmt(::core::fmt::Arguments::new_v1(&["E0018"], &[]))
  2194.                 }
  2195.                 ErrorCode::Break => f.write_fmt(::core::fmt::Arguments::new_v1(&["E0000"], &[])),
  2196.                 ErrorCode::Continue => f.write_fmt(::core::fmt::Arguments::new_v1(&["E0000"], &[])),
  2197.             }
  2198.         }
  2199.     }
  2200.     pub enum Severity {
  2201.         Error,
  2202.         Warning,
  2203.         Info,
  2204.     }
  2205.     #[automatically_derived]
  2206.     impl ::core::fmt::Debug for Severity {
  2207.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  2208.             match self {
  2209.                 Severity::Error => ::core::fmt::Formatter::write_str(f, "Error"),
  2210.                 Severity::Warning => ::core::fmt::Formatter::write_str(f, "Warning"),
  2211.                 Severity::Info => ::core::fmt::Formatter::write_str(f, "Info"),
  2212.             }
  2213.         }
  2214.     }
  2215.     #[automatically_derived]
  2216.     impl ::core::marker::Copy for Severity {}
  2217.     #[automatically_derived]
  2218.     impl ::core::clone::Clone for Severity {
  2219.         #[inline]
  2220.         fn clone(&self) -> Severity {
  2221.             *self
  2222.         }
  2223.     }
  2224.     #[automatically_derived]
  2225.     impl ::core::cmp::Ord for Severity {
  2226.         #[inline]
  2227.         fn cmp(&self, other: &Severity) -> ::core::cmp::Ordering {
  2228.             let __self_tag = ::core::intrinsics::discriminant_value(self);
  2229.             let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  2230.             ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
  2231.         }
  2232.     }
  2233.     #[automatically_derived]
  2234.     impl ::core::cmp::PartialOrd for Severity {
  2235.         #[inline]
  2236.         fn partial_cmp(&self, other: &Severity) -> ::core::option::Option<::core::cmp::Ordering> {
  2237.             let __self_tag = ::core::intrinsics::discriminant_value(self);
  2238.             let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  2239.             ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
  2240.         }
  2241.     }
  2242.     impl ::core::marker::StructuralEq for Severity {}
  2243.     #[automatically_derived]
  2244.     impl ::core::cmp::Eq for Severity {
  2245.         #[inline]
  2246.         #[doc(hidden)]
  2247.         #[no_coverage]
  2248.         fn assert_receiver_is_total_eq(&self) -> () {}
  2249.     }
  2250.     impl ::core::marker::StructuralPartialEq for Severity {}
  2251.     #[automatically_derived]
  2252.     impl ::core::cmp::PartialEq for Severity {
  2253.         #[inline]
  2254.         fn eq(&self, other: &Severity) -> bool {
  2255.             let __self_tag = ::core::intrinsics::discriminant_value(self);
  2256.             let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  2257.             __self_tag == __arg1_tag
  2258.         }
  2259.     }
  2260.     impl Display for Severity {
  2261.         fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
  2262.            let s = match self {
  2263.                Severity::Error => "error",
  2264.                Severity::Warning => "warning",
  2265.                Severity::Info => "info",
  2266.            };
  2267.            f.write_fmt(::core::fmt::Arguments::new_v1(
  2268.                &[""],
  2269.                &[::core::fmt::ArgumentV1::new_display(&s)],
  2270.            ))
  2271.        }
  2272.    }
  2273.    pub struct Span {
  2274.        pub lo: usize,
  2275.        pub hi: usize,
  2276.    }
  2277.    #[automatically_derived]
  2278.    impl ::core::fmt::Debug for Span {
  2279.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  2280.            ::core::fmt::Formatter::debug_struct_field2_finish(
  2281.                f, "Span", "lo", &&self.lo, "hi", &&self.hi,
  2282.            )
  2283.        }
  2284.    }
  2285.    #[automatically_derived]
  2286.    impl ::core::marker::Copy for Span {}
  2287.    #[automatically_derived]
  2288.    impl ::core::clone::Clone for Span {
  2289.        #[inline]
  2290.        fn clone(&self) -> Span {
  2291.            let _: ::core::clone::AssertParamIsClone<usize>;
  2292.            *self
  2293.        }
  2294.    }
  2295.    #[automatically_derived]
  2296.    impl ::core::cmp::Ord for Span {
  2297.        #[inline]
  2298.        fn cmp(&self, other: &Span) -> ::core::cmp::Ordering {
  2299.            match ::core::cmp::Ord::cmp(&self.lo, &other.lo) {
  2300.                ::core::cmp::Ordering::Equal => ::core::cmp::Ord::cmp(&self.hi, &other.hi),
  2301.                cmp => cmp,
  2302.            }
  2303.        }
  2304.    }
  2305.    #[automatically_derived]
  2306.    impl ::core::cmp::PartialOrd for Span {
  2307.        #[inline]
  2308.        fn partial_cmp(&self, other: &Span) -> ::core::option::Option<::core::cmp::Ordering> {
  2309.            match ::core::cmp::PartialOrd::partial_cmp(&self.lo, &other.lo) {
  2310.                ::core::option::Option::Some(::core::cmp::Ordering::Equal) => {
  2311.                    ::core::cmp::PartialOrd::partial_cmp(&self.hi, &other.hi)
  2312.                }
  2313.                cmp => cmp,
  2314.            }
  2315.        }
  2316.    }
  2317.    impl ::core::marker::StructuralEq for Span {}
  2318.    #[automatically_derived]
  2319.    impl ::core::cmp::Eq for Span {
  2320.        #[inline]
  2321.        #[doc(hidden)]
  2322.        #[no_coverage]
  2323.        fn assert_receiver_is_total_eq(&self) -> () {
  2324.            let _: ::core::cmp::AssertParamIsEq<usize>;
  2325.        }
  2326.    }
  2327.    impl ::core::marker::StructuralPartialEq for Span {}
  2328.    #[automatically_derived]
  2329.    impl ::core::cmp::PartialEq for Span {
  2330.        #[inline]
  2331.        fn eq(&self, other: &Span) -> bool {
  2332.            self.lo == other.lo && self.hi == other.hi
  2333.        }
  2334.        #[inline]
  2335.        fn ne(&self, other: &Span) -> bool {
  2336.            self.lo != other.lo || self.hi != other.hi
  2337.        }
  2338.    }
  2339.    impl Span {
  2340.        pub fn new(lo: usize, hi: usize) -> Self {
  2341.            Self { lo, hi }
  2342.        }
  2343.        pub fn merge(self, s2: Span) -> Self {
  2344.            Self {
  2345.                lo: self.lo,
  2346.                hi: s2.hi,
  2347.            }
  2348.        }
  2349.    }
  2350.    trait LiteralSize {
  2351.        fn literal_size(self) -> usize;
  2352.    }
  2353.    impl LiteralSize for usize {
  2354.        fn literal_size(self) -> usize {
  2355.            (0..).take_while(|i| 10usize.pow(*i) <= self).count()
  2356.        }
  2357.    }
  2358. }
  2359. mod interner {
  2360.    use parking_lot::RwLock;
  2361.    pub struct InternedString(usize);
  2362.    #[automatically_derived]
  2363.    impl ::core::fmt::Debug for InternedString {
  2364.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  2365.            ::core::fmt::Formatter::debug_tuple_field1_finish(f, "InternedString", &&self.0)
  2366.        }
  2367.    }
  2368.    #[automatically_derived]
  2369.    impl ::core::marker::Copy for InternedString {}
  2370.    #[automatically_derived]
  2371.    impl ::core::clone::Clone for InternedString {
  2372.        #[inline]
  2373.        fn clone(&self) -> InternedString {
  2374.            let _: ::core::clone::AssertParamIsClone<usize>;
  2375.            *self
  2376.        }
  2377.    }
  2378.    #[automatically_derived]
  2379.    impl ::core::default::Default for InternedString {
  2380.        #[inline]
  2381.        fn default() -> InternedString {
  2382.            InternedString(::core::default::Default::default())
  2383.        }
  2384.    }
  2385.    impl ::core::marker::StructuralPartialEq for InternedString {}
  2386.    #[automatically_derived]
  2387.    impl ::core::cmp::PartialEq for InternedString {
  2388.        #[inline]
  2389.        fn eq(&self, other: &InternedString) -> bool {
  2390.            self.0 == other.0
  2391.        }
  2392.        #[inline]
  2393.        fn ne(&self, other: &InternedString) -> bool {
  2394.            self.0 != other.0
  2395.        }
  2396.    }
  2397.    #[automatically_derived]
  2398.    impl ::core::cmp::PartialOrd for InternedString {
  2399.        #[inline]
  2400.        fn partial_cmp(
  2401.            &self,
  2402.            other: &InternedString,
  2403.        ) -> ::core::option::Option<::core::cmp::Ordering> {
  2404.            ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
  2405.        }
  2406.    }
  2407.    impl ::core::marker::StructuralEq for InternedString {}
  2408.    #[automatically_derived]
  2409.    impl ::core::cmp::Eq for InternedString {
  2410.        #[inline]
  2411.        #[doc(hidden)]
  2412.        #[no_coverage]
  2413.        fn assert_receiver_is_total_eq(&self) -> () {
  2414.            let _: ::core::cmp::AssertParamIsEq<usize>;
  2415.        }
  2416.    }
  2417.    #[automatically_derived]
  2418.    impl ::core::cmp::Ord for InternedString {
  2419.        #[inline]
  2420.        fn cmp(&self, other: &InternedString) -> ::core::cmp::Ordering {
  2421.            ::core::cmp::Ord::cmp(&self.0, &other.0)
  2422.        }
  2423.    }
  2424.    #[automatically_derived]
  2425.    impl ::core::hash::Hash for InternedString {
  2426.        fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
  2427.            ::core::hash::Hash::hash(&self.0, state)
  2428.        }
  2429.    }
  2430.    pub struct InternedValue(usize);
  2431.    #[automatically_derived]
  2432.    impl ::core::fmt::Debug for InternedValue {
  2433.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  2434.            ::core::fmt::Formatter::debug_tuple_field1_finish(f, "InternedValue", &&self.0)
  2435.        }
  2436.    }
  2437.    #[automatically_derived]
  2438.    impl ::core::marker::Copy for InternedValue {}
  2439.    #[automatically_derived]
  2440.    impl ::core::clone::Clone for InternedValue {
  2441.        #[inline]
  2442.        fn clone(&self) -> InternedValue {
  2443.            let _: ::core::clone::AssertParamIsClone<usize>;
  2444.            *self
  2445.        }
  2446.    }
  2447.    impl ::core::marker::StructuralPartialEq for InternedValue {}
  2448.    #[automatically_derived]
  2449.    impl ::core::cmp::PartialEq for InternedValue {
  2450.        #[inline]
  2451.        fn eq(&self, other: &InternedValue) -> bool {
  2452.            self.0 == other.0
  2453.        }
  2454.        #[inline]
  2455.        fn ne(&self, other: &InternedValue) -> bool {
  2456.            self.0 != other.0
  2457.        }
  2458.    }
  2459.    #[automatically_derived]
  2460.    impl ::core::cmp::PartialOrd for InternedValue {
  2461.        #[inline]
  2462.        fn partial_cmp(
  2463.            &self,
  2464.            other: &InternedValue,
  2465.        ) -> ::core::option::Option<::core::cmp::Ordering> {
  2466.            ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
  2467.        }
  2468.    }
  2469.    impl ::core::marker::StructuralEq for InternedValue {}
  2470.    #[automatically_derived]
  2471.    impl ::core::cmp::Eq for InternedValue {
  2472.        #[inline]
  2473.        #[doc(hidden)]
  2474.        #[no_coverage]
  2475.        fn assert_receiver_is_total_eq(&self) -> () {
  2476.            let _: ::core::cmp::AssertParamIsEq<usize>;
  2477.        }
  2478.    }
  2479.    #[automatically_derived]
  2480.    impl ::core::cmp::Ord for InternedValue {
  2481.        #[inline]
  2482.        fn cmp(&self, other: &InternedValue) -> ::core::cmp::Ordering {
  2483.            ::core::cmp::Ord::cmp(&self.0, &other.0)
  2484.        }
  2485.    }
  2486.    pub static INTERNER: RwLock<Interner> = RwLock::new(Interner::new());
  2487.    pub struct Interner {
  2488.        strings: Vec<String>,
  2489.    }
  2490.    #[automatically_derived]
  2491.    impl ::core::fmt::Debug for Interner {
  2492.        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  2493.            ::core::fmt::Formatter::debug_struct_field1_finish(
  2494.                f,
  2495.                "Interner",
  2496.                "strings",
  2497.                &&self.strings,
  2498.            )
  2499.        }
  2500.    }
  2501.    impl Interner {
  2502.        pub const fn new() -> Self {
  2503.            Self {
  2504.                strings: Vec::new(),
  2505.            }
  2506.        }
  2507.        pub fn intern_string(&mut self, string: String) -> InternedString {
  2508.            for (idx, interned_string) in self.strings.iter().enumerate() {
  2509.                if interned_string == &string {
  2510.                    return InternedString(idx);
  2511.                }
  2512.            }
  2513.            let id = self.strings.len();
  2514.            self.strings.push(string);
  2515.            InternedString(id)
  2516.        }
  2517.        pub fn get_interned_string(&self, id: InternedString) -> &str {
  2518.            &self.strings[id.0]
  2519.        }
  2520.    }
  2521. }
  2522. mod interp {
  2523.    use crate::ast::{
  2524.        BinaryOperation, Expr, ExprContainer, FunStmt, LogicalOperation, Mutable, Stmt,
  2525.        StmtContainer, UnaryOperation,
  2526.    };
  2527.    use crate::diagnostics::{Diagnostic, ErrorCode, Severity, Span};
  2528.    use crate::interner::{InternedString, INTERNER};
  2529.    use crate::lexer::NumberKind;
  2530.    use crate::memory::{Allocator, Callable, DataObject, Value, ValueAddr};
  2531.    use crate::native::{
  2532.        ArrayPopFunction, FloatFunction, InputFunction, IntFunction, PrintFunction,
  2533.        PrintlnFunction, SleepFunction,
  2534.    };
  2535.    use crate::Session;
  2536.    use std::cell::RefCell;
  2537.    use std::collections::HashMap;
  2538.    use std::str::FromStr;
  2539.    pub struct Interpreter<'i> {
  2540.         allocator: Allocator,
  2541.         session: RefCell<&'i mut Session>,
  2542.        envs: RefCell<HashMap<InternedString, Vec<Scope>>>,
  2543.        current: InternedString,
  2544.        context: Vec<InterpreterContext>,
  2545.    }
  2546.    impl<'i> Interpreter<'i> {
  2547.        pub fn new(session: &'i mut Session) -> Self {
  2548.             Self {
  2549.                 allocator: Allocator::new(),
  2550.                 session: RefCell::new(session),
  2551.                 envs: RefCell::new(HashMap::new()),
  2552.                 current: InternedString::default(),
  2553.                 context: alloc::vec::Vec::new(),
  2554.             }
  2555.         }
  2556.         pub fn init(&mut self) -> bool {
  2557.             self.session.borrow_mut().parse_entrypoint();
  2558.             let session = self.session.borrow();
  2559.             if session.has_diagnostics() {
  2560.                 session.print_diagnostics();
  2561.                 return false;
  2562.             }
  2563.             self.current = session.entry_point;
  2564.             let ast = session.get_ast(self.current);
  2565.             if let Err(e) = Self::prepare_global_env_for_module(
  2566.                 self.current,
  2567.                 ast,
  2568.                 &self.envs,
  2569.                 &mut self.allocator,
  2570.             ) {
  2571.                 {
  2572.                     ::std::io::_eprint(::core::fmt::Arguments::new_v1(
  2573.                         &["", "\n"],
  2574.                         &[::core::fmt::ArgumentV1::new_display(&e.display(
  2575.                             INTERNER.read().get_interned_string(self.current),
  2576.                             &session.files[&self.current],
  2577.                         ))],
  2578.                     ));
  2579.                 };
  2580.                 return false;
  2581.             };
  2582.             if session.debug {
  2583.                 match &self.envs {
  2584.                     tmp => {
  2585.                         {
  2586.                             ::std::io::_eprint(::core::fmt::Arguments::new_v1_formatted(
  2587.                                 &["[", ":", "] ", " = ", "\n"],
  2588.                                 &match (&"src/interp.rs", &59u32, &"&self.envs", &&tmp) {
  2589.                                     args => [
  2590.                                         ::core::fmt::ArgumentV1::new_display(args.0),
  2591.                                         ::core::fmt::ArgumentV1::new_display(args.1),
  2592.                                         ::core::fmt::ArgumentV1::new_display(args.2),
  2593.                                         ::core::fmt::ArgumentV1::new_debug(args.3),
  2594.                                     ],
  2595.                                 },
  2596.                                 &[
  2597.                                     ::core::fmt::rt::v1::Argument {
  2598.                                         position: 0usize,
  2599.                                         format: ::core::fmt::rt::v1::FormatSpec {
  2600.                                             fill: ' ',
  2601.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  2602.                                             flags: 0u32,
  2603.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  2604.                                             width: ::core::fmt::rt::v1::Count::Implied,
  2605.                                         },
  2606.                                     },
  2607.                                     ::core::fmt::rt::v1::Argument {
  2608.                                         position: 1usize,
  2609.                                         format: ::core::fmt::rt::v1::FormatSpec {
  2610.                                             fill: ' ',
  2611.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  2612.                                             flags: 0u32,
  2613.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  2614.                                             width: ::core::fmt::rt::v1::Count::Implied,
  2615.                                         },
  2616.                                     },
  2617.                                     ::core::fmt::rt::v1::Argument {
  2618.                                         position: 2usize,
  2619.                                         format: ::core::fmt::rt::v1::FormatSpec {
  2620.                                             fill: ' ',
  2621.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  2622.                                             flags: 0u32,
  2623.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  2624.                                             width: ::core::fmt::rt::v1::Count::Implied,
  2625.                                         },
  2626.                                     },
  2627.                                     ::core::fmt::rt::v1::Argument {
  2628.                                         position: 3usize,
  2629.                                         format: ::core::fmt::rt::v1::FormatSpec {
  2630.                                             fill: ' ',
  2631.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  2632.                                             flags: 4u32,
  2633.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  2634.                                             width: ::core::fmt::rt::v1::Count::Implied,
  2635.                                         },
  2636.                                     },
  2637.                                 ],
  2638.                                 unsafe { ::core::fmt::UnsafeArg::new() },
  2639.                             ));
  2640.                         };
  2641.                         tmp
  2642.                     }
  2643.                 };
  2644.                 match ast {
  2645.                     tmp => {
  2646.                         {
  2647.                             ::std::io::_eprint(::core::fmt::Arguments::new_v1_formatted(
  2648.                                 &["[", ":", "] ", " = ", "\n"],
  2649.                                 &match (&"src/interp.rs", &60u32, &"ast", &&tmp) {
  2650.                                     args => [
  2651.                                         ::core::fmt::ArgumentV1::new_display(args.0),
  2652.                                         ::core::fmt::ArgumentV1::new_display(args.1),
  2653.                                         ::core::fmt::ArgumentV1::new_display(args.2),
  2654.                                         ::core::fmt::ArgumentV1::new_debug(args.3),
  2655.                                     ],
  2656.                                 },
  2657.                                 &[
  2658.                                     ::core::fmt::rt::v1::Argument {
  2659.                                         position: 0usize,
  2660.                                         format: ::core::fmt::rt::v1::FormatSpec {
  2661.                                             fill: ' ',
  2662.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  2663.                                             flags: 0u32,
  2664.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  2665.                                             width: ::core::fmt::rt::v1::Count::Implied,
  2666.                                         },
  2667.                                     },
  2668.                                     ::core::fmt::rt::v1::Argument {
  2669.                                         position: 1usize,
  2670.                                         format: ::core::fmt::rt::v1::FormatSpec {
  2671.                                             fill: ' ',
  2672.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  2673.                                             flags: 0u32,
  2674.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  2675.                                             width: ::core::fmt::rt::v1::Count::Implied,
  2676.                                         },
  2677.                                     },
  2678.                                     ::core::fmt::rt::v1::Argument {
  2679.                                         position: 2usize,
  2680.                                         format: ::core::fmt::rt::v1::FormatSpec {
  2681.                                             fill: ' ',
  2682.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  2683.                                             flags: 0u32,
  2684.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  2685.                                             width: ::core::fmt::rt::v1::Count::Implied,
  2686.                                         },
  2687.                                     },
  2688.                                     ::core::fmt::rt::v1::Argument {
  2689.                                         position: 3usize,
  2690.                                         format: ::core::fmt::rt::v1::FormatSpec {
  2691.                                             fill: ' ',
  2692.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  2693.                                             flags: 4u32,
  2694.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  2695.                                             width: ::core::fmt::rt::v1::Count::Implied,
  2696.                                         },
  2697.                                     },
  2698.                                 ],
  2699.                                 unsafe { ::core::fmt::UnsafeArg::new() },
  2700.                             ));
  2701.                         };
  2702.                         tmp
  2703.                     }
  2704.                 };
  2705.             }
  2706.             true
  2707.         }
  2708.         pub fn interpret(&mut self) {
  2709.             let session = self.session.borrow();
  2710.             let ast = session.get_ast(self.current).to_vec();
  2711.             drop(session);
  2712.             if let Err(e) = self.interpret_ast(&ast) {
  2713.                 {
  2714.                     ::std::io::_eprint(::core::fmt::Arguments::new_v1(
  2715.                         &["", "\n"],
  2716.                         &[::core::fmt::ArgumentV1::new_display(&e.display(
  2717.                             INTERNER.read().get_interned_string(self.current),
  2718.                             &self.session.borrow().files[&self.current],
  2719.                         ))],
  2720.                     ));
  2721.                 };
  2722.             }
  2723.         }
  2724.         pub fn interpret_ast(&mut self, ast: &[StmtContainer]) -> Result<(), Diagnostic> {
  2725.             for stmt in ast {
  2726.                 if let Stmt::Fun(fs) = &stmt.stmt {
  2727.                     if INTERNER.read().get_interned_string(fs.name) != "main" {
  2728.                         continue;
  2729.                     }
  2730.                 }
  2731.                 self.interpret_stmt(stmt)?;
  2732.             }
  2733.             Ok(())
  2734.         }
  2735.         fn interpret_stmt(&mut self, stmt: &StmtContainer) -> Result<(), Diagnostic> {
  2736.             match &stmt.stmt {
  2737.                 Stmt::Var(var_stmt) => {
  2738.                     let interpreted_value = self.interpret_expr(&var_stmt.value)?;
  2739.                     let _ = &mut self
  2740.                         .envs
  2741.                         .borrow_mut()
  2742.                         .get_mut(&self.current)
  2743.                         .unwrap()
  2744.                         .last_mut()
  2745.                         .unwrap()
  2746.                         .insert(
  2747.                             var_stmt.name,
  2748.                             EnvItem {
  2749.                                 mutable: var_stmt.mutable,
  2750.                                 addr: interpreted_value,
  2751.                             },
  2752.                         );
  2753.                 }
  2754.                 Stmt::Fun(fun_stmt) => {
  2755.                     self.interpret_function(fun_stmt)?;
  2756.                 }
  2757.                 Stmt::Loop(block) => loop {
  2758.                     if let Err(e) = self.interpret_stmt(block) {
  2759.                         if match e.code {
  2760.                             ErrorCode::Break => true,
  2761.                             _ => false,
  2762.                         } {
  2763.                             return Ok(());
  2764.                         } else if !match e.code {
  2765.                             ErrorCode::Continue => true,
  2766.                             _ => false,
  2767.                         } {
  2768.                             return Err(e);
  2769.                         }
  2770.                     }
  2771.                 },
  2772.                 Stmt::Block(stmts) => {
  2773.                     for stmt in stmts {
  2774.                         self.interpret_stmt(stmt)?;
  2775.                     }
  2776.                 }
  2777.                 Stmt::If(if_stmt) => {
  2778.                     let condition_addr = self.interpret_expr(&if_stmt.condition)?;
  2779.                     let condition_container = self.allocator.get(condition_addr);
  2780.                     let condition_read = condition_container.read();
  2781.                     let is_condition_met = match &*condition_read {
  2782.                         Value::None | Value::Boolean(false) => false,
  2783.                         _ => true,
  2784.                     };
  2785.                     if is_condition_met {
  2786.                         self.interpret_stmt(&if_stmt.block)?;
  2787.                     } else if let Some(else_) = &if_stmt.else_ {
  2788.                         self.interpret_stmt(else_)?;
  2789.                     } else if let Some(then) = &if_stmt.then {
  2790.                         self.interpret_stmt(then)?;
  2791.                     }
  2792.                     return Ok(());
  2793.                 }
  2794.                 Stmt::Iter(iter_stmt) => {
  2795.                     let iterable_addr = self.interpret_expr(&iter_stmt.iterable)?;
  2796.                     let iterable_container = self.allocator.get(iterable_addr);
  2797.                     let iterable_read = iterable_container.read();
  2798.                     let array = match &*iterable_read {
  2799.                         Value::Array(arr) => arr,
  2800.                         val => {
  2801.                             return Err(Diagnostic {
  2802.                                 severity: Severity::Error,
  2803.                                 code: ErrorCode::InvalidType,
  2804.                                 message: {
  2805.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  2806.                                         &["Cannot iter type `", "`"],
  2807.                                         &[::core::fmt::ArgumentV1::new_display(&val.type_())],
  2808.                                     ));
  2809.                                     res
  2810.                                 },
  2811.                                 span: iter_stmt.iterable.span,
  2812.                             })
  2813.                         }
  2814.                     };
  2815.                     for item in array {
  2816.                         let mut scope = Scope::new();
  2817.                         scope.insert(
  2818.                             iter_stmt.binding,
  2819.                             EnvItem {
  2820.                                 mutable: Mutable::No,
  2821.                                 addr: *item,
  2822.                             },
  2823.                         );
  2824.                         self.envs
  2825.                             .borrow_mut()
  2826.                             .get_mut(&self.current)
  2827.                             .unwrap()
  2828.                             .push(scope);
  2829.                         if let Err(e) = self.interpret_stmt(&iter_stmt.block) {
  2830.                             if match e.code {
  2831.                                 ErrorCode::Break => true,
  2832.                                 _ => false,
  2833.                             } {
  2834.                                 return Ok(());
  2835.                             } else if !match e.code {
  2836.                                 ErrorCode::Continue => true,
  2837.                                 _ => false,
  2838.                             } {
  2839.                                 return Err(e);
  2840.                             }
  2841.                         }
  2842.                         self.envs.borrow_mut().get_mut(&self.current).unwrap().pop();
  2843.                     }
  2844.                 }
  2845.                 Stmt::Ret(v) => {
  2846.                     let val_addr = self.interpret_expr(v)?;
  2847.                     return Err(Diagnostic {
  2848.                         severity: Severity::Error,
  2849.                         code: ErrorCode::Return(val_addr),
  2850.                         message: String::from("This error should never be displayed"),
  2851.                         span: stmt.span,
  2852.                     });
  2853.                 }
  2854.                 Stmt::Break => {
  2855.                     return Err(Diagnostic {
  2856.                         severity: Severity::Warning,
  2857.                         span: stmt.span,
  2858.                         message: String::new(),
  2859.                         code: ErrorCode::Break,
  2860.                     })
  2861.                 }
  2862.                 Stmt::Continue => {
  2863.                     return Err(Diagnostic {
  2864.                         severity: Severity::Warning,
  2865.                         span: stmt.span,
  2866.                         message: String::new(),
  2867.                         code: ErrorCode::Continue,
  2868.                     })
  2869.                 }
  2870.                 Stmt::Expr(expr) => {
  2871.                     self.interpret_expr(expr)?;
  2872.                 }
  2873.                 Stmt::Data(_) => (),
  2874.                 _ => ::core::panicking::panic_fmt(::core::fmt::Arguments::new_v1(
  2875.                     &["not yet implemented: "],
  2876.                     &[::core::fmt::ArgumentV1::new_display(
  2877.                         &::core::fmt::Arguments::new_v1(
  2878.                             &[""],
  2879.                             &[::core::fmt::ArgumentV1::new_debug(&stmt)],
  2880.                         ),
  2881.                     )],
  2882.                 )),
  2883.             }
  2884.             Ok(())
  2885.         }
  2886.         fn interpret_function(
  2887.             &mut self,
  2888.             fun_stmt: &FunStmt,
  2889.         ) -> Result<Option<ValueAddr>, Diagnostic> {
  2890.             let mut env = self.envs.borrow_mut();
  2891.             env.get_mut(&self.current).unwrap().push(HashMap::new());
  2892.             drop(env);
  2893.             match &fun_stmt.body.stmt {
  2894.                 Stmt::Block(stmts) => {
  2895.                     for stmt in stmts {
  2896.                         if let Err(err) = self.interpret_stmt(stmt) {
  2897.                             return if let ErrorCode::Return(rv) = err.code {
  2898.                                 Ok(Some(rv))
  2899.                             } else {
  2900.                                 Err(err)
  2901.                             };
  2902.                         }
  2903.                     }
  2904.                 }
  2905.                 _ => ::core::panicking::panic("internal error: entered unreachable code"),
  2906.             }
  2907.             let mut env = self.envs.borrow_mut();
  2908.             for _val in env.get_mut(&self.current).unwrap().last().unwrap() {}
  2909.             Ok(None)
  2910.         }
  2911.         fn get_mutability(&self, name: InternedString) -> Option<Mutable> {
  2912.             let envs = self.envs.borrow();
  2913.             let scopes = envs[&self.current].iter().rev();
  2914.             for scope in scopes {
  2915.                 if let Some(env_item) = scope.get(&name) {
  2916.                     return Some(env_item.mutable);
  2917.                 }
  2918.             }
  2919.             None
  2920.         }
  2921.         fn interpret_expr(&mut self, expr: &ExprContainer) -> Result<ValueAddr, Diagnostic> {
  2922.             let val = match &expr.expr {
  2923.                 Expr::Assignment(assignment_expr) => {
  2924.                     let name = match assignment_expr.lvalue.expr {
  2925.                         Expr::Variable(name) => name,
  2926.                         _ => ::core::panicking::panic("internal error: entered unreachable code"),
  2927.                     };
  2928.                     if let Some(mutability) = self.get_mutability(name) {
  2929.                         if mutability == Mutable::No {
  2930.                             return Err(Diagnostic {
  2931.                                 severity: Severity::Error,
  2932.                                 code: ErrorCode::MutabilityError,
  2933.                                 message: String::from("Attempt to mutate immutable variable"),
  2934.                                 span: expr.span,
  2935.                             });
  2936.                         }
  2937.                     } else {
  2938.                         return Err(Diagnostic {
  2939.                             severity: Severity::Error,
  2940.                             code: ErrorCode::UndefinedVariable,
  2941.                             message: String::from("Undefined variable/type"),
  2942.                             span: expr.span,
  2943.                         });
  2944.                     }
  2945.                     let rvalue = self.interpret_expr(&assignment_expr.rvalue)?;
  2946.                     let mut envs = self.envs.borrow_mut();
  2947.                     let scopes = envs.get_mut(&self.current).unwrap().iter_mut().rev();
  2948.                     for scope in scopes {
  2949.                         if scope.get_mut(&name).is_some() {
  2950.                             scope.insert(
  2951.                                 name,
  2952.                                 EnvItem {
  2953.                                     mutable: Mutable::Yes,
  2954.                                     addr: rvalue,
  2955.                                 },
  2956.                             );
  2957.                             break;
  2958.                         }
  2959.                     }
  2960.                     return Ok(rvalue);
  2961.                 }
  2962.                 Expr::Data(data_expr) => {
  2963.                     let data_addr = self.interpret_expr(&ExprContainer {
  2964.                         span: expr.span,
  2965.                         expr: Expr::Variable(data_expr.name),
  2966.                     })?;
  2967.                     let data_container = self.allocator.get(data_addr);
  2968.                     let data_read = data_container.read();
  2969.                     let data_stmt = match &*data_read {
  2970.                         Value::Data(ds, _) => ds,
  2971.                         val => {
  2972.                             return Err(Diagnostic {
  2973.                                 severity: Severity::Error,
  2974.                                 code: ErrorCode::InvalidType,
  2975.                                 message: {
  2976.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  2977.                                         &["Expected data, found type `", "`"],
  2978.                                         &[::core::fmt::ArgumentV1::new_display(&val.type_())],
  2979.                                     ));
  2980.                                     res
  2981.                                 },
  2982.                                 span: expr.span,
  2983.                             })
  2984.                         }
  2985.                     };
  2986.                     for prop in &data_stmt.fields {
  2987.                         if !data_expr.props.contains_key(prop) {
  2988.                             return Err(Diagnostic {
  2989.                                 severity: Severity::Error,
  2990.                                 code: ErrorCode::MissingProp,
  2991.                                 message: {
  2992.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  2993.                                         &["Missing property `", "`"],
  2994.                                         &[::core::fmt::ArgumentV1::new_display(
  2995.                                             &INTERNER.read().get_interned_string(*prop),
  2996.                                         )],
  2997.                                     ));
  2998.                                     res
  2999.                                 },
  3000.                                 span: expr.span,
  3001.                             });
  3002.                         }
  3003.                     }
  3004.                     for prop in data_expr.props.keys() {
  3005.                         if !data_stmt.fields.contains(prop) {
  3006.                             return Err(Diagnostic {
  3007.                                 severity: Severity::Error,
  3008.                                 code: ErrorCode::UnknownProp,
  3009.                                 message: {
  3010.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3011.                                         &["Unknown property `", "`"],
  3012.                                         &[::core::fmt::ArgumentV1::new_display(
  3013.                                             &INTERNER.read().get_interned_string(*prop),
  3014.                                         )],
  3015.                                     ));
  3016.                                     res
  3017.                                 },
  3018.                                 span: expr.span,
  3019.                             });
  3020.                         }
  3021.                     }
  3022.                     let mut values = HashMap::new();
  3023.                     for (prop, value) in &data_expr.props {
  3024.                         let value = self.interpret_expr(value)?;
  3025.                         values.insert(*prop, value);
  3026.                     }
  3027.                     Ok(Value::DataObject(DataObject {
  3028.                         name: data_expr.name,
  3029.                         values,
  3030.                     }))
  3031.                 }
  3032.                 Expr::Boolean(b) => Ok(Value::Boolean(*b)),
  3033.                 Expr::Number(ne) => {
  3034.                     let radix = ne.kind.radix();
  3035.                     let number = INTERNER.read().get_interned_string(ne.value).to_string();
  3036.                     match ne.kind {
  3037.                         NumberKind::DecFloat => match f64::from_str(&number) {
  3038.                             Ok(v) => Ok(Value::Float(v)),
  3039.                             Err(e) => Err(Diagnostic {
  3040.                                 span: expr.span,
  3041.                                 message: {
  3042.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3043.                                         &["Failed to parse number: `", "`"],
  3044.                                         &[::core::fmt::ArgumentV1::new_display(&e)],
  3045.                                     ));
  3046.                                     res
  3047.                                 },
  3048.                                 code: ErrorCode::InvalidNumber,
  3049.                                 severity: Severity::Error,
  3050.                             }),
  3051.                         },
  3052.                         _ => match i64::from_str_radix(&number, radix) {
  3053.                             Ok(v) => Ok(Value::Int(v)),
  3054.                             Err(e) => Err(Diagnostic {
  3055.                                 span: expr.span,
  3056.                                 message: {
  3057.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3058.                                         &["Failed to parse number: `", "`"],
  3059.                                         &[::core::fmt::ArgumentV1::new_display(&e)],
  3060.                                     ));
  3061.                                     res
  3062.                                 },
  3063.                                 code: ErrorCode::InvalidNumber,
  3064.                                 severity: Severity::Error,
  3065.                             }),
  3066.                         },
  3067.                     }
  3068.                 }
  3069.                 Expr::Logical(logical_expr) => {
  3070.                     let lhs_addr = self.interpret_expr(&logical_expr.lhs)?;
  3071.                     let lhs_container = self.allocator.get(lhs_addr);
  3072.                     let lhs_inner = lhs_container.read();
  3073.                     let rhs_addr = self.interpret_expr(&logical_expr.rhs)?;
  3074.                     let rhs_container = self.allocator.get(rhs_addr);
  3075.                     let rhs_inner = rhs_container.read();
  3076.                     let lhs_type = lhs_inner.type_();
  3077.                     let rhs_type = rhs_inner.type_();
  3078.                     let op = logical_expr.op;
  3079.                     let return_error = move || {
  3080.                         return Err(Diagnostic {
  3081.                             severity: Severity::Error,
  3082.                             code: ErrorCode::InvalidType,
  3083.                             message: {
  3084.                                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3085.                                     &["Cannot apply logical operation between `", "` and `", "`"],
  3086.                                     &[
  3087.                                         ::core::fmt::ArgumentV1::new_display(&lhs_type),
  3088.                                         ::core::fmt::ArgumentV1::new_display(&rhs_type),
  3089.                                     ],
  3090.                                 ));
  3091.                                 res
  3092.                             },
  3093.                             span: expr.span,
  3094.                         });
  3095.                     };
  3096.                     let res = match (&*lhs_inner, &*rhs_inner) {
  3097.                         (Value::String(lhs), Value::String(rhs)) => {
  3098.                             let res;
  3099.                             {
  3100.                                 let interner = INTERNER.read();
  3101.                                 let lhs_s = interner.get_interned_string(*lhs);
  3102.                                 let rhs_s = interner.get_interned_string(*rhs);
  3103.                                 res = Value::Boolean({
  3104.                                     match op {
  3105.                                         LogicalOperation::GreaterThan => lhs_s.len() > rhs_s.len(),
  3106.                                         LogicalOperation::LessThan => lhs_s.len() < rhs_s.len(),
  3107.                                         LogicalOperation::GreaterThanOrEquals => {
  3108.                                             lhs_s.len() >= rhs_s.len()
  3109.                                         }
  3110.                                         LogicalOperation::LessThanOrEquals => {
  3111.                                             lhs_s.len() <= rhs_s.len()
  3112.                                         }
  3113.                                         LogicalOperation::Equals => lhs_s == rhs_s,
  3114.                                         LogicalOperation::NotEquals => lhs_s != rhs_s,
  3115.                                         LogicalOperation::And => {
  3116.                                             !lhs_s.is_empty() && !rhs_s.is_empty()
  3117.                                         }
  3118.                                         LogicalOperation::Or => {
  3119.                                             !lhs_s.is_empty() || !rhs_s.is_empty()
  3120.                                         }
  3121.                                     }
  3122.                                 });
  3123.                             }
  3124.                             res
  3125.                         }
  3126.                         (Value::Int(lhs), Value::Float(rhs))
  3127.                         | (Value::Float(rhs), Value::Int(lhs)) => {
  3128.                             let lhs = *lhs as f64;
  3129.                             let rhs = *rhs;
  3130.                             Value::Boolean(match op {
  3131.                                 LogicalOperation::Equals => lhs == rhs,
  3132.                                 LogicalOperation::NotEquals => lhs != rhs,
  3133.                                 LogicalOperation::GreaterThan => lhs > rhs,
  3134.                                 LogicalOperation::LessThan => lhs < rhs,
  3135.                                 LogicalOperation::GreaterThanOrEquals => lhs >= rhs,
  3136.                                 LogicalOperation::LessThanOrEquals => lhs <= rhs,
  3137.                                 LogicalOperation::And => (lhs != 0.0) && (rhs != 0.0),
  3138.                                 LogicalOperation::Or => (lhs != 0.0) || (rhs != 0.0),
  3139.                             })
  3140.                         }
  3141.                         (Value::Int(lhs), Value::Boolean(rhs))
  3142.                         | (Value::Boolean(rhs), Value::Int(lhs)) => {
  3143.                             let lhs = *lhs;
  3144.                             let rhs = *rhs;
  3145.                             Value::Boolean(match op {
  3146.                                 LogicalOperation::And => (lhs != 0) && rhs,
  3147.                                 LogicalOperation::Or => (lhs != 0) || rhs,
  3148.                                 _ => return return_error(),
  3149.                             })
  3150.                         }
  3151.                         (Value::Float(lhs), Value::Boolean(rhs))
  3152.                         | (Value::Boolean(rhs), Value::Float(lhs)) => {
  3153.                             let lhs = *lhs;
  3154.                             let rhs = *rhs;
  3155.                             Value::Boolean(match op {
  3156.                                 LogicalOperation::And => (lhs != 0.0) && rhs,
  3157.                                 LogicalOperation::Or => (lhs != 0.0) || rhs,
  3158.                                 _ => return return_error(),
  3159.                             })
  3160.                         }
  3161.                         (Value::Boolean(lhs), Value::Boolean(rhs)) => {
  3162.                             let lhs = *lhs;
  3163.                             let rhs = *rhs;
  3164.                             Value::Boolean(match op {
  3165.                                 LogicalOperation::And => lhs && rhs,
  3166.                                 LogicalOperation::Or => lhs || rhs,
  3167.                                 _ => return return_error(),
  3168.                             })
  3169.                         }
  3170.                         (Value::Int(lhs), Value::Int(rhs)) => {
  3171.                             let lhs = *lhs;
  3172.                             let rhs = *rhs;
  3173.                             Value::Boolean(match op {
  3174.                                 LogicalOperation::Equals => lhs == rhs,
  3175.                                 LogicalOperation::NotEquals => lhs != rhs,
  3176.                                 LogicalOperation::GreaterThan => lhs > rhs,
  3177.                                 LogicalOperation::LessThan => lhs < rhs,
  3178.                                 LogicalOperation::GreaterThanOrEquals => lhs >= rhs,
  3179.                                 LogicalOperation::LessThanOrEquals => lhs <= rhs,
  3180.                                 LogicalOperation::And => (lhs != 0) && (rhs != 0),
  3181.                                 LogicalOperation::Or => (lhs != 0) || (rhs != 0),
  3182.                             })
  3183.                         }
  3184.                         _ => return return_error(),
  3185.                     };
  3186.                     Ok(res)
  3187.                 }
  3188.                 Expr::Binary(binary_expr) => {
  3189.                     let lhs_addr = self.interpret_expr(&binary_expr.lhs)?;
  3190.                     let lhs_container = self.allocator.get(lhs_addr);
  3191.                     let lhs_inner = lhs_container.read();
  3192.                     let rhs_addr = self.interpret_expr(&binary_expr.rhs)?;
  3193.                     let rhs_container = self.allocator.get(rhs_addr);
  3194.                     let rhs_inner = rhs_container.read();
  3195.                     let lhs_type = lhs_inner.type_();
  3196.                     let rhs_type = rhs_inner.type_();
  3197.                     let op = binary_expr.op;
  3198.                     let return_error = move || {
  3199.                         return Err(Diagnostic {
  3200.                             severity: Severity::Error,
  3201.                             code: ErrorCode::InvalidType,
  3202.                             message: {
  3203.                                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3204.                                     &["Cannot apply binary operation between `", "` and `", "`"],
  3205.                                     &[
  3206.                                         ::core::fmt::ArgumentV1::new_display(&lhs_type),
  3207.                                         ::core::fmt::ArgumentV1::new_display(&rhs_type),
  3208.                                     ],
  3209.                                 ));
  3210.                                 res
  3211.                             },
  3212.                             span: expr.span,
  3213.                         });
  3214.                     };
  3215.                     let res = match (&*lhs_inner, &*rhs_inner) {
  3216.                         (Value::Int(lhs), Value::Float(rhs))
  3217.                         | (Value::Float(rhs), Value::Int(lhs)) => match op {
  3218.                             BinaryOperation::Plus => Value::Float(*lhs as f64 + *rhs),
  3219.                             BinaryOperation::Minus => Value::Float(*lhs as f64 - *rhs),
  3220.                             BinaryOperation::Multiply => Value::Float(*lhs as f64 * *rhs),
  3221.                             BinaryOperation::Divide => Value::Float(*lhs as f64 / *rhs),
  3222.                             BinaryOperation::Modulus => Value::Float(*lhs as f64 % *rhs),
  3223.                             _ => return return_error(),
  3224.                         },
  3225.                         (Value::Float(lhs), Value::Float(rhs)) => match op {
  3226.                             BinaryOperation::Plus => Value::Float(*lhs + *rhs),
  3227.                             BinaryOperation::Minus => Value::Float(*lhs - *rhs),
  3228.                             BinaryOperation::Multiply => Value::Float(*lhs * *rhs),
  3229.                             BinaryOperation::Divide => Value::Float(*lhs / *rhs),
  3230.                             BinaryOperation::Modulus => Value::Float(*lhs % *rhs),
  3231.                             _ => return return_error(),
  3232.                         },
  3233.                         (Value::Int(lhs), Value::Int(rhs)) => match op {
  3234.                             BinaryOperation::Plus => Value::Int(*lhs + *rhs),
  3235.                             BinaryOperation::Minus => Value::Int(*lhs - *rhs),
  3236.                             BinaryOperation::Multiply => Value::Int(*lhs * *rhs),
  3237.                             BinaryOperation::Divide => Value::Float(*lhs as f64 / *rhs as f64),
  3238.                             BinaryOperation::Modulus => Value::Int(*lhs % *rhs),
  3239.                             BinaryOperation::And => Value::Int(*lhs & *rhs),
  3240.                             BinaryOperation::Or => Value::Int(*lhs | *rhs),
  3241.                             BinaryOperation::Xor => Value::Int(*lhs ^ *rhs),
  3242.                             BinaryOperation::LeftShift => Value::Int(*lhs << *rhs),
  3243.                             BinaryOperation::RightShift => Value::Int(*lhs >> *rhs),
  3244.                         },
  3245.                         (Value::String(is), Value::Int(n)) => match op {
  3246.                             BinaryOperation::Multiply => Value::String({
  3247.                                 let res =
  3248.                                     INTERNER.read().get_interned_string(*is).repeat(*n as usize);
  3249.                                 INTERNER.write().intern_string(res)
  3250.                             }),
  3251.                             _ => return return_error(),
  3252.                         },
  3253.                         (Value::Array(arr), _) => {
  3254.                             let mut new_arr = arr.clone();
  3255.                             new_arr.push(rhs_addr);
  3256.                             let arr_addr = self.allocator.allocate(Value::Array(new_arr));
  3257.                             return Ok(arr_addr);
  3258.                         }
  3259.                         _ => return return_error(),
  3260.                     };
  3261.                     Ok(res)
  3262.                 }
  3263.                 Expr::Unary(unary_expr) => {
  3264.                     let value_addr = self.interpret_expr(&unary_expr.expr)?;
  3265.                     let value_container = self.allocator.get(value_addr);
  3266.                     let value_read = value_container.read();
  3267.                     match unary_expr.op {
  3268.                         UnaryOperation::Not => match &*value_read {
  3269.                             Value::None | Value::Boolean(false) => Ok(Value::Boolean(true)),
  3270.                             _ => Ok(Value::Boolean(false)),
  3271.                         },
  3272.                         UnaryOperation::Negate => match &*value_read {
  3273.                             Value::Int(i) => Ok(Value::Int(-*i)),
  3274.                             Value::Float(f) => Ok(Value::Float(-*f)),
  3275.                             v => Err(Diagnostic {
  3276.                                 severity: Severity::Error,
  3277.                                 code: ErrorCode::InvalidUnaryOperation,
  3278.                                 message: {
  3279.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3280.                                         &["Cannot apply unary negate to type `", "`"],
  3281.                                         &[::core::fmt::ArgumentV1::new_display(&v.type_())],
  3282.                                     ));
  3283.                                     res
  3284.                                 },
  3285.                                 span: expr.span,
  3286.                             }),
  3287.                         },
  3288.                     }
  3289.                 }
  3290.                 Expr::Call(call_expr) => {
  3291.                     let function_addr = self.interpret_expr(&call_expr.callee)?;
  3292.                     let function_container = self.allocator.get(function_addr);
  3293.                     let function_read = function_container.read();
  3294.                     let function = match &*function_read {
  3295.                         Value::Function(function) => function,
  3296.                         val => {
  3297.                             return Err(Diagnostic {
  3298.                                 span: expr.span,
  3299.                                 message: {
  3300.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3301.                                         &["Cannot call type: `", "`"],
  3302.                                         &[::core::fmt::ArgumentV1::new_display(&val.type_())],
  3303.                                     ));
  3304.                                     res
  3305.                                 },
  3306.                                 code: ErrorCode::InvalidType,
  3307.                                 severity: Severity::Error,
  3308.                             })
  3309.                         }
  3310.                     };
  3311.                     if function.arity() != usize::MAX && call_expr.args.len() > function.arity() {
  3312.                         return Err(Diagnostic {
  3313.                             span: expr.span,
  3314.                             message: {
  3315.                                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3316.                                     &["Function expects ", " arguments, found ", " arguments"],
  3317.                                     &[
  3318.                                         ::core::fmt::ArgumentV1::new_display(&function.arity()),
  3319.                                         ::core::fmt::ArgumentV1::new_display(&call_expr.args.len()),
  3320.                                     ],
  3321.                                 ));
  3322.                                 res
  3323.                             },
  3324.                             code: ErrorCode::ArityError,
  3325.                             severity: Severity::Error,
  3326.                         });
  3327.                     }
  3328.                     let mut args = alloc::vec::Vec::new();
  3329.                     for expr in &call_expr.args {
  3330.                         let val = self.interpret_expr(expr)?;
  3331.                         args.push(self.allocator.clone(val));
  3332.                     }
  3333.                     let res = function.call(self, args);
  3334.                     if let Ok(v) = res {
  3335.                         return Ok(v.unwrap_or(self.allocator.get_none()));
  3336.                     } else if let Err(mut e) = res {
  3337.                         if e.span
  3338.                             == (Span {
  3339.                                 lo: usize::MAX,
  3340.                                 hi: usize::MAX,
  3341.                             })
  3342.                         {
  3343.                             e.span = expr.span;
  3344.                         }
  3345.                         return Err(e);
  3346.                     }
  3347.                     ::core::panicking::panic("internal error: entered unreachable code")
  3348.                 }
  3349.                 Expr::None => Ok(Value::None),
  3350.                 Expr::String(is) => Ok(Value::String(*is)),
  3351.                 Expr::Grouping(e) => return self.interpret_expr(e),
  3352.                 Expr::Get(get_expr) => {
  3353.                     let object_addr = self.interpret_expr(&get_expr.object)?;
  3354.                     let object_container = self.allocator.get(object_addr);
  3355.                     let object_read = object_container.read();
  3356.                     let object = match &*object_read {
  3357.                         Value::DataObject(dobj) => dobj,
  3358.                         _ => {
  3359.                             return Err(Diagnostic {
  3360.                                 severity: Severity::Error,
  3361.                                 code: ErrorCode::InvalidType,
  3362.                                 message: {
  3363.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3364.                                         &["Cannot access property from type `", "`"],
  3365.                                         &[::core::fmt::ArgumentV1::new_display(
  3366.                                             &object_read.type_(),
  3367.                                         )],
  3368.                                     ));
  3369.                                     res
  3370.                                 },
  3371.                                 span: expr.span,
  3372.                             })
  3373.                         }
  3374.                     };
  3375.                     if let Some(value) = object.values.get(&get_expr.property) {
  3376.                         return Ok(*value);
  3377.                     } else {
  3378.                         Err(Diagnostic {
  3379.                             severity: Severity::Error,
  3380.                             code: ErrorCode::InvalidType,
  3381.                             message: {
  3382.                                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3383.                                     &["Cannot access property `", "`"],
  3384.                                     &[::core::fmt::ArgumentV1::new_display(
  3385.                                         &INTERNER.read().get_interned_string(get_expr.property),
  3386.                                     )],
  3387.                                 ));
  3388.                                 res
  3389.                             },
  3390.                             span: expr.span,
  3391.                         })
  3392.                     }
  3393.                 }
  3394.                 Expr::Array(array) => {
  3395.                     let mut items = alloc::vec::Vec::new();
  3396.                     for expr in array {
  3397.                         let value = self.interpret_expr(expr)?;
  3398.                         items.push(value);
  3399.                     }
  3400.                     Ok(Value::Array(items))
  3401.                 }
  3402.                 Expr::Index(index_expr) => {
  3403.                     let array_addr = self.interpret_expr(&index_expr.object)?;
  3404.                     let array_container = self.allocator.get(array_addr);
  3405.                     let array_read = array_container.read();
  3406.                     let array = match &*array_read {
  3407.                         Value::Array(a) => a,
  3408.                         _ => {
  3409.                             return Err(Diagnostic {
  3410.                                 severity: Severity::Error,
  3411.                                 code: ErrorCode::InvalidType,
  3412.                                 message: {
  3413.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3414.                                         &["Cannot index type `", "`"],
  3415.                                         &[::core::fmt::ArgumentV1::new_display(
  3416.                                             &array_read.type_(),
  3417.                                         )],
  3418.                                     ));
  3419.                                     res
  3420.                                 },
  3421.                                 span: expr.span,
  3422.                             })
  3423.                         }
  3424.                     };
  3425.                     let index_addr = self.interpret_expr(&index_expr.index)?;
  3426.                     let index = match &*self.allocator.get(index_addr).read() {
  3427.                         Value::Int(idx) => *idx,
  3428.                         ty => {
  3429.                             return Err(Diagnostic {
  3430.                                 severity: Severity::Error,
  3431.                                 code: ErrorCode::InvalidType,
  3432.                                 message: {
  3433.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3434.                                         &["Cannot index using type `", "`"],
  3435.                                         &[::core::fmt::ArgumentV1::new_display(&ty.type_())],
  3436.                                     ));
  3437.                                     res
  3438.                                 },
  3439.                                 span: expr.span,
  3440.                             })
  3441.                         }
  3442.                     };
  3443.                     return if let Some(val_addr) = array.get(index as usize) {
  3444.                         Ok(*val_addr)
  3445.                     } else {
  3446.                         Err(Diagnostic {
  3447.                             severity: Severity::Error,
  3448.                             code: ErrorCode::InvalidType,
  3449.                             message: String::from("Out of bound read"),
  3450.                             span: expr.span,
  3451.                         })
  3452.                     };
  3453.                 }
  3454.                 Expr::IndexSet(indexset_expr) => {
  3455.                     let index_expr = match &indexset_expr.object.expr {
  3456.                         Expr::Index(index_expr) => index_expr,
  3457.                         _ => ::core::panicking::panic("internal error: entered unreachable code"),
  3458.                     };
  3459.                     let array_addr = self.interpret_expr(&index_expr.object)?;
  3460.                     let array_container = self.allocator.get(array_addr);
  3461.                     let index_addr = self.interpret_expr(&index_expr.index)?;
  3462.                     let index = match &*self.allocator.get(index_addr).read() {
  3463.                         Value::Int(idx) => *idx,
  3464.                         ty => {
  3465.                             return Err(Diagnostic {
  3466.                                 severity: Severity::Error,
  3467.                                 code: ErrorCode::InvalidType,
  3468.                                 message: {
  3469.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3470.                                         &["Cannot index using type `", "`"],
  3471.                                         &[::core::fmt::ArgumentV1::new_display(&ty.type_())],
  3472.                                     ));
  3473.                                     res
  3474.                                 },
  3475.                                 span: expr.span,
  3476.                             })
  3477.                         }
  3478.                     };
  3479.                     let value_addr = self.interpret_expr(&indexset_expr.value)?;
  3480.                     let mut array_write = array_container.write();
  3481.                     let array = match &mut *array_write {
  3482.                         Value::Array(a) => a,
  3483.                         _ => {
  3484.                             return Err(Diagnostic {
  3485.                                 severity: Severity::Error,
  3486.                                 code: ErrorCode::InvalidType,
  3487.                                 message: {
  3488.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3489.                                         &["Cannot index type `", "`"],
  3490.                                         &[::core::fmt::ArgumentV1::new_display(
  3491.                                             &array_write.type_(),
  3492.                                         )],
  3493.                                     ));
  3494.                                     res
  3495.                                 },
  3496.                                 span: expr.span,
  3497.                             })
  3498.                         }
  3499.                     };
  3500.                     if array.get(index as usize).is_none() {
  3501.                         return Err(Diagnostic {
  3502.                             severity: Severity::Error,
  3503.                             code: ErrorCode::InvalidType,
  3504.                             message: String::from("Out of bound read"),
  3505.                             span: expr.span,
  3506.                         });
  3507.                     };
  3508.                     array[index as usize] = value_addr;
  3509.                     return Ok(value_addr);
  3510.                 }
  3511.                 Expr::Set(set_expr) => {
  3512.                     if let Expr::Get(get_expr) = &set_expr.object.expr {
  3513.                         let value = self.interpret_expr(&set_expr.value)?;
  3514.                         let obj_addr = self.interpret_expr(&get_expr.object)?;
  3515.                         let obj_container = self.allocator.get(obj_addr);
  3516.                         let mut obj_write = obj_container.write();
  3517.                         let data_object = match &mut *obj_write {
  3518.                             Value::DataObject(data_object) => data_object,
  3519.                             _ => {
  3520.                                 return Err(Diagnostic {
  3521.                                     severity: Severity::Error,
  3522.                                     code: ErrorCode::InvalidType,
  3523.                                     message: {
  3524.                                         let res =
  3525.                                             alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3526.                                                 &["Cannot access properties of type `", "`"],
  3527.                                                 &[::core::fmt::ArgumentV1::new_display(
  3528.                                                     &obj_write.type_(),
  3529.                                                 )],
  3530.                                             ));
  3531.                                         res
  3532.                                     },
  3533.                                     span: set_expr.object.span,
  3534.                                 })
  3535.                             }
  3536.                         };
  3537.                         if let std::collections::hash_map::Entry::Occupied(mut e) =
  3538.                             data_object.values.entry(get_expr.property)
  3539.                         {
  3540.                             e.insert(value);
  3541.                         } else {
  3542.                             return Err(Diagnostic {
  3543.                                 severity: Severity::Error,
  3544.                                 code: ErrorCode::InvalidType,
  3545.                                 message: {
  3546.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3547.                                         &["Cannot access property `", "`"],
  3548.                                         &[::core::fmt::ArgumentV1::new_display(
  3549.                                             &INTERNER.read().get_interned_string(get_expr.property),
  3550.                                         )],
  3551.                                     ));
  3552.                                     res
  3553.                                 },
  3554.                                 span: set_expr.object.span,
  3555.                             });
  3556.                         }
  3557.                         return Ok(obj_addr);
  3558.                     }
  3559.                     let object_addr = self.interpret_expr(&set_expr.object)?;
  3560.                     let value_addr = self.interpret_expr(&set_expr.value)?;
  3561.                     let object_container = self.allocator.get(object_addr);
  3562.                     let object_read = object_container.read();
  3563.                     let object = match &*object_read {
  3564.                         Value::DataObject(dobj) => dobj,
  3565.                         _ => {
  3566.                             return Err(Diagnostic {
  3567.                                 severity: Severity::Error,
  3568.                                 code: ErrorCode::InvalidType,
  3569.                                 message: {
  3570.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3571.                                         &["Cannot access property from type `", "`"],
  3572.                                         &[::core::fmt::ArgumentV1::new_display(
  3573.                                             &object_read.type_(),
  3574.                                         )],
  3575.                                     ));
  3576.                                     res
  3577.                                 },
  3578.                                 span: expr.span,
  3579.                             })
  3580.                         }
  3581.                     };
  3582.                     if object.values.get(&set_expr.property).is_none() {
  3583.                         return Err(Diagnostic {
  3584.                             severity: Severity::Error,
  3585.                             code: ErrorCode::InvalidType,
  3586.                             message: {
  3587.                                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3588.                                     &["Cannot access property `", "`"],
  3589.                                     &[::core::fmt::ArgumentV1::new_display(
  3590.                                         &INTERNER.read().get_interned_string(set_expr.property),
  3591.                                     )],
  3592.                                 ));
  3593.                                 res
  3594.                             },
  3595.                             span: expr.span,
  3596.                         });
  3597.                     };
  3598.                     drop(object_read);
  3599.                     let mut object_write = object_container.write();
  3600.                     let object = match &mut *object_write {
  3601.                         Value::DataObject(dobj) => dobj,
  3602.                         _ => {
  3603.                             return Err(Diagnostic {
  3604.                                 severity: Severity::Error,
  3605.                                 code: ErrorCode::InvalidType,
  3606.                                 message: {
  3607.                                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3608.                                         &["Cannot access property from type `", "`"],
  3609.                                         &[::core::fmt::ArgumentV1::new_display(
  3610.                                             &object_write.type_(),
  3611.                                         )],
  3612.                                     ));
  3613.                                     res
  3614.                                 },
  3615.                                 span: expr.span,
  3616.                             })
  3617.                         }
  3618.                     };
  3619.                     object.values.insert(set_expr.property, value_addr);
  3620.                     return Ok(object_addr);
  3621.                 }
  3622.                 Expr::Variable(name) => {
  3623.                     let envs = self.envs.borrow_mut();
  3624.                     let scopes = envs[&self.current].iter().rev();
  3625.                     for scope in scopes {
  3626.                         if let Some(env_item) = scope.get(name) {
  3627.                             return Ok(env_item.addr);
  3628.                         }
  3629.                     }
  3630.                     Err(Diagnostic {
  3631.                         severity: Severity::Error,
  3632.                         code: ErrorCode::UndefinedVariable,
  3633.                         message: String::from("Undefined variable/type"),
  3634.                         span: expr.span,
  3635.                     })
  3636.                 }
  3637.             };
  3638.             Ok(self.allocator.allocate(val?))
  3639.         }
  3640.         pub fn prepare_global_env_for_module(
  3641.             name: InternedString,
  3642.             ast: &[StmtContainer],
  3643.             interpreter_env: &RefCell<HashMap<InternedString, Vec<Scope>>>,
  3644.             allocator: &mut Allocator,
  3645.         ) -> Result<(), Diagnostic> {
  3646.             let mut env = alloc::vec::Vec::new();
  3647.             let mut scope = Scope::new();
  3648.             let mut create_native_fn =
  3649.                 |allocator: &mut Allocator, name: &str, function: Box<dyn Callable>| -> EnvItem {
  3650.                     let env_item = EnvItem {
  3651.                         mutable: Mutable::No,
  3652.                         addr: allocator.allocate(Value::Function(function)),
  3653.                     };
  3654.                     scope.insert(INTERNER.write().intern_string(name.to_string()), env_item);
  3655.                     env_item
  3656.                 };
  3657.             create_native_fn(allocator, "print", Box::new(PrintFunction {}));
  3658.             create_native_fn(allocator, "println", Box::new(PrintlnFunction {}));
  3659.             create_native_fn(allocator, "sleep", Box::new(SleepFunction {}));
  3660.             create_native_fn(allocator, "pop", Box::new(ArrayPopFunction {}));
  3661.             create_native_fn(allocator, "input", Box::new(InputFunction {}));
  3662.             create_native_fn(allocator, "int", Box::new(IntFunction {}));
  3663.             create_native_fn(allocator, "float", Box::new(FloatFunction {}));
  3664.             for stmt in ast {
  3665.                 match &stmt.stmt {
  3666.                     Stmt::Fun(fun_stmt) => {
  3667.                         scope.insert(
  3668.                             fun_stmt.name,
  3669.                             EnvItem {
  3670.                                 mutable: Mutable::No,
  3671.                                 addr: allocator.allocate(Value::Function(Box::new(YalFunction {
  3672.                                     fun_stmt: fun_stmt.clone(),
  3673.                                 }))),
  3674.                             },
  3675.                         );
  3676.                     }
  3677.                     Stmt::Data(data_stmt) => {
  3678.                         let value_addr =
  3679.                             allocator.allocate(Value::Data(data_stmt.clone(), HashMap::new()));
  3680.                         scope.insert(
  3681.                             data_stmt.name,
  3682.                             EnvItem {
  3683.                                 mutable: Mutable::No,
  3684.                                 addr: value_addr,
  3685.                             },
  3686.                         );
  3687.                     }
  3688.                     Stmt::Methods(methods_stmt) => {
  3689.                         let data_container = match scope.get(&methods_stmt.data) {
  3690.                             Some(ei) => allocator.get(ei.addr),
  3691.                             _ => {
  3692.                                 return Err(Diagnostic {
  3693.                                     severity: Severity::Error,
  3694.                                     code: ErrorCode::InvalidType,
  3695.                                     span: stmt.span,
  3696.                                     message: String::from("Cannot bind methods to invalid type"),
  3697.                                 })
  3698.                             }
  3699.                         };
  3700.                         let mut data = data_container.write();
  3701.                         let data_methods = match &mut *data {
  3702.                             Value::Data(_, methods) => methods,
  3703.                             _ => {
  3704.                                 ::core::panicking::panic("internal error: entered unreachable code")
  3705.                             }
  3706.                         };
  3707.                         for method in methods_stmt.methods.clone() {
  3708.                             match method.stmt {
  3709.                                 Stmt::Fun(fun) => {
  3710.                                     data_methods.insert(fun.name, fun);
  3711.                                 }
  3712.                                 _ => ::core::panicking::panic(
  3713.                                     "internal error: entered unreachable code",
  3714.                                 ),
  3715.                             }
  3716.                         }
  3717.                     }
  3718.                     _ => (),
  3719.                 }
  3720.             }
  3721.             env.push(scope);
  3722.             interpreter_env.borrow_mut().insert(name, env);
  3723.             Ok(())
  3724.         }
  3725.         pub fn get_allocator_mut(&mut self) -> &mut Allocator {
  3726.             &mut self.allocator
  3727.         }
  3728.         pub fn get_allocator(&self) -> &Allocator {
  3729.             &self.allocator
  3730.         }
  3731.     }
  3732.     struct YalFunction {
  3733.         fun_stmt: Box<FunStmt>,
  3734.     }
  3735.     #[automatically_derived]
  3736.     impl ::core::fmt::Debug for YalFunction {
  3737.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  3738.             ::core::fmt::Formatter::debug_struct_field1_finish(
  3739.                 f,
  3740.                 "YalFunction",
  3741.                 "fun_stmt",
  3742.                 &&self.fun_stmt,
  3743.             )
  3744.         }
  3745.     }
  3746.     #[automatically_derived]
  3747.     impl ::core::clone::Clone for YalFunction {
  3748.         #[inline]
  3749.         fn clone(&self) -> YalFunction {
  3750.             YalFunction {
  3751.                 fun_stmt: ::core::clone::Clone::clone(&self.fun_stmt),
  3752.             }
  3753.         }
  3754.     }
  3755.     impl Callable for YalFunction {
  3756.         fn arity(&self) -> usize {
  3757.             self.fun_stmt.arguments.len()
  3758.         }
  3759.         fn call(
  3760.             &self,
  3761.             interpreter: &mut Interpreter,
  3762.             args: Vec<ValueAddr>,
  3763.         ) -> Result<Option<ValueAddr>, Diagnostic> {
  3764.             let mut env = interpreter.envs.borrow_mut();
  3765.             let mut scope = HashMap::new();
  3766.             for (k, v) in self.fun_stmt.arguments.iter().zip(args.iter()) {
  3767.                 scope.insert(
  3768.                     *k,
  3769.                     EnvItem {
  3770.                         addr: *v,
  3771.                         mutable: Mutable::No,
  3772.                     },
  3773.                 );
  3774.             }
  3775.             let parent_scope;
  3776.             if env.get_mut(&interpreter.current).unwrap().len() > 1 {
  3777.                 parent_scope = env.get_mut(&interpreter.current).unwrap().pop();
  3778.             } else {
  3779.                 parent_scope = None;
  3780.             }
  3781.             env.get_mut(&interpreter.current).unwrap().push(scope);
  3782.             drop(env);
  3783.             match &self.fun_stmt.body.stmt {
  3784.                 Stmt::Block(stmts) => {
  3785.                     for stmt in stmts {
  3786.                         if let Err(err) = interpreter.interpret_stmt(stmt) {
  3787.                             return if let ErrorCode::Return(rv) = err.code {
  3788.                                 let mut env = interpreter.envs.borrow_mut();
  3789.                                 for _val in
  3790.                                     env.get_mut(&interpreter.current).unwrap().last().unwrap()
  3791.                                 {
  3792.                                 }
  3793.                                 env.get_mut(&interpreter.current).unwrap().pop();
  3794.                                 if let Some(parent_scope) = parent_scope {
  3795.                                     env.get_mut(&interpreter.current)
  3796.                                         .unwrap()
  3797.                                         .push(parent_scope);
  3798.                                 }
  3799.                                 Ok(Some(rv))
  3800.                             } else {
  3801.                                 Err(err)
  3802.                             };
  3803.                         }
  3804.                     }
  3805.                 }
  3806.                 _ => ::core::panicking::panic("internal error: entered unreachable code"),
  3807.             }
  3808.             let mut env = interpreter.envs.borrow_mut();
  3809.             for _val in env.get_mut(&interpreter.current).unwrap().last().unwrap() {}
  3810.             env.get_mut(&interpreter.current).unwrap().pop();
  3811.             if let Some(parent_scope) = parent_scope {
  3812.                 env.get_mut(&interpreter.current)
  3813.                     .unwrap()
  3814.                     .push(parent_scope);
  3815.             }
  3816.             Ok(None)
  3817.         }
  3818.         fn to_string(&self) -> String {
  3819.             {
  3820.                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  3821.                     &["<function ", " at ", ">"],
  3822.                     &[
  3823.                         ::core::fmt::ArgumentV1::new_display(
  3824.                             &INTERNER.read().get_interned_string(self.fun_stmt.name),
  3825.                         ),
  3826.                         ::core::fmt::ArgumentV1::new_pointer(&(self as *const _)),
  3827.                     ],
  3828.                 ));
  3829.                 res
  3830.             }
  3831.         }
  3832.         fn clone(&self) -> Self
  3833.         where
  3834.             Self: Sized,
  3835.         {
  3836.             Clone::clone(self)
  3837.         }
  3838.     }
  3839.     type Scope = HashMap<InternedString, EnvItem>;
  3840.     enum InterpreterContext {
  3841.         Function,
  3842.         Loop,
  3843.         Method,
  3844.     }
  3845.     #[automatically_derived]
  3846.     impl ::core::fmt::Debug for InterpreterContext {
  3847.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  3848.             match self {
  3849.                 InterpreterContext::Function => ::core::fmt::Formatter::write_str(f, "Function"),
  3850.                 InterpreterContext::Loop => ::core::fmt::Formatter::write_str(f, "Loop"),
  3851.                 InterpreterContext::Method => ::core::fmt::Formatter::write_str(f, "Method"),
  3852.             }
  3853.         }
  3854.     }
  3855.     #[automatically_derived]
  3856.     impl ::core::clone::Clone for InterpreterContext {
  3857.         #[inline]
  3858.         fn clone(&self) -> InterpreterContext {
  3859.             match self {
  3860.                 InterpreterContext::Function => InterpreterContext::Function,
  3861.                 InterpreterContext::Loop => InterpreterContext::Loop,
  3862.                 InterpreterContext::Method => InterpreterContext::Method,
  3863.             }
  3864.         }
  3865.     }
  3866.     pub struct EnvItem {
  3867.         pub mutable: Mutable,
  3868.         pub addr: ValueAddr,
  3869.     }
  3870.     #[automatically_derived]
  3871.     impl ::core::fmt::Debug for EnvItem {
  3872.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  3873.             ::core::fmt::Formatter::debug_struct_field2_finish(
  3874.                 f,
  3875.                 "EnvItem",
  3876.                 "mutable",
  3877.                 &&self.mutable,
  3878.                 "addr",
  3879.                 &&self.addr,
  3880.             )
  3881.         }
  3882.     }
  3883.     #[automatically_derived]
  3884.     impl ::core::clone::Clone for EnvItem {
  3885.         #[inline]
  3886.         fn clone(&self) -> EnvItem {
  3887.             let _: ::core::clone::AssertParamIsClone<Mutable>;
  3888.             let _: ::core::clone::AssertParamIsClone<ValueAddr>;
  3889.             *self
  3890.         }
  3891.     }
  3892.     #[automatically_derived]
  3893.     impl ::core::marker::Copy for EnvItem {}
  3894. }
  3895. mod lexer {
  3896.     use crate::diagnostics::{Diagnostic, ErrorCode, Severity, Span};
  3897.     use crate::interner::{InternedString, INTERNER};
  3898.     use std::str::Chars;
  3899.     pub struct Lexer<'l> {
  3900.        source_chars: Chars<'l>,
  3901.         source_len: usize,
  3902.         pos: usize,
  3903.     }
  3904.     #[automatically_derived]
  3905.     impl<'l> ::core::fmt::Debug for Lexer<'l> {
  3906.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  3907.             ::core::fmt::Formatter::debug_struct_field3_finish(
  3908.                 f,
  3909.                 "Lexer",
  3910.                 "source_chars",
  3911.                 &&self.source_chars,
  3912.                 "source_len",
  3913.                 &&self.source_len,
  3914.                 "pos",
  3915.                 &&self.pos,
  3916.             )
  3917.         }
  3918.     }
  3919.     impl<'l> Lexer<'l> {
  3920.         pub fn new(source: &'l str) -> Self {
  3921.            Self {
  3922.                source_chars: source.chars(),
  3923.                source_len: source.len(),
  3924.                pos: 0,
  3925.            }
  3926.        }
  3927.        fn lex_identifier(&mut self) -> Result<Token, Diagnostic> {
  3928.            let start = self.pos;
  3929.            let mut end = self.pos;
  3930.            let mut ident = String::new();
  3931.            ident.push(self.get_current());
  3932.            self.advance();
  3933.            while !self.is_eof() {
  3934.                let c = self.get_current();
  3935.                if c.is_alphanumeric() || c == '_' {
  3936.                    ident.push(c);
  3937.                    end += 1;
  3938.                    self.advance();
  3939.                } else {
  3940.                    break;
  3941.                }
  3942.            }
  3943.            let kind = match ident.as_str() {
  3944.                "as" => TokenKind::As,
  3945.                "const" => TokenKind::Const,
  3946.                "mut" => TokenKind::Mut,
  3947.                "fun" => TokenKind::Fun,
  3948.                "data" => TokenKind::Data,
  3949.                "methods" => TokenKind::Methods,
  3950.                "true" => TokenKind::True,
  3951.                "false" => TokenKind::False,
  3952.                "none" => TokenKind::None,
  3953.                "loop" => TokenKind::Loop,
  3954.                "iter" => TokenKind::Iter,
  3955.                "ret" => TokenKind::Ret,
  3956.                "continue" => TokenKind::Continue,
  3957.                "break" => TokenKind::Break,
  3958.                "if" => TokenKind::If,
  3959.                "else" => TokenKind::Else,
  3960.                _ => TokenKind::Identifier,
  3961.            };
  3962.            let value = if kind == TokenKind::Identifier {
  3963.                TokenValue::String(INTERNER.write().intern_string(ident))
  3964.            } else {
  3965.                TokenValue::None
  3966.            };
  3967.            Ok(Token {
  3968.                value,
  3969.                kind,
  3970.                span: Span::new(start, end),
  3971.            })
  3972.        }
  3973.        fn lex_decimal_number(&mut self) -> Result<Token, Diagnostic> {
  3974.            let start = self.pos;
  3975.            let mut end = self.pos;
  3976.            let mut number = String::new();
  3977.            number.push(self.get_current());
  3978.            self.advance();
  3979.            while !self.is_eof() {
  3980.                let c = self.get_current();
  3981.                if c.is_numeric() || c == '.' {
  3982.                    number.push(c);
  3983.                    end += 1;
  3984.                    self.advance();
  3985.                } else {
  3986.                    break;
  3987.                }
  3988.            }
  3989.            let dot_count = number.matches('.').count();
  3990.            if dot_count > 1 {
  3991.                return Err(Diagnostic {
  3992.                    severity: Severity::Error,
  3993.                    code: ErrorCode::InvalidNumber,
  3994.                    message: "Invalid number".to_string(),
  3995.                    span: Span::new(start, end),
  3996.                });
  3997.            }
  3998.            let number = INTERNER.write().intern_string(number);
  3999.            Ok(Token {
  4000.                value: TokenValue::Number {
  4001.                    value: number,
  4002.                    kind: if dot_count == 1 {
  4003.                        NumberKind::DecFloat
  4004.                    } else {
  4005.                        NumberKind::DecInt
  4006.                    },
  4007.                },
  4008.                kind: TokenKind::Number,
  4009.                span: Span::new(start, end),
  4010.            })
  4011.        }
  4012.        fn lex_hex_number(&mut self) -> Result<Token, Diagnostic> {
  4013.            self.advance();
  4014.            self.advance();
  4015.            let start = self.pos;
  4016.            let mut end = self.pos;
  4017.            let mut number = String::new();
  4018.            number.push(self.get_current());
  4019.            self.advance();
  4020.            while !self.is_eof() {
  4021.                let c = self.get_current();
  4022.                if c.is_numeric() || "ABCDEFabcdef".contains(c) {
  4023.                    number.push(c);
  4024.                    end += 1;
  4025.                    self.advance();
  4026.                } else {
  4027.                    break;
  4028.                }
  4029.            }
  4030.            let number = INTERNER.write().intern_string(number);
  4031.            Ok(Token {
  4032.                value: TokenValue::Number {
  4033.                    value: number,
  4034.                    kind: NumberKind::Hex,
  4035.                },
  4036.                kind: TokenKind::Number,
  4037.                span: Span::new(start, end),
  4038.            })
  4039.        }
  4040.        fn lex_binary_number(&mut self) -> Result<Token, Diagnostic> {
  4041.            self.advance();
  4042.            self.advance();
  4043.            let start = self.pos;
  4044.            let mut end = self.pos;
  4045.            let mut number = String::new();
  4046.            number.push(self.get_current());
  4047.            self.advance();
  4048.            while !self.is_eof() {
  4049.                let c = self.get_current();
  4050.                if "01".contains(c) {
  4051.                    number.push(c);
  4052.                    end += 1;
  4053.                    self.advance();
  4054.                } else {
  4055.                    break;
  4056.                }
  4057.            }
  4058.            let number = INTERNER.write().intern_string(number);
  4059.            Ok(Token {
  4060.                value: TokenValue::Number {
  4061.                    value: number,
  4062.                    kind: NumberKind::Bin,
  4063.                },
  4064.                kind: TokenKind::Number,
  4065.                span: Span::new(start, end),
  4066.            })
  4067.        }
  4068.        fn lex_octal_number(&mut self) -> Result<Token, Diagnostic> {
  4069.            self.advance();
  4070.            self.advance();
  4071.            let start = self.pos;
  4072.            let mut end = self.pos;
  4073.            let mut number = String::new();
  4074.            number.push(self.get_current());
  4075.            self.advance();
  4076.            while !self.is_eof() {
  4077.                let c = self.get_current();
  4078.                if "01234567".contains(c) {
  4079.                    number.push(c);
  4080.                    end += 1;
  4081.                    self.advance();
  4082.                } else {
  4083.                    break;
  4084.                }
  4085.            }
  4086.            let number = INTERNER.write().intern_string(number);
  4087.            Ok(Token {
  4088.                value: TokenValue::Number {
  4089.                    value: number,
  4090.                    kind: NumberKind::Oct,
  4091.                },
  4092.                kind: TokenKind::Number,
  4093.                span: Span::new(start, end),
  4094.            })
  4095.        }
  4096.        fn lex_number(&mut self) -> Result<Token, Diagnostic> {
  4097.            match self.try_peek_next() {
  4098.                Some('x') => self.lex_hex_number(),
  4099.                Some('b') => self.lex_binary_number(),
  4100.                Some('o') => self.lex_octal_number(),
  4101.                _ => self.lex_decimal_number(),
  4102.            }
  4103.        }
  4104.        fn single_char_token(&mut self, kind: TokenKind) -> Token {
  4105.            let start = self.pos;
  4106.            let end = self.pos;
  4107.            self.advance();
  4108.            Token {
  4109.                value: TokenValue::None,
  4110.                kind,
  4111.                span: Span::new(start, end),
  4112.            }
  4113.        }
  4114.        fn maybe_double_char_token(
  4115.            &mut self,
  4116.            kind: TokenKind,
  4117.            next: &[char],
  4118.            double_kind: &[TokenKind],
  4119.        ) -> Token {
  4120.            let start = self.pos;
  4121.            let end = self.pos;
  4122.            self.advance();
  4123.            if !self.is_eof() {
  4124.                let ch = self.get_current();
  4125.                if next.contains(&ch) {
  4126.                    self.advance();
  4127.                    return Token {
  4128.                        value: TokenValue::None,
  4129.                        kind: double_kind[next.iter().position(|&c| c == ch).unwrap()],
  4130.                        span: Span::new(start, end + 1),
  4131.                    };
  4132.                }
  4133.            }
  4134.            Token {
  4135.                value: TokenValue::None,
  4136.                kind,
  4137.                span: Span::new(start, end),
  4138.            }
  4139.        }
  4140.        fn lex_string(&mut self) -> Result<Token, Diagnostic> {
  4141.            let start = self.pos;
  4142.            let mut end = self.pos;
  4143.            let mut string = String::new();
  4144.            self.advance();
  4145.            loop {
  4146.                if self.is_eof() {
  4147.                    return Err(Diagnostic {
  4148.                        severity: Severity::Error,
  4149.                        code: ErrorCode::UnterminatedString,
  4150.                        message: "Unterminated string".to_string(),
  4151.                        span: Span::new(start, end),
  4152.                    });
  4153.                }
  4154.                end += 1;
  4155.                let c = self.get_current();
  4156.                if c == '"' {
  4157.                    self.advance();
  4158.                    break;
  4159.                } else if c == '\\' {
  4160.                    let mut esc = "\\".to_string();
  4161.                    self.advance();
  4162.                    if self.is_eof() {
  4163.                        return Err(Diagnostic {
  4164.                            severity: Severity::Error,
  4165.                            code: ErrorCode::UnexpectedToken,
  4166.                            message: "Unexpected eof".to_string(),
  4167.                            span: Span::new(start, end + 1),
  4168.                        });
  4169.                    }
  4170.                    esc += &self.get_current().to_string();
  4171.                    end += 1;
  4172.                    let escape_char = match esc.as_str() {
  4173.                        "\\n" => '\n',
  4174.                        "\\t" => '\t',
  4175.                        "\\r" => '\r',
  4176.                        "\\\\" => '\\',
  4177.                        "\\\"" => '\"',
  4178.                         _ => {
  4179.                             return Err(Diagnostic {
  4180.                                 severity: Severity::Error,
  4181.                                 code: ErrorCode::InvalidEscapeCharacter,
  4182.                                 message: "Invalid escape character".to_string(),
  4183.                                 span: Span {
  4184.                                     lo: end - 2,
  4185.                                     hi: end,
  4186.                                 },
  4187.                             })
  4188.                         }
  4189.                     };
  4190.                     string.push(escape_char);
  4191.                     self.advance();
  4192.                     continue;
  4193.                 }
  4194.                 string.push(c);
  4195.                 self.advance();
  4196.             }
  4197.             Ok(Token {
  4198.                 value: TokenValue::String(INTERNER.write().intern_string(string)),
  4199.                 kind: TokenKind::String,
  4200.                 span: Span::new(start, end - 1),
  4201.             })
  4202.         }
  4203.         pub fn lex_once(&mut self) -> Result<Token, Diagnostic> {
  4204.             if self.is_eof() {
  4205.                 return Ok(Token {
  4206.                     value: TokenValue::None,
  4207.                     kind: TokenKind::Eof,
  4208.                     span: Span::new(self.pos, self.pos),
  4209.                 });
  4210.             }
  4211.             match self.get_current() {
  4212.                 '{' => Ok(self.single_char_token(TokenKind::LeftBrace)),
  4213.                 '}' => Ok(self.single_char_token(TokenKind::RightBrace)),
  4214.                 '(' => Ok(self.single_char_token(TokenKind::LeftParen)),
  4215.                 ')' => Ok(self.single_char_token(TokenKind::RightParen)),
  4216.                 '[' => Ok(self.single_char_token(TokenKind::LeftBracket)),
  4217.                 ']' => Ok(self.single_char_token(TokenKind::RightBracket)),
  4218.                 ',' => Ok(self.single_char_token(TokenKind::Comma)),
  4219.                 '.' => Ok(self.single_char_token(TokenKind::Dot)),
  4220.                 ';' => Ok(self.single_char_token(TokenKind::Semicolon)),
  4221.                 '~' => Ok(self.single_char_token(TokenKind::Tilde)),
  4222.                 '@' => Ok(self.single_char_token(TokenKind::At)),
  4223.                 ':' => Ok(self.single_char_token(TokenKind::Colon)),
  4224.                 '+' => {
  4225.                     Ok(self.maybe_double_char_token(TokenKind::Plus, &['='], &[TokenKind::PlusEq]))
  4226.                 }
  4227.                 '-' => Ok(self.maybe_double_char_token(
  4228.                     TokenKind::Minus,
  4229.                     &['='],
  4230.                     &[TokenKind::MinusEq],
  4231.                 )),
  4232.                 '*' => Ok(self.maybe_double_char_token(
  4233.                     TokenKind::Asterisk,
  4234.                     &['='],
  4235.                     &[TokenKind::AsteriskEq],
  4236.                 )),
  4237.                 '/' => {
  4238.                     if self.try_peek_next() == Some('/') {
  4239.                         self.advance();
  4240.                         while !self.is_eof() {
  4241.                             if self.get_current() == '\n' {
  4242.                                 self.advance();
  4243.                                 if !self.is_eof() {
  4244.                                     return self.lex_once();
  4245.                                 }
  4246.                             }
  4247.                             self.advance();
  4248.                         }
  4249.                         return self.lex_once();
  4250.                     }
  4251.                     Ok(self.maybe_double_char_token(
  4252.                         TokenKind::Slash,
  4253.                         &['='],
  4254.                         &[TokenKind::SlashEq],
  4255.                     ))
  4256.                 }
  4257.                 '%' => Ok(self.maybe_double_char_token(
  4258.                     TokenKind::Percent,
  4259.                     &['='],
  4260.                     &[TokenKind::PercentEq],
  4261.                 )),
  4262.                 '^' => Ok(self.maybe_double_char_token(
  4263.                     TokenKind::Caret,
  4264.                     &['='],
  4265.                     &[TokenKind::CaretEq],
  4266.                 )),
  4267.                 '&' => Ok(self.maybe_double_char_token(
  4268.                     TokenKind::Ampersand,
  4269.                     &['&', '='],
  4270.                     &[TokenKind::DoubleAmpersand, TokenKind::AmpersandEq],
  4271.                 )),
  4272.                 '|' => Ok(self.maybe_double_char_token(
  4273.                     TokenKind::Pipe,
  4274.                     &['|', '='],
  4275.                     &[TokenKind::DoublePipe, TokenKind::PipeEq],
  4276.                 )),
  4277.                 '!' => Ok(self.maybe_double_char_token(
  4278.                     TokenKind::Exclamation,
  4279.                     &['='],
  4280.                     &[TokenKind::ExclamationEq],
  4281.                 )),
  4282.                 '=' => Ok(self.maybe_double_char_token(
  4283.                     TokenKind::Equal,
  4284.                     &['='],
  4285.                     &[TokenKind::DoubleEqual],
  4286.                 )),
  4287.                 '<' => Ok({
  4288.                     if let Some('<') = self.try_peek_next() {
  4289.                         self.advance();
  4290.                         if let Some('=') = self.try_peek_next() {
  4291.                             self.advance();
  4292.                             self.advance();
  4293.                             Token {
  4294.                                 value: TokenValue::None,
  4295.                                 kind: TokenKind::DoubleLeftAngleEq,
  4296.                                 span: Span::new(self.pos - 3, self.pos - 1),
  4297.                             }
  4298.                         } else {
  4299.                             self.advance();
  4300.                             Token {
  4301.                                 value: TokenValue::None,
  4302.                                 kind: TokenKind::DoubleLeftAngle,
  4303.                                 span: Span::new(self.pos - 2, self.pos - 1),
  4304.                             }
  4305.                         }
  4306.                     } else if let Some('=') = self.try_peek_next() {
  4307.                         self.advance();
  4308.                         self.advance();
  4309.                         Token {
  4310.                             value: TokenValue::None,
  4311.                             kind: TokenKind::LeftAngleEq,
  4312.                             span: Span::new(self.pos - 2, self.pos - 1),
  4313.                         }
  4314.                     } else {
  4315.                         self.advance();
  4316.                         Token {
  4317.                             value: TokenValue::None,
  4318.                             kind: TokenKind::LeftAngle,
  4319.                             span: Span::new(self.pos - 1, self.pos - 1),
  4320.                         }
  4321.                     }
  4322.                 }),
  4323.                 '>' => Ok({
  4324.                     if let Some('>') = self.try_peek_next() {
  4325.                         self.advance();
  4326.                         if let Some('=') = self.try_peek_next() {
  4327.                             self.advance();
  4328.                             self.advance();
  4329.                             Token {
  4330.                                 value: TokenValue::None,
  4331.                                 kind: TokenKind::DoubleRightAngleEq,
  4332.                                 span: Span::new(self.pos - 3, self.pos - 1),
  4333.                             }
  4334.                         } else {
  4335.                             self.advance();
  4336.                             Token {
  4337.                                 value: TokenValue::None,
  4338.                                 kind: TokenKind::DoubleRightAngle,
  4339.                                 span: Span::new(self.pos - 2, self.pos - 1),
  4340.                             }
  4341.                         }
  4342.                     } else if let Some('=') = self.try_peek_next() {
  4343.                         self.advance();
  4344.                         self.advance();
  4345.                         Token {
  4346.                             value: TokenValue::None,
  4347.                             kind: TokenKind::RightAngleEq,
  4348.                             span: Span::new(self.pos - 2, self.pos - 1),
  4349.                         }
  4350.                     } else {
  4351.                         self.advance();
  4352.                         Token {
  4353.                             value: TokenValue::None,
  4354.                             kind: TokenKind::RightAngle,
  4355.                             span: Span::new(self.pos - 1, self.pos - 1),
  4356.                         }
  4357.                     }
  4358.                 }),
  4359.                 '"' => self.lex_string(),
  4360.                 '0'..='9' => self.lex_number(),
  4361.                 'a'..='z' | 'A'..='Z' => self.lex_identifier(),
  4362.                 c if c.is_whitespace() => {
  4363.                     self.advance();
  4364.                     self.lex_once()
  4365.                 }
  4366.                 _ => {
  4367.                     let e = Err(Diagnostic {
  4368.                         severity: Severity::Error,
  4369.                         code: ErrorCode::UnknownToken,
  4370.                         message: "Unknown character".to_string(),
  4371.                         span: self.current_char_span(),
  4372.                     });
  4373.                     self.advance();
  4374.                     e
  4375.                 }
  4376.             }
  4377.         }
  4378.         fn try_peek_next(&self) -> Option<char> {
  4379.             self.source_chars.clone().nth(self.pos + 1)
  4380.         }
  4381.         fn current_char_span(&self) -> Span {
  4382.             Span {
  4383.                 lo: self.pos,
  4384.                 hi: self.pos,
  4385.             }
  4386.         }
  4387.         fn get_current(&mut self) -> char {
  4388.             self.source_chars.clone().nth(self.pos).unwrap()
  4389.         }
  4390.         fn is_eof(&self) -> bool {
  4391.             self.pos >= self.source_len
  4392.         }
  4393.         fn advance(&mut self) {
  4394.             self.pos += 1;
  4395.         }
  4396.     }
  4397.     pub struct Token {
  4398.         pub value: TokenValue,
  4399.         pub kind: TokenKind,
  4400.         pub span: Span,
  4401.     }
  4402.     #[automatically_derived]
  4403.     impl ::core::fmt::Debug for Token {
  4404.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  4405.             ::core::fmt::Formatter::debug_struct_field3_finish(
  4406.                 f,
  4407.                 "Token",
  4408.                 "value",
  4409.                 &&self.value,
  4410.                 "kind",
  4411.                 &&self.kind,
  4412.                 "span",
  4413.                 &&self.span,
  4414.             )
  4415.         }
  4416.     }
  4417.     #[automatically_derived]
  4418.     impl ::core::marker::Copy for Token {}
  4419.     #[automatically_derived]
  4420.     impl ::core::clone::Clone for Token {
  4421.         #[inline]
  4422.         fn clone(&self) -> Token {
  4423.             let _: ::core::clone::AssertParamIsClone<TokenValue>;
  4424.             let _: ::core::clone::AssertParamIsClone<TokenKind>;
  4425.             let _: ::core::clone::AssertParamIsClone<Span>;
  4426.             *self
  4427.         }
  4428.     }
  4429.     pub enum TokenValue {
  4430.         String(InternedString),
  4431.         Number {
  4432.             kind: NumberKind,
  4433.             value: InternedString,
  4434.         },
  4435.         None,
  4436.     }
  4437.     #[automatically_derived]
  4438.     impl ::core::fmt::Debug for TokenValue {
  4439.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  4440.             match self {
  4441.                 TokenValue::String(__self_0) => {
  4442.                     ::core::fmt::Formatter::debug_tuple_field1_finish(f, "String", &__self_0)
  4443.                 }
  4444.                 TokenValue::Number {
  4445.                     kind: __self_0,
  4446.                     value: __self_1,
  4447.                 } => ::core::fmt::Formatter::debug_struct_field2_finish(
  4448.                     f, "Number", "kind", &__self_0, "value", &__self_1,
  4449.                 ),
  4450.                 TokenValue::None => ::core::fmt::Formatter::write_str(f, "None"),
  4451.             }
  4452.         }
  4453.     }
  4454.     #[automatically_derived]
  4455.     impl ::core::clone::Clone for TokenValue {
  4456.         #[inline]
  4457.         fn clone(&self) -> TokenValue {
  4458.             let _: ::core::clone::AssertParamIsClone<InternedString>;
  4459.             let _: ::core::clone::AssertParamIsClone<NumberKind>;
  4460.             *self
  4461.         }
  4462.     }
  4463.     #[automatically_derived]
  4464.     impl ::core::marker::Copy for TokenValue {}
  4465.     impl TokenValue {
  4466.         pub fn get_string(&self) -> InternedString {
  4467.             match self {
  4468.                 Self::String(s) => *s,
  4469.                 _ => ::core::panicking::panic_fmt(::core::fmt::Arguments::new_v1(
  4470.                     &["TokenValue::get_string() called on non TokenValue::String"],
  4471.                     &[],
  4472.                 )),
  4473.             }
  4474.         }
  4475.         pub fn get_number(&self) -> (InternedString, NumberKind) {
  4476.             match self {
  4477.                 Self::Number { value, kind } => (*value, *kind),
  4478.                 _ => ::core::panicking::panic_fmt(::core::fmt::Arguments::new_v1(
  4479.                     &["TokenValue::get_string() called on non TokenValue::String"],
  4480.                     &[],
  4481.                 )),
  4482.             }
  4483.         }
  4484.     }
  4485.     pub enum NumberKind {
  4486.         Bin,
  4487.         Hex,
  4488.         Oct,
  4489.         DecInt,
  4490.         DecFloat,
  4491.     }
  4492.     #[automatically_derived]
  4493.     impl ::core::fmt::Debug for NumberKind {
  4494.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  4495.             match self {
  4496.                 NumberKind::Bin => ::core::fmt::Formatter::write_str(f, "Bin"),
  4497.                 NumberKind::Hex => ::core::fmt::Formatter::write_str(f, "Hex"),
  4498.                 NumberKind::Oct => ::core::fmt::Formatter::write_str(f, "Oct"),
  4499.                 NumberKind::DecInt => ::core::fmt::Formatter::write_str(f, "DecInt"),
  4500.                 NumberKind::DecFloat => ::core::fmt::Formatter::write_str(f, "DecFloat"),
  4501.             }
  4502.         }
  4503.     }
  4504.     #[automatically_derived]
  4505.     impl ::core::marker::Copy for NumberKind {}
  4506.     #[automatically_derived]
  4507.     impl ::core::clone::Clone for NumberKind {
  4508.         #[inline]
  4509.         fn clone(&self) -> NumberKind {
  4510.             *self
  4511.         }
  4512.     }
  4513.     impl ::core::marker::StructuralPartialEq for NumberKind {}
  4514.     #[automatically_derived]
  4515.     impl ::core::cmp::PartialEq for NumberKind {
  4516.         #[inline]
  4517.         fn eq(&self, other: &NumberKind) -> bool {
  4518.             let __self_tag = ::core::intrinsics::discriminant_value(self);
  4519.             let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  4520.             __self_tag == __arg1_tag
  4521.         }
  4522.     }
  4523.     #[automatically_derived]
  4524.     impl ::core::cmp::PartialOrd for NumberKind {
  4525.         #[inline]
  4526.         fn partial_cmp(&self, other: &NumberKind) -> ::core::option::Option<::core::cmp::Ordering> {
  4527.             let __self_tag = ::core::intrinsics::discriminant_value(self);
  4528.             let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  4529.             ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
  4530.         }
  4531.     }
  4532.     impl ::core::marker::StructuralEq for NumberKind {}
  4533.     #[automatically_derived]
  4534.     impl ::core::cmp::Eq for NumberKind {
  4535.         #[inline]
  4536.         #[doc(hidden)]
  4537.         #[no_coverage]
  4538.         fn assert_receiver_is_total_eq(&self) -> () {}
  4539.     }
  4540.     #[automatically_derived]
  4541.     impl ::core::cmp::Ord for NumberKind {
  4542.         #[inline]
  4543.         fn cmp(&self, other: &NumberKind) -> ::core::cmp::Ordering {
  4544.             let __self_tag = ::core::intrinsics::discriminant_value(self);
  4545.             let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  4546.             ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
  4547.         }
  4548.     }
  4549.     impl NumberKind {
  4550.         pub fn radix(&self) -> u32 {
  4551.             match self {
  4552.                 Self::Bin => 2,
  4553.                 Self::Hex => 16,
  4554.                 Self::Oct => 8,
  4555.                 Self::DecInt | Self::DecFloat => 10,
  4556.             }
  4557.         }
  4558.     }
  4559.     pub enum TokenKind {
  4560.         String,
  4561.         Number,
  4562.         Identifier,
  4563.         As,
  4564.         Const,
  4565.         Mut,
  4566.         Fun,
  4567.         Data,
  4568.         Methods,
  4569.         Continue,
  4570.         Break,
  4571.         Loop,
  4572.         Iter,
  4573.         Ret,
  4574.         If,
  4575.         Else,
  4576.         True,
  4577.         False,
  4578.         None,
  4579.         Plus,
  4580.         PlusEq,
  4581.         Minus,
  4582.         MinusEq,
  4583.         Asterisk,
  4584.         AsteriskEq,
  4585.         Slash,
  4586.         SlashEq,
  4587.         Percent,
  4588.         PercentEq,
  4589.         Caret,
  4590.         CaretEq,
  4591.         Ampersand,
  4592.         AmpersandEq,
  4593.         DoubleAmpersand,
  4594.         Pipe,
  4595.         PipeEq,
  4596.         DoublePipe,
  4597.         Tilde,
  4598.         Exclamation,
  4599.         ExclamationEq,
  4600.         LeftAngle,
  4601.         LeftAngleEq,
  4602.         DoubleLeftAngle,
  4603.         DoubleLeftAngleEq,
  4604.         RightAngle,
  4605.         RightAngleEq,
  4606.         DoubleRightAngle,
  4607.         DoubleRightAngleEq,
  4608.         Equal,
  4609.         DoubleEqual,
  4610.         LeftParen,
  4611.         RightParen,
  4612.         LeftBrace,
  4613.         RightBrace,
  4614.         LeftBracket,
  4615.         RightBracket,
  4616.         Comma,
  4617.         Dot,
  4618.         Colon,
  4619.         Semicolon,
  4620.         At,
  4621.         Eof,
  4622.     }
  4623.     #[automatically_derived]
  4624.     impl ::core::fmt::Debug for TokenKind {
  4625.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  4626.             match self {
  4627.                 TokenKind::String => ::core::fmt::Formatter::write_str(f, "String"),
  4628.                 TokenKind::Number => ::core::fmt::Formatter::write_str(f, "Number"),
  4629.                 TokenKind::Identifier => ::core::fmt::Formatter::write_str(f, "Identifier"),
  4630.                 TokenKind::As => ::core::fmt::Formatter::write_str(f, "As"),
  4631.                 TokenKind::Const => ::core::fmt::Formatter::write_str(f, "Const"),
  4632.                 TokenKind::Mut => ::core::fmt::Formatter::write_str(f, "Mut"),
  4633.                 TokenKind::Fun => ::core::fmt::Formatter::write_str(f, "Fun"),
  4634.                 TokenKind::Data => ::core::fmt::Formatter::write_str(f, "Data"),
  4635.                 TokenKind::Methods => ::core::fmt::Formatter::write_str(f, "Methods"),
  4636.                 TokenKind::Continue => ::core::fmt::Formatter::write_str(f, "Continue"),
  4637.                 TokenKind::Break => ::core::fmt::Formatter::write_str(f, "Break"),
  4638.                 TokenKind::Loop => ::core::fmt::Formatter::write_str(f, "Loop"),
  4639.                 TokenKind::Iter => ::core::fmt::Formatter::write_str(f, "Iter"),
  4640.                 TokenKind::Ret => ::core::fmt::Formatter::write_str(f, "Ret"),
  4641.                 TokenKind::If => ::core::fmt::Formatter::write_str(f, "If"),
  4642.                 TokenKind::Else => ::core::fmt::Formatter::write_str(f, "Else"),
  4643.                 TokenKind::True => ::core::fmt::Formatter::write_str(f, "True"),
  4644.                 TokenKind::False => ::core::fmt::Formatter::write_str(f, "False"),
  4645.                 TokenKind::None => ::core::fmt::Formatter::write_str(f, "None"),
  4646.                 TokenKind::Plus => ::core::fmt::Formatter::write_str(f, "Plus"),
  4647.                 TokenKind::PlusEq => ::core::fmt::Formatter::write_str(f, "PlusEq"),
  4648.                 TokenKind::Minus => ::core::fmt::Formatter::write_str(f, "Minus"),
  4649.                 TokenKind::MinusEq => ::core::fmt::Formatter::write_str(f, "MinusEq"),
  4650.                 TokenKind::Asterisk => ::core::fmt::Formatter::write_str(f, "Asterisk"),
  4651.                 TokenKind::AsteriskEq => ::core::fmt::Formatter::write_str(f, "AsteriskEq"),
  4652.                 TokenKind::Slash => ::core::fmt::Formatter::write_str(f, "Slash"),
  4653.                 TokenKind::SlashEq => ::core::fmt::Formatter::write_str(f, "SlashEq"),
  4654.                 TokenKind::Percent => ::core::fmt::Formatter::write_str(f, "Percent"),
  4655.                 TokenKind::PercentEq => ::core::fmt::Formatter::write_str(f, "PercentEq"),
  4656.                 TokenKind::Caret => ::core::fmt::Formatter::write_str(f, "Caret"),
  4657.                 TokenKind::CaretEq => ::core::fmt::Formatter::write_str(f, "CaretEq"),
  4658.                 TokenKind::Ampersand => ::core::fmt::Formatter::write_str(f, "Ampersand"),
  4659.                 TokenKind::AmpersandEq => ::core::fmt::Formatter::write_str(f, "AmpersandEq"),
  4660.                 TokenKind::DoubleAmpersand => {
  4661.                     ::core::fmt::Formatter::write_str(f, "DoubleAmpersand")
  4662.                 }
  4663.                 TokenKind::Pipe => ::core::fmt::Formatter::write_str(f, "Pipe"),
  4664.                 TokenKind::PipeEq => ::core::fmt::Formatter::write_str(f, "PipeEq"),
  4665.                 TokenKind::DoublePipe => ::core::fmt::Formatter::write_str(f, "DoublePipe"),
  4666.                 TokenKind::Tilde => ::core::fmt::Formatter::write_str(f, "Tilde"),
  4667.                 TokenKind::Exclamation => ::core::fmt::Formatter::write_str(f, "Exclamation"),
  4668.                 TokenKind::ExclamationEq => ::core::fmt::Formatter::write_str(f, "ExclamationEq"),
  4669.                 TokenKind::LeftAngle => ::core::fmt::Formatter::write_str(f, "LeftAngle"),
  4670.                 TokenKind::LeftAngleEq => ::core::fmt::Formatter::write_str(f, "LeftAngleEq"),
  4671.                 TokenKind::DoubleLeftAngle => {
  4672.                     ::core::fmt::Formatter::write_str(f, "DoubleLeftAngle")
  4673.                 }
  4674.                 TokenKind::DoubleLeftAngleEq => {
  4675.                     ::core::fmt::Formatter::write_str(f, "DoubleLeftAngleEq")
  4676.                 }
  4677.                 TokenKind::RightAngle => ::core::fmt::Formatter::write_str(f, "RightAngle"),
  4678.                 TokenKind::RightAngleEq => ::core::fmt::Formatter::write_str(f, "RightAngleEq"),
  4679.                 TokenKind::DoubleRightAngle => {
  4680.                     ::core::fmt::Formatter::write_str(f, "DoubleRightAngle")
  4681.                 }
  4682.                 TokenKind::DoubleRightAngleEq => {
  4683.                     ::core::fmt::Formatter::write_str(f, "DoubleRightAngleEq")
  4684.                 }
  4685.                 TokenKind::Equal => ::core::fmt::Formatter::write_str(f, "Equal"),
  4686.                 TokenKind::DoubleEqual => ::core::fmt::Formatter::write_str(f, "DoubleEqual"),
  4687.                 TokenKind::LeftParen => ::core::fmt::Formatter::write_str(f, "LeftParen"),
  4688.                 TokenKind::RightParen => ::core::fmt::Formatter::write_str(f, "RightParen"),
  4689.                 TokenKind::LeftBrace => ::core::fmt::Formatter::write_str(f, "LeftBrace"),
  4690.                 TokenKind::RightBrace => ::core::fmt::Formatter::write_str(f, "RightBrace"),
  4691.                 TokenKind::LeftBracket => ::core::fmt::Formatter::write_str(f, "LeftBracket"),
  4692.                 TokenKind::RightBracket => ::core::fmt::Formatter::write_str(f, "RightBracket"),
  4693.                 TokenKind::Comma => ::core::fmt::Formatter::write_str(f, "Comma"),
  4694.                 TokenKind::Dot => ::core::fmt::Formatter::write_str(f, "Dot"),
  4695.                 TokenKind::Colon => ::core::fmt::Formatter::write_str(f, "Colon"),
  4696.                 TokenKind::Semicolon => ::core::fmt::Formatter::write_str(f, "Semicolon"),
  4697.                 TokenKind::At => ::core::fmt::Formatter::write_str(f, "At"),
  4698.                 TokenKind::Eof => ::core::fmt::Formatter::write_str(f, "Eof"),
  4699.             }
  4700.         }
  4701.     }
  4702.     #[automatically_derived]
  4703.     impl ::core::marker::Copy for TokenKind {}
  4704.     #[automatically_derived]
  4705.     impl ::core::clone::Clone for TokenKind {
  4706.         #[inline]
  4707.         fn clone(&self) -> TokenKind {
  4708.             *self
  4709.         }
  4710.     }
  4711.     impl ::core::marker::StructuralPartialEq for TokenKind {}
  4712.     #[automatically_derived]
  4713.     impl ::core::cmp::PartialEq for TokenKind {
  4714.         #[inline]
  4715.         fn eq(&self, other: &TokenKind) -> bool {
  4716.             let __self_tag = ::core::intrinsics::discriminant_value(self);
  4717.             let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  4718.             __self_tag == __arg1_tag
  4719.         }
  4720.     }
  4721.     #[automatically_derived]
  4722.     impl ::core::cmp::PartialOrd for TokenKind {
  4723.         #[inline]
  4724.         fn partial_cmp(&self, other: &TokenKind) -> ::core::option::Option<::core::cmp::Ordering> {
  4725.             let __self_tag = ::core::intrinsics::discriminant_value(self);
  4726.             let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  4727.             ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
  4728.         }
  4729.     }
  4730.     impl ::core::marker::StructuralEq for TokenKind {}
  4731.     #[automatically_derived]
  4732.     impl ::core::cmp::Eq for TokenKind {
  4733.         #[inline]
  4734.         #[doc(hidden)]
  4735.         #[no_coverage]
  4736.         fn assert_receiver_is_total_eq(&self) -> () {}
  4737.     }
  4738.     #[automatically_derived]
  4739.     impl ::core::cmp::Ord for TokenKind {
  4740.         #[inline]
  4741.         fn cmp(&self, other: &TokenKind) -> ::core::cmp::Ordering {
  4742.             let __self_tag = ::core::intrinsics::discriminant_value(self);
  4743.             let __arg1_tag = ::core::intrinsics::discriminant_value(other);
  4744.             ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
  4745.         }
  4746.     }
  4747. }
  4748. mod memory {
  4749.     use crate::interner::InternedString;
  4750.     use std::collections::HashMap;
  4751.     use std::fmt::Debug;
  4752.     use crate::ast::{DataStmt, FunStmt};
  4753.     use crate::diagnostics::Diagnostic;
  4754.     use crate::Interpreter;
  4755.     use parking_lot::RwLock;
  4756.     use std::sync::Arc;
  4757.     pub struct Allocator {
  4758.         allocations: Vec<Arc<RwLock<Value>>>,
  4759.     }
  4760.     impl Allocator {
  4761.         pub const fn new() -> Self {
  4762.             Self {
  4763.                 allocations: alloc::vec::Vec::new(),
  4764.             }
  4765.         }
  4766.         pub fn get_none(&self) -> ValueAddr {
  4767.             ValueAddr(0)
  4768.         }
  4769.         pub fn allocate(&mut self, value: Value) -> ValueAddr {
  4770.             if self.allocations.is_empty() {
  4771.                 self.allocations.push(Arc::new(RwLock::new(Value::None)));
  4772.             }
  4773.             if match value {
  4774.                 Value::None => true,
  4775.                 _ => false,
  4776.             } {
  4777.                 return ValueAddr(0);
  4778.             }
  4779.             self.allocations.push(Arc::new(RwLock::new(value)));
  4780.             ValueAddr(self.allocations.len() - 1)
  4781.         }
  4782.         pub fn clone(&mut self, addr: ValueAddr) -> ValueAddr {
  4783.             let value_arc = self.allocations[addr.0].clone();
  4784.             let value_read = value_arc.read();
  4785.             let cloned_value = match &*value_read {
  4786.                 Value::Int(i) => Value::Int(*i),
  4787.                 Value::Float(f) => Value::Float(*f),
  4788.                 Value::Boolean(b) => Value::Boolean(*b),
  4789.                 Value::String(s) => Value::String(*s),
  4790.                 Value::None => Value::None,
  4791.                 Value::Function(_f) => return addr,
  4792.                 Value::Data(d, m) => Value::Data(d.clone(), m.clone()),
  4793.                 Value::DataObject(d_object) => Value::DataObject(d_object.clone()),
  4794.                 Value::Array(a) => Value::Array(a.clone()),
  4795.             };
  4796.             self.allocations.push(Arc::new(RwLock::new(cloned_value)));
  4797.             ValueAddr(self.allocations.len() - 1)
  4798.         }
  4799.         pub fn deallocate(&mut self, addr: ValueAddr) {
  4800.             if let Some(obj) = self.allocations.get(addr.0) {
  4801.                 if Arc::strong_count(obj) == 0 {
  4802.                     self.allocations.remove(addr.0);
  4803.                 }
  4804.             }
  4805.         }
  4806.         pub fn get(&self, addr: ValueAddr) -> Arc<RwLock<Value>> {
  4807.             self.allocations[addr.0].clone()
  4808.         }
  4809.     }
  4810.     pub struct ValueAddr(usize);
  4811.     #[automatically_derived]
  4812.     impl ::core::fmt::Debug for ValueAddr {
  4813.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  4814.             ::core::fmt::Formatter::debug_tuple_field1_finish(f, "ValueAddr", &&self.0)
  4815.         }
  4816.     }
  4817.     #[automatically_derived]
  4818.     impl ::core::clone::Clone for ValueAddr {
  4819.         #[inline]
  4820.         fn clone(&self) -> ValueAddr {
  4821.             let _: ::core::clone::AssertParamIsClone<usize>;
  4822.             *self
  4823.         }
  4824.     }
  4825.     #[automatically_derived]
  4826.     impl ::core::marker::Copy for ValueAddr {}
  4827.     pub enum Value {
  4828.         Int(i64),
  4829.         Float(f64),
  4830.         Boolean(bool),
  4831.         String(InternedString),
  4832.         None,
  4833.         Function(Box<dyn Callable>),
  4834.         Data(Box<DataStmt>, HashMap<InternedString, Box<FunStmt>>),
  4835.         DataObject(DataObject),
  4836.         Array(Vec<ValueAddr>),
  4837.     }
  4838.     #[automatically_derived]
  4839.     impl ::core::fmt::Debug for Value {
  4840.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  4841.             match self {
  4842.                 Value::Int(__self_0) => {
  4843.                     ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Int", &__self_0)
  4844.                 }
  4845.                 Value::Float(__self_0) => {
  4846.                     ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Float", &__self_0)
  4847.                 }
  4848.                 Value::Boolean(__self_0) => {
  4849.                     ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Boolean", &__self_0)
  4850.                 }
  4851.                 Value::String(__self_0) => {
  4852.                     ::core::fmt::Formatter::debug_tuple_field1_finish(f, "String", &__self_0)
  4853.                 }
  4854.                 Value::None => ::core::fmt::Formatter::write_str(f, "None"),
  4855.                 Value::Function(__self_0) => {
  4856.                     ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Function", &__self_0)
  4857.                 }
  4858.                 Value::Data(__self_0, __self_1) => {
  4859.                     ::core::fmt::Formatter::debug_tuple_field2_finish(
  4860.                         f, "Data", &__self_0, &__self_1,
  4861.                     )
  4862.                 }
  4863.                 Value::DataObject(__self_0) => {
  4864.                     ::core::fmt::Formatter::debug_tuple_field1_finish(f, "DataObject", &__self_0)
  4865.                 }
  4866.                 Value::Array(__self_0) => {
  4867.                     ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Array", &__self_0)
  4868.                 }
  4869.             }
  4870.         }
  4871.     }
  4872.     impl Value {
  4873.         pub fn type_(&self) -> String {
  4874.             String::from(match self {
  4875.                 Value::Int(_) => "int",
  4876.                 Value::Float(_) => "float",
  4877.                 Value::Boolean(_) => "boolean",
  4878.                 Value::String(_) => "string",
  4879.                 Value::None => "none",
  4880.                 Value::Function(_) => "function",
  4881.                 Value::DataObject(_) => "data object",
  4882.                 Value::Data(_, _) => "data",
  4883.                 Value::Array(_) => "array",
  4884.             })
  4885.         }
  4886.     }
  4887.     pub trait Callable: Debug + Send + Sync {
  4888.         fn arity(&self) -> usize;
  4889.         fn call(
  4890.             &self,
  4891.             interpreter: &mut Interpreter,
  4892.             args: Vec<ValueAddr>,
  4893.         ) -> Result<Option<ValueAddr>, Diagnostic>;
  4894.         fn to_string(&self) -> String;
  4895.         fn clone(&self) -> Self
  4896.         where
  4897.             Self: Sized;
  4898.     }
  4899.     pub struct DataObject {
  4900.         pub name: InternedString,
  4901.         pub values: HashMap<InternedString, ValueAddr>,
  4902.     }
  4903.     #[automatically_derived]
  4904.     impl ::core::fmt::Debug for DataObject {
  4905.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  4906.             ::core::fmt::Formatter::debug_struct_field2_finish(
  4907.                 f,
  4908.                 "DataObject",
  4909.                 "name",
  4910.                 &&self.name,
  4911.                 "values",
  4912.                 &&self.values,
  4913.             )
  4914.         }
  4915.     }
  4916.     #[automatically_derived]
  4917.     impl ::core::clone::Clone for DataObject {
  4918.         #[inline]
  4919.         fn clone(&self) -> DataObject {
  4920.             DataObject {
  4921.                 name: ::core::clone::Clone::clone(&self.name),
  4922.                 values: ::core::clone::Clone::clone(&self.values),
  4923.             }
  4924.         }
  4925.     }
  4926. }
  4927. mod native {
  4928.     use crate::diagnostics::{Diagnostic, ErrorCode, Severity, Span};
  4929.     use crate::interner::INTERNER;
  4930.     use crate::memory::{Allocator, Value};
  4931.     use crate::memory::{Callable, ValueAddr};
  4932.     use crate::Interpreter;
  4933.     use std::io::Write;
  4934.     use std::thread::sleep;
  4935.     use std::time::Duration;
  4936.     pub struct PrintFunction {}
  4937.     #[automatically_derived]
  4938.     impl ::core::fmt::Debug for PrintFunction {
  4939.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  4940.             ::core::fmt::Formatter::write_str(f, "PrintFunction")
  4941.         }
  4942.     }
  4943.     #[automatically_derived]
  4944.     impl ::core::clone::Clone for PrintFunction {
  4945.         #[inline]
  4946.         fn clone(&self) -> PrintFunction {
  4947.             PrintFunction {}
  4948.         }
  4949.     }
  4950.     impl PrintFunction {
  4951.         pub fn stringify_value(allocator: &Allocator, value: &Value) -> String {
  4952.             match &*value {
  4953.                 Value::Int(i) => i.to_string(),
  4954.                 Value::Float(f) => f.to_string(),
  4955.                 Value::Boolean(b) => b.to_string(),
  4956.                 Value::String(s) => INTERNER.read().get_interned_string(*s).to_string(),
  4957.                 Value::None => "None".to_string(),
  4958.                 Value::Function(f) => f.to_string(),
  4959.                 Value::Data(_, _) => "<data>".to_string(),
  4960.                 Value::DataObject(_) => {
  4961.                     let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  4962.                         &["<data object at 0x", ">"],
  4963.                         &[::core::fmt::ArgumentV1::new_pointer(&(value as *const _))],
  4964.                     ));
  4965.                     res
  4966.                 }
  4967.                 Value::Array(a) => {
  4968.                     let mut res = String::from("[");
  4969.                     let mut str_vals = alloc::vec::Vec::new();
  4970.                     for v in a {
  4971.                         let val = allocator.get(*v);
  4972.                         let val_reader = val.read();
  4973.                         if let Value::String(s) = &*val_reader {
  4974.                             str_vals.push({
  4975.                                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  4976.                                     &[""],
  4977.                                     &[::core::fmt::ArgumentV1::new_debug(
  4978.                                         &INTERNER.read().get_interned_string(*s),
  4979.                                     )],
  4980.                                 ));
  4981.                                 res
  4982.                             });
  4983.                         } else {
  4984.                             str_vals.push(Self::stringify_value(allocator, &*val_reader));
  4985.                         }
  4986.                     }
  4987.                     res.push_str(&str_vals.join(", "));
  4988.                     res.push(']');
  4989.                     res
  4990.                 }
  4991.             }
  4992.         }
  4993.     }
  4994.     impl Callable for PrintFunction {
  4995.         fn arity(&self) -> usize {
  4996.             usize::MAX
  4997.         }
  4998.         fn call(
  4999.             &self,
  5000.             interpreter: &mut Interpreter,
  5001.             args: Vec<ValueAddr>,
  5002.         ) -> Result<Option<ValueAddr>, Diagnostic> {
  5003.             for arg in args {
  5004.                 let value = interpreter.get_allocator().get(arg);
  5005.                 let value_read = value.read();
  5006.                 {
  5007.                     ::std::io::_print(::core::fmt::Arguments::new_v1(
  5008.                         &[""],
  5009.                         &[::core::fmt::ArgumentV1::new_display(
  5010.                             &Self::stringify_value(interpreter.get_allocator_mut(), &*value_read),
  5011.                         )],
  5012.                     ));
  5013.                 };
  5014.                 std::io::stdout().flush().unwrap();
  5015.             }
  5016.             Ok(None)
  5017.         }
  5018.         fn to_string(&self) -> String {
  5019.             {
  5020.                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5021.                     &["<native function \"print\" at ", ">"],
  5022.                     &[::core::fmt::ArgumentV1::new_pointer(&(self as *const _))],
  5023.                 ));
  5024.                 res
  5025.             }
  5026.         }
  5027.         fn clone(&self) -> Self
  5028.         where
  5029.             Self: Sized,
  5030.         {
  5031.             Clone::clone(self)
  5032.         }
  5033.     }
  5034.     pub struct PrintlnFunction {}
  5035.     #[automatically_derived]
  5036.     impl ::core::fmt::Debug for PrintlnFunction {
  5037.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  5038.             ::core::fmt::Formatter::write_str(f, "PrintlnFunction")
  5039.         }
  5040.     }
  5041.     #[automatically_derived]
  5042.     impl ::core::clone::Clone for PrintlnFunction {
  5043.         #[inline]
  5044.         fn clone(&self) -> PrintlnFunction {
  5045.             PrintlnFunction {}
  5046.         }
  5047.     }
  5048.     impl Callable for PrintlnFunction {
  5049.         fn arity(&self) -> usize {
  5050.             usize::MAX
  5051.         }
  5052.         fn call(
  5053.             &self,
  5054.             interpreter: &mut Interpreter,
  5055.             args: Vec<ValueAddr>,
  5056.         ) -> Result<Option<ValueAddr>, Diagnostic> {
  5057.             PrintFunction {}.call(interpreter, args)?;
  5058.             {
  5059.                 ::std::io::_print(::core::fmt::Arguments::new_v1(&["\n"], &[]));
  5060.             };
  5061.             std::io::stdout().flush().unwrap();
  5062.             Ok(None)
  5063.         }
  5064.         fn to_string(&self) -> String {
  5065.             {
  5066.                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5067.                     &["<native function \"println\" at ", ">"],
  5068.                     &[::core::fmt::ArgumentV1::new_pointer(&(self as *const _))],
  5069.                 ));
  5070.                 res
  5071.             }
  5072.         }
  5073.         fn clone(&self) -> Self
  5074.         where
  5075.             Self: Sized,
  5076.         {
  5077.             Clone::clone(self)
  5078.         }
  5079.     }
  5080.     pub struct SleepFunction {}
  5081.     #[automatically_derived]
  5082.     impl ::core::fmt::Debug for SleepFunction {
  5083.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  5084.             ::core::fmt::Formatter::write_str(f, "SleepFunction")
  5085.         }
  5086.     }
  5087.     #[automatically_derived]
  5088.     impl ::core::clone::Clone for SleepFunction {
  5089.         #[inline]
  5090.         fn clone(&self) -> SleepFunction {
  5091.             SleepFunction {}
  5092.         }
  5093.     }
  5094.     impl Callable for SleepFunction {
  5095.         fn arity(&self) -> usize {
  5096.             1
  5097.         }
  5098.         fn call(
  5099.             &self,
  5100.             interpreter: &mut Interpreter,
  5101.             args: Vec<ValueAddr>,
  5102.         ) -> Result<Option<ValueAddr>, Diagnostic> {
  5103.             let time_addr = args[0];
  5104.             let time_container = interpreter.get_allocator().get(time_addr);
  5105.             let time_read = time_container.read();
  5106.             let time = match &*time_read {
  5107.                 Value::Int(i) => *i as f64,
  5108.                 Value::Float(f) => *f,
  5109.                 val => {
  5110.                     return Err(Diagnostic {
  5111.                         severity: Severity::Error,
  5112.                         code: ErrorCode::InvalidType,
  5113.                         message: {
  5114.                             let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5115.                                 &["Expected type `int` or `float`, found type `", "`"],
  5116.                                 &[::core::fmt::ArgumentV1::new_display(&val.type_())],
  5117.                             ));
  5118.                             res
  5119.                         },
  5120.                         span: Span {
  5121.                             lo: usize::MAX,
  5122.                             hi: usize::MAX,
  5123.                         },
  5124.                     })
  5125.                 }
  5126.             };
  5127.             sleep(Duration::from_secs_f64(time));
  5128.             Ok(None)
  5129.         }
  5130.         fn to_string(&self) -> String {
  5131.             {
  5132.                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5133.                     &["<native function \"sleep\" at ", ">"],
  5134.                     &[::core::fmt::ArgumentV1::new_pointer(&(self as *const _))],
  5135.                 ));
  5136.                 res
  5137.             }
  5138.         }
  5139.         fn clone(&self) -> Self
  5140.         where
  5141.             Self: Sized,
  5142.         {
  5143.             Clone::clone(self)
  5144.         }
  5145.     }
  5146.     pub struct ArrayPopFunction {}
  5147.     #[automatically_derived]
  5148.     impl ::core::fmt::Debug for ArrayPopFunction {
  5149.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  5150.             ::core::fmt::Formatter::write_str(f, "ArrayPopFunction")
  5151.         }
  5152.     }
  5153.     #[automatically_derived]
  5154.     impl ::core::clone::Clone for ArrayPopFunction {
  5155.         #[inline]
  5156.         fn clone(&self) -> ArrayPopFunction {
  5157.             ArrayPopFunction {}
  5158.         }
  5159.     }
  5160.     impl Callable for ArrayPopFunction {
  5161.         fn arity(&self) -> usize {
  5162.             1
  5163.         }
  5164.         fn call(
  5165.             &self,
  5166.             interpreter: &mut Interpreter,
  5167.             args: Vec<ValueAddr>,
  5168.         ) -> Result<Option<ValueAddr>, Diagnostic> {
  5169.             let array_addr = args[0];
  5170.             let array_container = interpreter.get_allocator().get(array_addr);
  5171.             let mut array_read = array_container.write();
  5172.             let array = match &mut *array_read {
  5173.                 Value::Array(arr) => arr,
  5174.                 val => {
  5175.                     return Err(Diagnostic {
  5176.                         severity: Severity::Error,
  5177.                         code: ErrorCode::InvalidType,
  5178.                         message: {
  5179.                             let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5180.                                 &["Expected type `array`, found type `", "`"],
  5181.                                 &[::core::fmt::ArgumentV1::new_display(&val.type_())],
  5182.                             ));
  5183.                             res
  5184.                         },
  5185.                         span: Span {
  5186.                             lo: usize::MAX,
  5187.                             hi: usize::MAX,
  5188.                         },
  5189.                     })
  5190.                 }
  5191.             };
  5192.             Ok(array.pop())
  5193.         }
  5194.         fn to_string(&self) -> String {
  5195.             {
  5196.                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5197.                     &["<native function \"sleep\" at ", ">"],
  5198.                     &[::core::fmt::ArgumentV1::new_pointer(&(self as *const _))],
  5199.                 ));
  5200.                 res
  5201.             }
  5202.         }
  5203.         fn clone(&self) -> Self
  5204.         where
  5205.             Self: Sized,
  5206.         {
  5207.             Clone::clone(self)
  5208.         }
  5209.     }
  5210.     pub struct InputFunction {}
  5211.     #[automatically_derived]
  5212.     impl ::core::fmt::Debug for InputFunction {
  5213.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  5214.             ::core::fmt::Formatter::write_str(f, "InputFunction")
  5215.         }
  5216.     }
  5217.     #[automatically_derived]
  5218.     impl ::core::clone::Clone for InputFunction {
  5219.         #[inline]
  5220.         fn clone(&self) -> InputFunction {
  5221.             InputFunction {}
  5222.         }
  5223.     }
  5224.     impl Callable for InputFunction {
  5225.         fn arity(&self) -> usize {
  5226.             usize::MAX
  5227.         }
  5228.         fn call(
  5229.             &self,
  5230.             interpreter: &mut Interpreter,
  5231.             args: Vec<ValueAddr>,
  5232.         ) -> Result<Option<ValueAddr>, Diagnostic> {
  5233.             if !args.is_empty() {
  5234.                 PrintFunction {}.call(interpreter, args)?;
  5235.             }
  5236.             let mut line = String::new();
  5237.             loop {
  5238.                 let size = std::io::stdin().read_line(&mut line).unwrap();
  5239.                 if size > 1 {
  5240.                     break;
  5241.                 }
  5242.             }
  5243.             line.pop();
  5244.             Ok(Some(interpreter.get_allocator_mut().allocate(
  5245.                 Value::String(INTERNER.write().intern_string(line)),
  5246.             )))
  5247.         }
  5248.         fn to_string(&self) -> String {
  5249.             {
  5250.                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5251.                     &["<native function \"input\" at ", ">"],
  5252.                     &[::core::fmt::ArgumentV1::new_pointer(&(self as *const _))],
  5253.                 ));
  5254.                 res
  5255.             }
  5256.         }
  5257.         fn clone(&self) -> Self
  5258.         where
  5259.             Self: Sized,
  5260.         {
  5261.             Clone::clone(self)
  5262.         }
  5263.     }
  5264.     pub struct IntFunction {}
  5265.     #[automatically_derived]
  5266.     impl ::core::fmt::Debug for IntFunction {
  5267.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  5268.             ::core::fmt::Formatter::write_str(f, "IntFunction")
  5269.         }
  5270.     }
  5271.     #[automatically_derived]
  5272.     impl ::core::clone::Clone for IntFunction {
  5273.         #[inline]
  5274.         fn clone(&self) -> IntFunction {
  5275.             IntFunction {}
  5276.         }
  5277.     }
  5278.     impl Callable for IntFunction {
  5279.         fn arity(&self) -> usize {
  5280.             1
  5281.         }
  5282.         fn call(
  5283.             &self,
  5284.             interpreter: &mut Interpreter,
  5285.             args: Vec<ValueAddr>,
  5286.         ) -> Result<Option<ValueAddr>, Diagnostic> {
  5287.             let n_s = args[0];
  5288.             let n_container = interpreter.get_allocator().get(n_s);
  5289.             let n_read = n_container.read();
  5290.             let res: i64 = match &*n_read {
  5291.                 Value::String(s) => match INTERNER.read().get_interned_string(*s).parse() {
  5292.                     Ok(res) => res,
  5293.                     Err(e) => {
  5294.                         return Err(Diagnostic {
  5295.                             span: Span {
  5296.                                 lo: usize::MAX,
  5297.                                 hi: usize::MAX,
  5298.                             },
  5299.                             code: ErrorCode::InvalidNumber,
  5300.                             message: {
  5301.                                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5302.                                     &["Failed to parse number: "],
  5303.                                     &[::core::fmt::ArgumentV1::new_display(&e)],
  5304.                                 ));
  5305.                                 res
  5306.                             },
  5307.                             severity: Severity::Error,
  5308.                         })
  5309.                     }
  5310.                 },
  5311.                 Value::Float(f) => *f as _,
  5312.                 Value::Int(i) => *i,
  5313.                 _ => {
  5314.                     return Err(Diagnostic {
  5315.                         span: Span {
  5316.                             lo: usize::MAX,
  5317.                             hi: usize::MAX,
  5318.                         },
  5319.                         code: ErrorCode::InvalidType,
  5320.                         message: {
  5321.                             let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5322.                                 &["Expected type `string`, `float` or `int`, found "],
  5323.                                 &[::core::fmt::ArgumentV1::new_display(&n_read.type_())],
  5324.                             ));
  5325.                             res
  5326.                         },
  5327.                         severity: Severity::Error,
  5328.                     })
  5329.                 }
  5330.             };
  5331.             Ok(Some(
  5332.                 interpreter.get_allocator_mut().allocate(Value::Int(res)),
  5333.             ))
  5334.         }
  5335.         fn to_string(&self) -> String {
  5336.             {
  5337.                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5338.                     &["<native function \"input\" at ", ">"],
  5339.                     &[::core::fmt::ArgumentV1::new_pointer(&(self as *const _))],
  5340.                 ));
  5341.                 res
  5342.             }
  5343.         }
  5344.         fn clone(&self) -> Self
  5345.         where
  5346.             Self: Sized,
  5347.         {
  5348.             Clone::clone(self)
  5349.         }
  5350.     }
  5351.     pub struct FloatFunction {}
  5352.     #[automatically_derived]
  5353.     impl ::core::fmt::Debug for FloatFunction {
  5354.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  5355.             ::core::fmt::Formatter::write_str(f, "FloatFunction")
  5356.         }
  5357.     }
  5358.     #[automatically_derived]
  5359.     impl ::core::clone::Clone for FloatFunction {
  5360.         #[inline]
  5361.         fn clone(&self) -> FloatFunction {
  5362.             FloatFunction {}
  5363.         }
  5364.     }
  5365.     impl Callable for FloatFunction {
  5366.         fn arity(&self) -> usize {
  5367.             1
  5368.         }
  5369.         fn call(
  5370.             &self,
  5371.             interpreter: &mut Interpreter,
  5372.             args: Vec<ValueAddr>,
  5373.         ) -> Result<Option<ValueAddr>, Diagnostic> {
  5374.             let n_s = args[0];
  5375.             let n_container = interpreter.get_allocator().get(n_s);
  5376.             let n_read = n_container.read();
  5377.             let res: f64 = match &*n_read {
  5378.                 Value::String(s) => match INTERNER.read().get_interned_string(*s).parse() {
  5379.                     Ok(res) => res,
  5380.                     Err(e) => {
  5381.                         return Err(Diagnostic {
  5382.                             span: Span {
  5383.                                 lo: usize::MAX,
  5384.                                 hi: usize::MAX,
  5385.                             },
  5386.                             code: ErrorCode::InvalidNumber,
  5387.                             message: {
  5388.                                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5389.                                     &["Failed to parse number: "],
  5390.                                     &[::core::fmt::ArgumentV1::new_display(&e)],
  5391.                                 ));
  5392.                                 res
  5393.                             },
  5394.                             severity: Severity::Error,
  5395.                         })
  5396.                     }
  5397.                 },
  5398.                 Value::Float(f) => *f,
  5399.                 Value::Int(i) => *i as _,
  5400.                 _ => {
  5401.                     return Err(Diagnostic {
  5402.                         span: Span {
  5403.                             lo: usize::MAX,
  5404.                             hi: usize::MAX,
  5405.                         },
  5406.                         code: ErrorCode::InvalidType,
  5407.                         message: {
  5408.                             let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5409.                                 &["Expected type `string`, `float` or `int`, found "],
  5410.                                 &[::core::fmt::ArgumentV1::new_display(&n_read.type_())],
  5411.                             ));
  5412.                             res
  5413.                         },
  5414.                         severity: Severity::Error,
  5415.                     })
  5416.                 }
  5417.             };
  5418.             Ok(Some(
  5419.                 interpreter.get_allocator_mut().allocate(Value::Float(res)),
  5420.             ))
  5421.         }
  5422.         fn to_string(&self) -> String {
  5423.             {
  5424.                 let res = alloc::fmt::format(::core::fmt::Arguments::new_v1(
  5425.                     &["<native function \"input\" at ", ">"],
  5426.                     &[::core::fmt::ArgumentV1::new_pointer(&(self as *const _))],
  5427.                 ));
  5428.                 res
  5429.             }
  5430.         }
  5431.         fn clone(&self) -> Self
  5432.         where
  5433.             Self: Sized,
  5434.         {
  5435.             Clone::clone(self)
  5436.         }
  5437.     }
  5438. }
  5439. mod parser {
  5440.     use crate::ast::{
  5441.         AssignmentExpr, BinaryExpr, BinaryOperation, CallExpr, DataExpr, DataStmt, Expr,
  5442.         ExprContainer, FunStmt, GetExpr, IfStmt, IndexExpr, IndexSetExpr, IterStmt, LogicalExpr,
  5443.         LogicalOperation, MethodsStmt, Mutable, NumberExpr, SetExpr, Stmt, StmtContainer,
  5444.         UnaryExpr, UnaryOperation, VarStmt,
  5445.     };
  5446.     use crate::diagnostics::{Diagnostic, ErrorCode, Severity};
  5447.     use crate::lexer::{Lexer, Token, TokenKind};
  5448.     use std::collections::HashMap;
  5449.     pub struct Parser {
  5450.         tokens: Vec<Token>,
  5451.         diagnostics: Vec<Diagnostic>,
  5452.         pos: usize,
  5453.     }
  5454.     #[automatically_derived]
  5455.     impl ::core::fmt::Debug for Parser {
  5456.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  5457.             ::core::fmt::Formatter::debug_struct_field3_finish(
  5458.                 f,
  5459.                 "Parser",
  5460.                 "tokens",
  5461.                 &&self.tokens,
  5462.                 "diagnostics",
  5463.                 &&self.diagnostics,
  5464.                 "pos",
  5465.                 &&self.pos,
  5466.             )
  5467.         }
  5468.     }
  5469.     impl Parser {
  5470.         pub fn new(source: &str) -> Self {
  5471.             let mut lexer = Lexer::new(source);
  5472.             let mut tokens = alloc::vec::Vec::new();
  5473.             let mut lexer_diags = alloc::vec::Vec::new();
  5474.             loop {
  5475.                 let res = lexer.lex_once();
  5476.                 if let Ok(token) = res {
  5477.                     tokens.push(token);
  5478.                     if token.kind == TokenKind::Eof {
  5479.                         break;
  5480.                     }
  5481.                 } else if let Err(e) = res {
  5482.                     lexer_diags.push(e);
  5483.                 }
  5484.             }
  5485.             Self {
  5486.                 tokens,
  5487.                 diagnostics: lexer_diags,
  5488.                 pos: 0,
  5489.             }
  5490.         }
  5491.         fn expect(&mut self, kind: TokenKind) -> Result<Token, Diagnostic> {
  5492.             let token = self.peek();
  5493.             if token.kind == kind {
  5494.                 self.advance();
  5495.                 Ok(token)
  5496.             } else if token.kind == TokenKind::Eof {
  5497.                 Err(Self::error_for_token(
  5498.                     ErrorCode::UnexpectedToken,
  5499.                     "unexpected end of file",
  5500.                     token,
  5501.                 ))
  5502.             } else {
  5503.                 Err(Self::error_for_token(
  5504.                     ErrorCode::UnexpectedToken,
  5505.                     "Unexpected token",
  5506.                     token,
  5507.                 ))
  5508.             }
  5509.         }
  5510.         fn previous(&self) -> Token {
  5511.             self.tokens[self.pos - 1]
  5512.         }
  5513.         fn unless(&mut self, kind: TokenKind) -> Result<bool, Diagnostic> {
  5514.             if self.is_eof() {
  5515.                 Err(Self::error_for_token(
  5516.                     ErrorCode::UnexpectedToken,
  5517.                     "unexpected end of file",
  5518.                     self.peek(),
  5519.                 ))
  5520.             } else if self.peek().kind == kind {
  5521.                 self.advance();
  5522.                 Ok(true)
  5523.             } else {
  5524.                 Ok(false)
  5525.             }
  5526.         }
  5527.         fn advance(&mut self) {
  5528.             self.pos += 1;
  5529.         }
  5530.         fn peek(&self) -> Token {
  5531.             self.tokens[self.pos]
  5532.         }
  5533.         fn is_eof(&self) -> bool {
  5534.             self.peek().kind == TokenKind::Eof
  5535.         }
  5536.         pub fn parse(&mut self) -> Vec<StmtContainer> {
  5537.             let mut stmts = alloc::vec::Vec::new();
  5538.             while !self.is_eof() {
  5539.                 let res = self.declaration();
  5540.                 if let Ok(stmt) = res {
  5541.                     stmts.push(stmt);
  5542.                 } else if let Err(e) = res {
  5543.                     self.diagnostics.push(e);
  5544.                     self.synchronize();
  5545.                 }
  5546.             }
  5547.             stmts
  5548.         }
  5549.         fn synchronize(&mut self) {
  5550.             if self.is_eof() {
  5551.                 return;
  5552.             }
  5553.             self.advance();
  5554.             loop {
  5555.                 match self.previous().kind {
  5556.                     TokenKind::Semicolon
  5557.                     | TokenKind::LeftBrace
  5558.                     | TokenKind::RightBrace
  5559.                     | TokenKind::If
  5560.                     | TokenKind::Const
  5561.                     | TokenKind::Mut
  5562.                     | TokenKind::Loop
  5563.                     | TokenKind::Iter
  5564.                     | TokenKind::Fun
  5565.                     | TokenKind::Data
  5566.                     | TokenKind::Continue
  5567.                     | TokenKind::Break
  5568.                     | TokenKind::Ret
  5569.                     | TokenKind::Methods
  5570.                     | TokenKind::Eof => break,
  5571.                     _ => (),
  5572.                 }
  5573.                 self.advance();
  5574.             }
  5575.         }
  5576.         fn declaration(&mut self) -> Result<StmtContainer, Diagnostic> {
  5577.             match self.peek().kind {
  5578.                 TokenKind::Const => self.var_declaration(Mutable::No),
  5579.                 TokenKind::Mut => self.var_declaration(Mutable::Yes),
  5580.                 TokenKind::Fun => self.fun_stmt(false),
  5581.                 TokenKind::Data => self.data_stmt(),
  5582.                 TokenKind::Methods => self.methods_stmt(),
  5583.                 _ => {
  5584.                     let token = self.peek();
  5585.                     self.advance();
  5586.                     Err(Self::error_for_token(
  5587.                         ErrorCode::UnexpectedToken,
  5588.                         "unexpected token",
  5589.                         token,
  5590.                     ))
  5591.                 }
  5592.             }
  5593.         }
  5594.         fn data_stmt(&mut self) -> Result<StmtContainer, Diagnostic> {
  5595.             let start_span = self.peek().span;
  5596.             self.advance();
  5597.             let name = self.expect(TokenKind::Identifier)?.value.get_string();
  5598.             let mut fields = alloc::vec::Vec::new();
  5599.             self.expect(TokenKind::LeftBrace)?;
  5600.             let mut is_first_property = true;
  5601.             while !self.unless(TokenKind::RightBrace)? {
  5602.                 if !is_first_property {
  5603.                     self.expect(TokenKind::Comma)?;
  5604.                 } else {
  5605.                     is_first_property = false;
  5606.                 }
  5607.                 fields.push(self.expect(TokenKind::Identifier)?.value.get_string());
  5608.             }
  5609.             Ok(Stmt::Data(Box::new(DataStmt { name, fields }))
  5610.                 .into_container(start_span.merge(self.previous().span)))
  5611.         }
  5612.         fn methods_stmt(&mut self) -> Result<StmtContainer, Diagnostic> {
  5613.             let start_span = self.peek().span;
  5614.             self.advance();
  5615.             let data = self.expect(TokenKind::Identifier)?.value.get_string();
  5616.             let mut methods = alloc::vec::Vec::new();
  5617.             self.expect(TokenKind::LeftBrace)?;
  5618.             while !self.unless(TokenKind::RightBrace)? {
  5619.                 methods.push(self.fun_stmt(true)?);
  5620.             }
  5621.             Ok(Stmt::Methods(Box::new(MethodsStmt { methods, data }))
  5622.                 .into_container(start_span.merge(self.previous().span)))
  5623.         }
  5624.         fn var_declaration(&mut self, mutable: Mutable) -> Result<StmtContainer, Diagnostic> {
  5625.             let span_start = self.peek().span;
  5626.             self.advance();
  5627.             let name = self.expect(TokenKind::Identifier)?.value.get_string();
  5628.             self.expect(TokenKind::Equal)?;
  5629.             let value = self.expr()?;
  5630.             self.expect(TokenKind::Semicolon)?;
  5631.             Ok(Stmt::Var(Box::new(VarStmt {
  5632.                 name,
  5633.                 value,
  5634.                 mutable,
  5635.             }))
  5636.             .into_container(span_start.merge(self.previous().span)))
  5637.         }
  5638.         fn fun_stmt(&mut self, is_method: bool) -> Result<StmtContainer, Diagnostic> {
  5639.             let start_span = self.peek().span;
  5640.             self.advance();
  5641.             let name = self.expect(TokenKind::Identifier)?.value.get_string();
  5642.             self.expect(TokenKind::LeftParen)?;
  5643.             let mut arguments = alloc::vec::Vec::new();
  5644.             let mut is_first_arg = true;
  5645.             loop {
  5646.                 if match self.peek().kind {
  5647.                     TokenKind::RightParen => true,
  5648.                     _ => false,
  5649.                 } {
  5650.                     break;
  5651.                 }
  5652.                 if !is_first_arg {
  5653.                     self.expect(TokenKind::Comma)?;
  5654.                 } else {
  5655.                     is_first_arg = false;
  5656.                 }
  5657.                 let current_token = self.peek();
  5658.                 if current_token.kind == TokenKind::Identifier {
  5659.                     self.advance();
  5660.                     arguments.push(current_token.value.get_string());
  5661.                 } else {
  5662.                     self.advance();
  5663.                     break;
  5664.                 }
  5665.             }
  5666.             self.expect(TokenKind::RightParen)?;
  5667.             let body = self.block_stmt()?;
  5668.             Ok(Stmt::Fun(Box::new(FunStmt {
  5669.                 name,
  5670.                 arguments,
  5671.                 body,
  5672.                 is_method,
  5673.             }))
  5674.             .into_container(start_span.merge(self.peek().span)))
  5675.         }
  5676.         fn ret_stmt(&mut self) -> Result<StmtContainer, Diagnostic> {
  5677.             let start_span = self.peek().span;
  5678.             self.advance();
  5679.             let expr = self.expr()?;
  5680.             self.expect(TokenKind::Semicolon)?;
  5681.             Ok(Stmt::Ret(expr).into_container(start_span.merge(self.previous().span)))
  5682.         }
  5683.         fn iter_stmt(&mut self) -> Result<StmtContainer, Diagnostic> {
  5684.             let start_span = self.peek().span;
  5685.             self.advance();
  5686.             let iterable = self.expr()?;
  5687.             self.expect(TokenKind::Colon)?;
  5688.             let binding = self.expect(TokenKind::Identifier)?.value.get_string();
  5689.             let block = self.block_stmt()?;
  5690.             Ok(Stmt::Iter(Box::new(IterStmt {
  5691.                 iterable,
  5692.                 binding,
  5693.                 block,
  5694.             }))
  5695.             .into_container(start_span.merge(self.previous().span)))
  5696.         }
  5697.         fn if_stmt(&mut self) -> Result<StmtContainer, Diagnostic> {
  5698.             let start_span = self.peek().span;
  5699.             self.advance();
  5700.             self.expect(TokenKind::LeftParen)?;
  5701.             let condition = self.expr()?;
  5702.             self.expect(TokenKind::RightParen)?;
  5703.             let block = self.block_stmt()?;
  5704.             let else_;
  5705.             let mut then = None;
  5706.             if self.peek().kind == TokenKind::Else {
  5707.                 self.advance();
  5708.                 if self.peek().kind == TokenKind::If {
  5709.                     else_ = Some(self.if_stmt()?);
  5710.                 } else {
  5711.                     else_ = None;
  5712.                     then = Some(self.block_stmt()?);
  5713.                 }
  5714.             } else {
  5715.                 else_ = None;
  5716.             }
  5717.             Ok(Stmt::If(Box::new(IfStmt {
  5718.                 condition,
  5719.                 block,
  5720.                 else_,
  5721.                 then,
  5722.             }))
  5723.             .into_container(start_span.merge(self.previous().span)))
  5724.         }
  5725.         fn block_stmt(&mut self) -> Result<StmtContainer, Diagnostic> {
  5726.             let start_span = self.peek().span;
  5727.             let mut stmts = alloc::vec::Vec::new();
  5728.             self.expect(TokenKind::LeftBrace)?;
  5729.             while !self.unless(TokenKind::RightBrace)? {
  5730.                 let res = match self.peek().kind {
  5731.                     TokenKind::Const => self.var_declaration(Mutable::No),
  5732.                     TokenKind::Mut => self.var_declaration(Mutable::Yes),
  5733.                     TokenKind::LeftBrace => self.block_stmt(),
  5734.                     TokenKind::Ret => self.ret_stmt(),
  5735.                     TokenKind::Continue => {
  5736.                         let span = self.peek().span;
  5737.                         self.advance();
  5738.                         self.expect(TokenKind::Semicolon)?;
  5739.                         Ok(Stmt::Continue.into_container(span.merge(self.previous().span)))
  5740.                     }
  5741.                     TokenKind::Break => {
  5742.                         let span = self.peek().span;
  5743.                         self.advance();
  5744.                         self.expect(TokenKind::Semicolon)?;
  5745.                         Ok(Stmt::Break.into_container(span.merge(self.previous().span)))
  5746.                     }
  5747.                     TokenKind::Loop => {
  5748.                         let span = self.peek().span;
  5749.                         self.advance();
  5750.                         let block = self.block_stmt()?;
  5751.                         Ok(Stmt::Loop(Box::new(block))
  5752.                             .into_container(span.merge(self.previous().span)))
  5753.                     }
  5754.                     TokenKind::Iter => self.iter_stmt(),
  5755.                     TokenKind::If => self.if_stmt(),
  5756.                     _ => {
  5757.                         let expr = self.expr()?;
  5758.                         let span = expr.span;
  5759.                         self.expect(TokenKind::Semicolon)?;
  5760.                         Ok(Stmt::Expr(expr).into_container(span))
  5761.                     }
  5762.                 };
  5763.                 if let Ok(res) = res {
  5764.                     stmts.push(res);
  5765.                 } else if let Err(e) = res {
  5766.                     self.diagnostics.push(e);
  5767.                     self.synchronize();
  5768.                 }
  5769.             }
  5770.             Ok(Stmt::Block(stmts).into_container(start_span.merge(self.previous().span)))
  5771.         }
  5772.         fn expr(&mut self) -> Result<ExprContainer, Diagnostic> {
  5773.             self.assignment()
  5774.         }
  5775.         fn assignment(&mut self) -> Result<ExprContainer, Diagnostic> {
  5776.             let mut data_member = false;
  5777.             let start_span = self.peek().span;
  5778.             if self.peek().kind == TokenKind::At {
  5779.                 data_member = true;
  5780.                 self.advance();
  5781.             }
  5782.             let expr = self.logical_or()?;
  5783.             match self.peek().kind {
  5784.                 TokenKind::DoubleLeftAngleEq
  5785.                 | TokenKind::DoubleRightAngleEq
  5786.                 | TokenKind::PlusEq
  5787.                 | TokenKind::MinusEq
  5788.                 | TokenKind::AsteriskEq
  5789.                 | TokenKind::SlashEq
  5790.                 | TokenKind::PercentEq
  5791.                 | TokenKind::AmpersandEq
  5792.                 | TokenKind::PipeEq
  5793.                 | TokenKind::CaretEq => {
  5794.                     let op = match self.peek().kind {
  5795.                         TokenKind::DoubleLeftAngleEq => BinaryOperation::LeftShift,
  5796.                         TokenKind::DoubleRightAngleEq => BinaryOperation::RightShift,
  5797.                         TokenKind::PlusEq => BinaryOperation::Plus,
  5798.                         TokenKind::MinusEq => BinaryOperation::Minus,
  5799.                         TokenKind::AsteriskEq => BinaryOperation::Multiply,
  5800.                         TokenKind::SlashEq => BinaryOperation::Divide,
  5801.                         TokenKind::PercentEq => BinaryOperation::Modulus,
  5802.                         TokenKind::AmpersandEq => BinaryOperation::And,
  5803.                         TokenKind::PipeEq => BinaryOperation::Or,
  5804.                         TokenKind::CaretEq => BinaryOperation::Xor,
  5805.                         _ => ::core::panicking::panic("internal error: entered unreachable code"),
  5806.                     };
  5807.                     let eq_token = self.peek();
  5808.                     self.advance();
  5809.                     let rhs = self.expr()?;
  5810.                     return match &expr.expr {
  5811.                         Expr::Get(get_expr) => Ok(Expr::Set(Box::new(SetExpr {
  5812.                             property: get_expr.property,
  5813.                             object: expr.clone(),
  5814.                             value: Expr::Binary(Box::new(BinaryExpr {
  5815.                                 lhs: expr.clone(),
  5816.                                 op,
  5817.                                 rhs,
  5818.                             }))
  5819.                             .into_container(start_span.merge(self.peek().span)),
  5820.                         }))
  5821.                         .into_container(start_span.merge(self.peek().span))),
  5822.                         Expr::Index(_) => Ok(Expr::IndexSet(Box::new(IndexSetExpr {
  5823.                             object: expr.clone(),
  5824.                             value: Expr::Binary(Box::new(BinaryExpr {
  5825.                                 lhs: expr.clone(),
  5826.                                 op,
  5827.                                 rhs,
  5828.                             }))
  5829.                             .into_container(start_span.merge(self.peek().span)),
  5830.                         }))
  5831.                         .into_container(start_span.merge(self.peek().span))),
  5832.                         Expr::Variable(_) => Ok(Expr::Assignment(Box::new(AssignmentExpr {
  5833.                             lvalue: expr.clone(),
  5834.                             data_member,
  5835.                             rvalue: Expr::Binary(Box::new(BinaryExpr {
  5836.                                 lhs: expr.clone(),
  5837.                                 op,
  5838.                                 rhs,
  5839.                             }))
  5840.                             .into_container(start_span.merge(self.peek().span)),
  5841.                         }))
  5842.                         .into_container(start_span.merge(self.peek().span))),
  5843.                         _ => Err(Self::error_for_token(
  5844.                             ErrorCode::InvalidAssignment,
  5845.                             "invalid assignment target",
  5846.                             eq_token,
  5847.                         )),
  5848.                     };
  5849.                 }
  5850.                 _ => (),
  5851.             }
  5852.             if self.peek().kind == TokenKind::Equal {
  5853.                 let eq_token = self.peek();
  5854.                 self.advance();
  5855.                 let rhs = self.expr()?;
  5856.                 return match &expr.expr {
  5857.                     Expr::Get(get_expr) => {
  5858.                         let expr = get_expr.clone();
  5859.                         Ok(Expr::Set(Box::new(SetExpr {
  5860.                             property: expr.property,
  5861.                             object: expr.object,
  5862.                             value: rhs,
  5863.                         }))
  5864.                         .into_container(start_span.merge(self.peek().span)))
  5865.                     }
  5866.                     Expr::Index(_) => Ok(Expr::IndexSet(Box::new(IndexSetExpr {
  5867.                         object: expr,
  5868.                         value: rhs,
  5869.                     }))
  5870.                     .into_container(start_span.merge(self.peek().span))),
  5871.                     Expr::Variable(_name) => Ok(Expr::Assignment(Box::new(AssignmentExpr {
  5872.                         data_member,
  5873.                         lvalue: expr,
  5874.                         rvalue: rhs,
  5875.                     }))
  5876.                     .into_container(start_span.merge(self.peek().span))),
  5877.                     _ => Err(Self::error_for_token(
  5878.                         ErrorCode::InvalidAssignment,
  5879.                         "invalid assignment target",
  5880.                         eq_token,
  5881.                     )),
  5882.                 };
  5883.             }
  5884.             Ok(expr)
  5885.         }
  5886.         fn logical_or(&mut self) -> Result<ExprContainer, Diagnostic> {
  5887.             let start_span = self.peek().span;
  5888.             let mut expr = self.logical_and()?;
  5889.             let mut op;
  5890.             loop {
  5891.                 op = LogicalOperation::try_from(self.peek().kind);
  5892.                 if let Ok(op) = op {
  5893.                     if op == LogicalOperation::Or {
  5894.                         self.advance();
  5895.                         let rhs = self.logical_and()?;
  5896.                         expr = Expr::Logical(Box::new(LogicalExpr { lhs: expr, op, rhs }))
  5897.                             .into_container(start_span.merge(self.peek().span));
  5898.                     } else {
  5899.                         break;
  5900.                     }
  5901.                 } else {
  5902.                     break;
  5903.                 }
  5904.             }
  5905.             Ok(expr)
  5906.         }
  5907.         fn logical_and(&mut self) -> Result<ExprContainer, Diagnostic> {
  5908.             let start_span = self.peek().span;
  5909.             let mut expr = self.equality()?;
  5910.             let mut op;
  5911.             loop {
  5912.                 op = LogicalOperation::try_from(self.peek().kind);
  5913.                 if let Ok(op) = op {
  5914.                     if op == LogicalOperation::And {
  5915.                         self.advance();
  5916.                         let rhs = self.equality()?;
  5917.                         expr = Expr::Logical(Box::new(LogicalExpr { lhs: expr, op, rhs }))
  5918.                             .into_container(start_span.merge(self.peek().span));
  5919.                     } else {
  5920.                         break;
  5921.                     }
  5922.                 } else {
  5923.                     break;
  5924.                 }
  5925.             }
  5926.             Ok(expr)
  5927.         }
  5928.         fn equality(&mut self) -> Result<ExprContainer, Diagnostic> {
  5929.             let start_span = self.peek().span;
  5930.             let mut expr = self.comparison()?;
  5931.             let mut op;
  5932.             loop {
  5933.                 op = LogicalOperation::try_from(self.peek().kind);
  5934.                 if let Ok(op) = op {
  5935.                     if op == LogicalOperation::Equals || op == LogicalOperation::NotEquals {
  5936.                         self.advance();
  5937.                         let rhs = self.comparison()?;
  5938.                         expr = Expr::Logical(Box::new(LogicalExpr { lhs: expr, op, rhs }))
  5939.                             .into_container(start_span.merge(self.peek().span));
  5940.                     } else {
  5941.                         break;
  5942.                     }
  5943.                 } else {
  5944.                     break;
  5945.                 }
  5946.             }
  5947.             Ok(expr)
  5948.         }
  5949.         fn comparison(&mut self) -> Result<ExprContainer, Diagnostic> {
  5950.             let start_span = self.peek().span;
  5951.             let mut expr = self.bitwise_or()?;
  5952.             let mut op;
  5953.             loop {
  5954.                 op = LogicalOperation::try_from(self.peek().kind);
  5955.                 if let Ok(op) = op {
  5956.                     if op == LogicalOperation::LessThan
  5957.                         || op == LogicalOperation::LessThanOrEquals
  5958.                         || op == LogicalOperation::GreaterThan
  5959.                         || op == LogicalOperation::GreaterThanOrEquals
  5960.                     {
  5961.                         self.advance();
  5962.                         let rhs = self.bitwise_or()?;
  5963.                         expr = Expr::Logical(Box::new(LogicalExpr { lhs: expr, op, rhs }))
  5964.                             .into_container(start_span.merge(self.peek().span));
  5965.                     } else {
  5966.                         break;
  5967.                     }
  5968.                 } else {
  5969.                     break;
  5970.                 }
  5971.             }
  5972.             Ok(expr)
  5973.         }
  5974.         fn bitwise_or(&mut self) -> Result<ExprContainer, Diagnostic> {
  5975.             let start_span = self.peek().span;
  5976.             let mut expr = self.bitwise_xor()?;
  5977.             let mut op;
  5978.             loop {
  5979.                 op = BinaryOperation::try_from(self.peek().kind);
  5980.                 if let Ok(op) = op {
  5981.                     if op == BinaryOperation::Or {
  5982.                         self.advance();
  5983.                         let rhs = self.bitwise_xor()?;
  5984.                         expr = Expr::Binary(Box::new(BinaryExpr { lhs: expr, op, rhs }))
  5985.                             .into_container(start_span.merge(self.peek().span));
  5986.                     } else {
  5987.                         break;
  5988.                     }
  5989.                 } else {
  5990.                     break;
  5991.                 }
  5992.             }
  5993.             Ok(expr)
  5994.         }
  5995.         fn bitwise_xor(&mut self) -> Result<ExprContainer, Diagnostic> {
  5996.             let start_span = self.peek().span;
  5997.             let mut expr = self.bitwise_and()?;
  5998.             let mut op;
  5999.             loop {
  6000.                 op = BinaryOperation::try_from(self.peek().kind);
  6001.                 if let Ok(op) = op {
  6002.                     if op == BinaryOperation::Xor {
  6003.                         self.advance();
  6004.                         let rhs = self.bitwise_and()?;
  6005.                         expr = Expr::Binary(Box::new(BinaryExpr { lhs: expr, op, rhs }))
  6006.                             .into_container(start_span.merge(self.peek().span));
  6007.                     } else {
  6008.                         break;
  6009.                     }
  6010.                 } else {
  6011.                     break;
  6012.                 }
  6013.             }
  6014.             Ok(expr)
  6015.         }
  6016.         fn bitwise_and(&mut self) -> Result<ExprContainer, Diagnostic> {
  6017.             let start_span = self.peek().span;
  6018.             let mut expr = self.bitwise_shift()?;
  6019.             let mut op;
  6020.             loop {
  6021.                 op = BinaryOperation::try_from(self.peek().kind);
  6022.                 if let Ok(op) = op {
  6023.                     if op == BinaryOperation::And {
  6024.                         self.advance();
  6025.                         let rhs = self.bitwise_shift()?;
  6026.                         expr = Expr::Binary(Box::new(BinaryExpr { lhs: expr, op, rhs }))
  6027.                             .into_container(start_span.merge(self.peek().span));
  6028.                     } else {
  6029.                         break;
  6030.                     }
  6031.                 } else {
  6032.                     break;
  6033.                 }
  6034.             }
  6035.             Ok(expr)
  6036.         }
  6037.         fn bitwise_shift(&mut self) -> Result<ExprContainer, Diagnostic> {
  6038.             let start_span = self.peek().span;
  6039.             let mut expr = self.term()?;
  6040.             let mut op;
  6041.             loop {
  6042.                 op = BinaryOperation::try_from(self.peek().kind);
  6043.                 if let Ok(op) = op {
  6044.                     if op == BinaryOperation::LeftShift || op == BinaryOperation::RightShift {
  6045.                         self.advance();
  6046.                         let rhs = self.term()?;
  6047.                         expr = Expr::Binary(Box::new(BinaryExpr { lhs: expr, op, rhs }))
  6048.                             .into_container(start_span.merge(self.peek().span));
  6049.                     } else {
  6050.                         break;
  6051.                     }
  6052.                 } else {
  6053.                     break;
  6054.                 }
  6055.             }
  6056.             Ok(expr)
  6057.         }
  6058.         fn term(&mut self) -> Result<ExprContainer, Diagnostic> {
  6059.             let start_span = self.peek().span;
  6060.             let mut expr = self.factor()?;
  6061.             let mut op;
  6062.             loop {
  6063.                 op = BinaryOperation::try_from(self.peek().kind);
  6064.                 if let Ok(op) = op {
  6065.                     if op == BinaryOperation::Plus || op == BinaryOperation::Minus {
  6066.                         self.advance();
  6067.                         let rhs = self.factor()?;
  6068.                         expr = Expr::Binary(Box::new(BinaryExpr { lhs: expr, op, rhs }))
  6069.                             .into_container(start_span.merge(self.peek().span));
  6070.                     } else {
  6071.                         break;
  6072.                     }
  6073.                 } else {
  6074.                     break;
  6075.                 }
  6076.             }
  6077.             Ok(expr)
  6078.         }
  6079.         fn factor(&mut self) -> Result<ExprContainer, Diagnostic> {
  6080.             let start_span = self.peek().span;
  6081.             let mut expr = self.unary()?;
  6082.             let mut op;
  6083.             loop {
  6084.                 op = BinaryOperation::try_from(self.peek().kind);
  6085.                 if let Ok(op) = op {
  6086.                     if op == BinaryOperation::Multiply || op == BinaryOperation::Divide {
  6087.                         self.advance();
  6088.                         let rhs = self.unary()?;
  6089.                         expr = Expr::Binary(Box::new(BinaryExpr { lhs: expr, op, rhs }))
  6090.                             .into_container(start_span.merge(self.peek().span));
  6091.                     } else {
  6092.                         break;
  6093.                     }
  6094.                 } else {
  6095.                     break;
  6096.                 }
  6097.             }
  6098.             Ok(expr)
  6099.         }
  6100.         fn unary(&mut self) -> Result<ExprContainer, Diagnostic> {
  6101.             let op = match UnaryOperation::try_from(self.peek().kind) {
  6102.                 Ok(op) => op,
  6103.                 Err(_) => return self.callexpr(),
  6104.             };
  6105.             let start_span = self.peek().span;
  6106.             self.advance();
  6107.             Ok(Expr::Unary(Box::new(UnaryExpr {
  6108.                 expr: self.unary()?,
  6109.                 op,
  6110.             }))
  6111.             .into_container(start_span.merge(self.peek().span)))
  6112.         }
  6113.         fn callexpr(&mut self) -> Result<ExprContainer, Diagnostic> {
  6114.             let start_span = self.peek().span;
  6115.             let mut expr = self.primary()?;
  6116.             loop {
  6117.                 if self.peek().kind == TokenKind::LeftParen {
  6118.                     self.advance();
  6119.                     let args = self.arguments()?;
  6120.                     self.expect(TokenKind::RightParen)?;
  6121.                     expr = Expr::Call(Box::new(CallExpr { callee: expr, args }))
  6122.                         .into_container(start_span.merge(self.peek().span));
  6123.                 } else if self.peek().kind == TokenKind::Dot {
  6124.                     self.advance();
  6125.                     let name = self.expect(TokenKind::Identifier)?;
  6126.                     expr = Expr::Get(Box::new(GetExpr {
  6127.                         property: name.value.get_string(),
  6128.                         object: expr,
  6129.                     }))
  6130.                     .into_container(start_span.merge(self.peek().span));
  6131.                 } else {
  6132.                     break;
  6133.                 }
  6134.             }
  6135.             Ok(expr)
  6136.         }
  6137.         fn arguments(&mut self) -> Result<Vec<ExprContainer>, Diagnostic> {
  6138.             let mut args = alloc::vec::Vec::new();
  6139.             if self.peek().kind == TokenKind::RightParen {
  6140.                 return Ok(args);
  6141.             }
  6142.             args.push(self.expr()?);
  6143.             loop {
  6144.                 if self.peek().kind != TokenKind::Comma {
  6145.                     break;
  6146.                 }
  6147.                 self.advance();
  6148.                 args.push(self.expr()?);
  6149.             }
  6150.             Ok(args)
  6151.         }
  6152.         fn primary(&mut self) -> Result<ExprContainer, Diagnostic> {
  6153.             let current_token = self.peek();
  6154.             self.advance();
  6155.             match current_token.kind {
  6156.                 TokenKind::True => Ok(Expr::Boolean(true).into_container(current_token.span)),
  6157.                 TokenKind::False => Ok(Expr::Boolean(false).into_container(current_token.span)),
  6158.                 TokenKind::None => Ok(Expr::None.into_container(current_token.span)),
  6159.                 TokenKind::Identifier => {
  6160.                     let start_span = self.peek().span;
  6161.                     let mut expr = Expr::Variable(current_token.value.get_string())
  6162.                         .into_container(current_token.span);
  6163.                     if self.peek().kind == TokenKind::LeftBracket {
  6164.                         self.advance();
  6165.                         let index = self.expr()?;
  6166.                         self.expect(TokenKind::RightBracket)?;
  6167.                         expr = Expr::Index(Box::new(IndexExpr {
  6168.                             object: expr,
  6169.                             index,
  6170.                         }))
  6171.                         .into_container(start_span.merge(self.previous().span));
  6172.                     } else if self.peek().kind == TokenKind::LeftBrace {
  6173.                         self.advance();
  6174.                         let name = match expr.expr {
  6175.                             Expr::Variable(n) => n,
  6176.                             _ => {
  6177.                                 ::core::panicking::panic("internal error: entered unreachable code")
  6178.                             }
  6179.                         };
  6180.                         let mut props = HashMap::new();
  6181.                         let mut is_first_prop = true;
  6182.                         let mut err = None;
  6183.                         while !self.unless(TokenKind::RightBrace)? {
  6184.                             if !is_first_prop {
  6185.                                 self.expect(TokenKind::Comma)?;
  6186.                             } else {
  6187.                                 is_first_prop = false;
  6188.                             }
  6189.                             let prop_span = self.peek().span;
  6190.                             let prop = self.expect(TokenKind::Identifier)?.value.get_string();
  6191.                             self.expect(TokenKind::Colon)?;
  6192.                             let value = self.expr()?;
  6193.                             let sp = prop_span.merge(value.span);
  6194.                             if let Some(_) = props.insert(prop, value) {
  6195.                                 err = Some(Diagnostic {
  6196.                                     code: ErrorCode::InvalidDataPropertySet,
  6197.                                     severity: Severity::Error,
  6198.                                     message: String::from(
  6199.                                         "Attempt to set same property more than once",
  6200.                                     ),
  6201.                                     span: sp,
  6202.                                 })
  6203.                             }
  6204.                         }
  6205.                         if let Some(e) = err {
  6206.                             return Err(e);
  6207.                         }
  6208.                         expr = Expr::Data(Box::new(DataExpr { name, props }))
  6209.                             .into_container(start_span.merge(self.previous().span));
  6210.                     }
  6211.                     Ok(expr)
  6212.                 }
  6213.                 TokenKind::String => Ok(Expr::String(current_token.value.get_string())
  6214.                     .into_container(current_token.span)),
  6215.                 TokenKind::Number => {
  6216.                     let (value, kind) = current_token.value.get_number();
  6217.                     Ok(Expr::Number(NumberExpr { kind, value }).into_container(current_token.span))
  6218.                 }
  6219.                 TokenKind::LeftParen => {
  6220.                     let expr = self.expr()?;
  6221.                     self.expect(TokenKind::RightParen)?;
  6222.                     Ok(Expr::Grouping(Box::new(expr)).into_container(current_token.span))
  6223.                 }
  6224.                 TokenKind::LeftBracket => {
  6225.                     let mut exprs = alloc::vec::Vec::new();
  6226.                     let mut is_first_item = true;
  6227.                     while !self.unless(TokenKind::RightBracket)? {
  6228.                         if !is_first_item {
  6229.                             self.expect(TokenKind::Comma)?;
  6230.                         } else {
  6231.                             is_first_item = false;
  6232.                         }
  6233.                         exprs.push(self.expr()?);
  6234.                     }
  6235.                     Ok(Expr::Array(exprs).into_container(current_token.span))
  6236.                 }
  6237.                 _ => Err(Self::error_for_token(
  6238.                     ErrorCode::UnexpectedToken,
  6239.                     "expected primary expression",
  6240.                     current_token,
  6241.                 )),
  6242.             }
  6243.         }
  6244.         fn error_for_token(code: ErrorCode, message: &str, token: Token) -> Diagnostic {
  6245.             Diagnostic {
  6246.                 severity: Severity::Error,
  6247.                 code,
  6248.                 message: message.to_string(),
  6249.                 span: token.span,
  6250.             }
  6251.         }
  6252.         pub fn get_diagnostics(self) -> Vec<Diagnostic> {
  6253.             self.diagnostics
  6254.         }
  6255.     }
  6256. }
  6257. mod session {
  6258.     use crate::diagnostics::{Diagnostic, Severity};
  6259.     use crate::interner::{InternedString, INTERNER};
  6260.     use crate::analyzer::Analyzer;
  6261.     use crate::ast::StmtContainer;
  6262.     use crate::parser::Parser;
  6263.     use std::collections::HashMap;
  6264.     pub struct Session {
  6265.         pub entry_point: InternedString,
  6266.         pub debug: bool,
  6267.         pub files: HashMap<InternedString, String>,
  6268.         asts: HashMap<InternedString, Vec<StmtContainer>>,
  6269.         diagnostics: HashMap<InternedString, Vec<Diagnostic>>,
  6270.     }
  6271.     #[automatically_derived]
  6272.     impl ::core::fmt::Debug for Session {
  6273.         fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
  6274.             ::core::fmt::Formatter::debug_struct_field5_finish(
  6275.                 f,
  6276.                 "Session",
  6277.                 "entry_point",
  6278.                 &&self.entry_point,
  6279.                 "debug",
  6280.                 &&self.debug,
  6281.                 "files",
  6282.                 &&self.files,
  6283.                 "asts",
  6284.                 &&self.asts,
  6285.                 "diagnostics",
  6286.                 &&self.diagnostics,
  6287.             )
  6288.         }
  6289.     }
  6290.     impl Session {
  6291.         pub fn from_file(filename: String, file: String, debug: bool) -> Self {
  6292.             let filename = INTERNER.write().intern_string(filename);
  6293.             let mut files = HashMap::new();
  6294.             files.insert(filename, file);
  6295.             Self {
  6296.                 entry_point: filename,
  6297.                 files,
  6298.                 diagnostics: HashMap::new(),
  6299.                 asts: HashMap::new(),
  6300.                 debug,
  6301.             }
  6302.         }
  6303.         pub fn parse(&mut self, file: InternedString) {
  6304.             let file_content = &self.files[&file];
  6305.             let mut parser = Parser::new(file_content);
  6306.             let stmts = parser.parse();
  6307.             self.diagnostics.insert(file, parser.get_diagnostics());
  6308.             let analyzer = Analyzer::new(&stmts);
  6309.             analyzer.analyze();
  6310.             self.diagnostics
  6311.                 .get_mut(&file)
  6312.                 .unwrap()
  6313.                 .extend(analyzer.get_diagnostics());
  6314.             if self.debug {
  6315.                 match &stmts {
  6316.                     tmp => {
  6317.                         {
  6318.                             ::std::io::_eprint(::core::fmt::Arguments::new_v1_formatted(
  6319.                                 &["[", ":", "] ", " = ", "\n"],
  6320.                                 &match (&"src/session.rs", &48u32, &"&stmts", &&tmp) {
  6321.                                     args => [
  6322.                                         ::core::fmt::ArgumentV1::new_display(args.0),
  6323.                                         ::core::fmt::ArgumentV1::new_display(args.1),
  6324.                                         ::core::fmt::ArgumentV1::new_display(args.2),
  6325.                                         ::core::fmt::ArgumentV1::new_debug(args.3),
  6326.                                     ],
  6327.                                 },
  6328.                                 &[
  6329.                                     ::core::fmt::rt::v1::Argument {
  6330.                                         position: 0usize,
  6331.                                         format: ::core::fmt::rt::v1::FormatSpec {
  6332.                                             fill: ' ',
  6333.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  6334.                                             flags: 0u32,
  6335.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  6336.                                             width: ::core::fmt::rt::v1::Count::Implied,
  6337.                                         },
  6338.                                     },
  6339.                                     ::core::fmt::rt::v1::Argument {
  6340.                                         position: 1usize,
  6341.                                         format: ::core::fmt::rt::v1::FormatSpec {
  6342.                                             fill: ' ',
  6343.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  6344.                                             flags: 0u32,
  6345.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  6346.                                             width: ::core::fmt::rt::v1::Count::Implied,
  6347.                                         },
  6348.                                     },
  6349.                                     ::core::fmt::rt::v1::Argument {
  6350.                                         position: 2usize,
  6351.                                         format: ::core::fmt::rt::v1::FormatSpec {
  6352.                                             fill: ' ',
  6353.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  6354.                                             flags: 0u32,
  6355.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  6356.                                             width: ::core::fmt::rt::v1::Count::Implied,
  6357.                                         },
  6358.                                     },
  6359.                                     ::core::fmt::rt::v1::Argument {
  6360.                                         position: 3usize,
  6361.                                         format: ::core::fmt::rt::v1::FormatSpec {
  6362.                                             fill: ' ',
  6363.                                             align: ::core::fmt::rt::v1::Alignment::Unknown,
  6364.                                             flags: 4u32,
  6365.                                             precision: ::core::fmt::rt::v1::Count::Implied,
  6366.                                             width: ::core::fmt::rt::v1::Count::Implied,
  6367.                                         },
  6368.                                     },
  6369.                                 ],
  6370.                                 unsafe { ::core::fmt::UnsafeArg::new() },
  6371.                             ));
  6372.                         };
  6373.                         tmp
  6374.                     }
  6375.                 };
  6376.             }
  6377.             self.asts.insert(file, stmts);
  6378.         }
  6379.         pub fn parse_entrypoint(&mut self) {
  6380.             self.parse(self.entry_point);
  6381.         }
  6382.         pub fn has_diagnostics(&self) -> bool {
  6383.             for (_, diags) in &self.diagnostics {
  6384.                 for diag in diags {
  6385.                     if diag.severity == Severity::Error {
  6386.                         return true;
  6387.                     }
  6388.                 }
  6389.             }
  6390.             false
  6391.         }
  6392.         pub fn print_diagnostics(&self) {
  6393.             for (filename, diagnostics) in &self.diagnostics {
  6394.                 for diagnostic in diagnostics {
  6395.                     {
  6396.                         ::std::io::_eprint(::core::fmt::Arguments::new_v1(
  6397.                             &["", "\n"],
  6398.                             &[::core::fmt::ArgumentV1::new_display(&diagnostic.display(
  6399.                                 INTERNER.read().get_interned_string(*filename),
  6400.                                 self.files.get(filename).unwrap(),
  6401.                             ))],
  6402.                         ));
  6403.                     };
  6404.                 }
  6405.             }
  6406.         }
  6407.         pub fn get_ast(&self, file_name: InternedString) -> &[StmtContainer] {
  6408.             &self.asts[&file_name]
  6409.         }
  6410.     }
  6411. }
  6412. fn main() {
  6413.     let args = std::env::args().collect::<Vec<String>>();
  6414.     let file_name = &args[1];
  6415.     let file_content = std::fs::read_to_string(file_name).unwrap();
  6416.     let mut session = Session::from_file(
  6417.         file_name.clone(),
  6418.         file_content,
  6419.         args.contains(&String::from("--debug")),
  6420.     );
  6421.     let mut interpreter = Interpreter::new(&mut session);
  6422.     if interpreter.init() {
  6423.         interpreter.interpret();
  6424.     }
  6425. }
  6426.  
Add Comment
Please, Sign In to add comment