Tweak HhasMethod C++: Get as close to `repr(C)` as we can
[hiphop-php.git] / hphp / hack / src / hhbc / hhbc_by_ref / hhas_method.rs
blob1f9f51f867aa2c1a73e3e8e19d4b90a2bd9d90e3
1 // Copyright (c) Facebook, Inc. and its affiliates.
2 //
3 // This source code is licensed under the MIT license found in the
4 // LICENSE file in the "hack" directory of this source tree.
6 use ffi::Slice;
7 use hhbc_by_ref_hhas_attribute::HhasAttribute;
8 use hhbc_by_ref_hhas_body::HhasBody;
9 use hhbc_by_ref_hhas_coeffects::HhasCoeffects;
10 use hhbc_by_ref_hhas_pos::Span;
11 use hhbc_by_ref_hhbc_ast::Visibility;
12 use hhbc_by_ref_hhbc_id::method::MethodType;
14 use bitflags::bitflags;
16 #[derive(Debug)]
17 pub struct HhasMethod<'arena> {
18     pub attributes: Slice<'arena, HhasAttribute<'arena>>,
19     pub visibility: Visibility,
20     pub name: MethodType<'arena>,
21     pub body: HhasBody<'arena>,
22     pub span: Span,
23     pub coeffects: HhasCoeffects, //TODO(SF, 2021-08-10): Fix when Steve's `HhasCoeffect`'s (`repr(C)`)work lands
24     pub flags: HhasMethodFlags,
27 bitflags! {
28     #[repr(C)]
29     pub struct HhasMethodFlags: u16 {
30         const IS_STATIC = 1 << 1;
31         const IS_FINAL = 1 << 2;
32         const IS_ABSTRACT = 1 << 3;
33         const IS_ASYNC = 1 << 4;
34         const IS_GENERATOR = 1 << 5;
35         const IS_PAIR_GENERATOR = 1 << 6;
36         const IS_CLOSURE_BODY = 1 << 7;
37         const IS_INTERCEPTABLE = 1 << 8;
38         const IS_MEMOIZE_IMPL = 1 << 9;
39         const RX_DISABLED = 1 << 10;
40         const NO_INJECTION = 1 << 11;
41     }
44 impl<'a, 'arena> HhasMethod<'arena> {
45     pub fn is_closure_body(&self) -> bool {
46         self.flags.contains(HhasMethodFlags::IS_CLOSURE_BODY)
47     }
49     pub fn is_no_injection(&self) -> bool {
50         self.flags.contains(HhasMethodFlags::NO_INJECTION)
51     }
53     pub fn is_memoize_impl(&self) -> bool {
54         self.flags.contains(HhasMethodFlags::IS_MEMOIZE_IMPL)
55     }
57     pub fn is_interceptable(&self) -> bool {
58         self.flags.contains(HhasMethodFlags::IS_INTERCEPTABLE)
59     }