ezno_checker/features/
objects.rs1use source_map::SpanWithSource;
2
3use crate::{
4 context::LocalInformation,
5 types::{
6 calling::ThisValue,
7 properties::{PropertyKey, PropertyValue, Publicity},
8 TypeStore,
9 },
10 FunctionId, TypeId,
11};
12
13pub struct ObjectBuilder {
16 pub object: TypeId,
17}
18
19impl ObjectBuilder {
20 pub fn new(
21 prototype: Option<TypeId>,
22 types: &mut TypeStore,
23 position: SpanWithSource,
24 info: &mut LocalInformation,
25 ) -> Self {
26 let is_under_dyn = true;
28 Self { object: info.new_object(prototype, types, position, is_under_dyn) }
29 }
30
31 pub fn append(
32 &mut self,
33 publicity: Publicity,
34 under: PropertyKey<'static>,
35 value: PropertyValue,
36 position: SpanWithSource,
37 info: &mut LocalInformation,
38 ) {
39 info.register_property(self.object, publicity, under, value, position);
40 }
41
42 #[must_use]
43 pub fn build_object(self) -> TypeId {
44 self.object
45 }
46}
47
48#[derive(Clone, Debug, binary_serialize_derive::BinarySerializable)]
50pub enum SpecialObject {
51 Promise {
53 from: FunctionId,
54 position: TypeId,
55 },
56 Generator {
58 from: FunctionId,
59 position: TypeId,
60 },
61 Proxy(Proxy),
63 RegularExpression(super::regexp::RegExp),
65 Import(super::modules::Exported),
67 Function(FunctionId, ThisValue),
70 Null,
71}
72
73#[derive(Copy, Clone, Debug, binary_serialize_derive::BinarySerializable)]
80pub struct Proxy {
81 pub over: TypeId,
82 pub handler: TypeId,
83}