/
method.rs
46 lines (41 loc) · 1.14 KB
/
method.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use bitflags::bitflags;
use ffi::Slice;
use hhvm_types_ffi::ffi::Attr;
use serde::Serialize;
use crate::Attribute;
use crate::Body;
use crate::Coeffects;
use crate::MethodName;
use crate::Span;
use crate::Visibility;
#[derive(Debug, Serialize)]
#[repr(C)]
pub struct Method<'arena> {
pub attributes: Slice<'arena, Attribute<'arena>>,
pub visibility: Visibility,
pub name: MethodName<'arena>,
pub body: Body<'arena>,
pub span: Span,
pub coeffects: Coeffects<'arena>,
pub flags: MethodFlags,
pub attrs: Attr,
}
bitflags! {
#[derive(Default, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
#[repr(C)]
pub struct MethodFlags: u16 {
const IS_ASYNC = 1 << 0;
const IS_GENERATOR = 1 << 1;
const IS_PAIR_GENERATOR = 1 << 2;
const IS_CLOSURE_BODY = 1 << 3;
}
}
impl Method<'_> {
pub fn is_closure_body(&self) -> bool {
self.flags.contains(MethodFlags::IS_CLOSURE_BODY)
}
}