Skip to main content

nanvm_lib/vm/
mod.rs

1mod any;
2mod array;
3mod bigint;
4mod bigint_coercion;
5mod boolean_coercion;
6mod container_fmt;
7mod dispatch;
8mod ecma_whitespace;
9mod error;
10mod function;
11mod impls;
12mod internal;
13mod iterator_record;
14mod lambda;
15mod member_access;
16mod nullish;
17mod number;
18mod number_coercion;
19mod numeric;
20mod numeric_coercion;
21mod object;
22mod object_spread;
23mod position;
24mod primitive;
25mod primitive_coercion;
26mod primitive_dispatch;
27mod runtime;
28mod string;
29mod string_coercion;
30mod string_numeric_literal;
31mod unpacked;
32pub mod unstable;
33
34pub use crate::vm::{
35    any::{Any, Constructor, JsonError, to_any::ToAny},
36    array::{Array, to_array::ToArray},
37    bigint::BigInt,
38    function::Function,
39    internal::{IComplex, IContainer, IFunction, IStaticFunction, IVm, StaticCode},
40    iterator_record::IteratorRecord,
41    lambda::{OptionLambda, OptionPropertyLambda, PropertyLambda},
42    nullish::Nullish,
43    number::Number,
44    object::{Object, property::Property, to_object::ToObject},
45    object_spread::ObjectSpread,
46    string::{String, to_string::ToString},
47    unpacked::Unpacked,
48};
49
50/// The runtime as a value, `runtime::<A>()`: what whoever runs compiled
51/// modules builds once and hands each as its parameter
52/// (`fjs/js/runtime/README.md`, "How NaNVM finds it").
53pub use crate::vm::runtime::compiled::runtime;
54
55pub(crate) use crate::vm::impls::ContainerWrapper;
56
57#[cfg(test)]
58mod test {
59    pub(super) mod deep;
60    pub(super) mod function;
61
62    use crate::vm::ToAny;
63
64    use super::*;
65
66    /// Compiles only: `Any<A>` is `PartialEq` for a generic VM. The two
67    /// sides differ, a value and its clone, so clippy's `eq_op` does not
68    /// read the comparison as a tautology under `--all-targets`.
69    fn _eq_test<A: IVm>() {
70        let x: Any<A> = Number::from(0.5).to_any();
71        assert_eq!(x.clone(), x);
72    }
73
74    fn _any_test<A: IVm>() {
75        let x: Any<A> = Number::from(0.5).to_any();
76        let _: Number = x.try_into().unwrap();
77    }
78}