convert HackConstant to use ConstId
[hiphop-php.git] / hphp / hack / src / hackc / ir / conversions / bc_to_ir / constant.rs
blob3905f047ca47809d0167dfae335249639e63183b
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 hhbc::Constant;
7 use ir::StringInterner;
9 use crate::convert;
11 pub(crate) fn convert_constant<'a>(
12     constant: &Constant<'a>,
13     strings: &StringInterner,
14 ) -> ir::HackConstant {
15     let Constant {
16         name,
17         ref value,
18         is_abstract,
19     } = *constant;
21     let value = value
22         .as_ref()
23         .map(|tv| convert::convert_typed_value(tv, strings))
24         .into();
26     let name = ir::ConstId::from_hhbc(name, strings);
28     ir::HackConstant {
29         name,
30         value,
31         is_abstract,
32     }