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.
6 /// Emit the opcodes enum. Given input that looks like this:
9 /// #[macros::emit_opcodes]
10 /// enum MyCrazyOpcodes<'lifetime> { }
13 /// The result will look something like this:
16 /// enum MyCrazyOpcodes<'lifetime> {
19 /// PopL(Local<'lifetime>),
23 /// If the 'Targets' derive is used then the Targets trait will be implemented
26 /// See emit_opcodes::tests::test_basic() for a more detailed example output.
28 #[proc_macro_attribute]
30 _attrs: proc_macro::TokenStream,
31 input: proc_macro::TokenStream,
32 ) -> proc_macro::TokenStream {
33 match emit_opcodes::emit_opcodes(input.into(), hhbc::opcode_data()) {
34 Ok(res) => res.into(),
35 Err(err) => err.into_compile_error().into(),
39 #[proc_macro_derive(Targets)]
40 pub fn emit_targets(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
41 match emit_opcodes::emit_impl_targets(input.into(), hhbc::opcode_data()) {
42 Ok(res) => res.into(),
43 Err(err) => err.into_compile_error().into(),