1 // Copyright (c) Facebook, Inc. and its affiliates.
3 // This source code is licensed under the MIT license found in the
4 // LICENSE file in the "hack" directory of this source tree.
5 #![feature(rustc_private)]
6 use hhas_attribute_rust::HhasAttribute;
7 use hhas_type::{constraint, Info};
9 use tast_rust::TastExpr;
10 extern crate bitflags;
13 pub struct HhasParam {
15 pub is_reference: bool,
16 pub is_variadic: bool,
18 pub user_attributes: Vec<HhasAttribute>,
19 pub type_info: Option<Info>,
20 pub default_value: Option<(Label, TastExpr)>,
24 pub fn replace_default_value_label(&mut self, new_label: Label) {
25 let old_default_value = std::mem::replace(&mut self.default_value, None);
26 if let Some((_, e)) = old_default_value {
27 self.default_value = Some((new_label, e));
31 pub fn without_type(&mut self) {
32 self.type_info.as_mut().map(|ti| {
33 ti.type_constraint = constraint::Type::default();
37 pub fn with_name(&mut self, name: String) {
41 pub fn switch_inout_to_reference(&mut self) {
43 self.is_inout = false;
44 self.is_reference = true;
48 pub fn switch_reference_to_inout(&mut self) {
49 if self.is_reference {
51 self.is_reference = false;