mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
gccrs: libproc_macro: Add proc_macro interface structures
Add the structures that should be used by a compiler opening a procedural macro to either identify or execute it. libgrust/ChangeLog: * libproc_macro/proc_macro.h (struct CustomDerivePayload): Add C compatible payload structure. (struct AttrPayload): Likewise. (struct BangPayload): Likewise. (enum ProcmacroTag): Add tag for tagged union. (union ProcmacroPayload): Proc macro payload union. (struct Procmacro): Tagged union. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
This commit is contained in:
parent
a365e3ed70
commit
1ff234bffd
@ -23,6 +23,7 @@
|
||||
#ifndef PROC_MACRO_H
|
||||
#define PROC_MACRO_H
|
||||
|
||||
#include <cstdint>
|
||||
#include "literal.h"
|
||||
#include "tokenstream.h"
|
||||
#include "tokentree.h"
|
||||
@ -30,4 +31,58 @@
|
||||
#include "punct.h"
|
||||
#include "ident.h"
|
||||
|
||||
namespace ProcMacro {
|
||||
|
||||
extern "C" {
|
||||
|
||||
using CustomDeriveMacro = TokenStream (*) (TokenStream);
|
||||
using AttributeMacro = TokenStream (*) (TokenStream, TokenStream);
|
||||
using BangMacro = TokenStream (*) (TokenStream);
|
||||
|
||||
struct CustomDerivePayload
|
||||
{
|
||||
// TODO: UTF-8 function name
|
||||
char *trait_name;
|
||||
// TODO: UTF-8 attributes
|
||||
char **attributes;
|
||||
std::uint64_t attr_size;
|
||||
CustomDeriveMacro macro;
|
||||
};
|
||||
|
||||
struct AttrPayload
|
||||
{
|
||||
// TODO: UTF-8 function name
|
||||
char *name;
|
||||
AttributeMacro macro;
|
||||
};
|
||||
|
||||
struct BangPayload
|
||||
{
|
||||
char *name;
|
||||
BangMacro macro;
|
||||
};
|
||||
}
|
||||
|
||||
enum ProcmacroTag
|
||||
{
|
||||
CUSTOM_DERIVE,
|
||||
ATTR,
|
||||
BANG,
|
||||
};
|
||||
|
||||
union ProcmacroPayload
|
||||
{
|
||||
CustomDerivePayload custom_derive;
|
||||
AttrPayload attribute;
|
||||
BangPayload bang;
|
||||
};
|
||||
|
||||
struct Procmacro
|
||||
{
|
||||
ProcmacroTag tag;
|
||||
ProcmacroPayload payload;
|
||||
};
|
||||
|
||||
} // namespace ProcMacro
|
||||
|
||||
#endif /* ! PROC_MACRO_H */
|
||||
|
Loading…
Reference in New Issue
Block a user