1 #include "ast/intrinsic.h"
8 {
"asm", IntrinsicType::ASM },
9 {
"swap", IntrinsicType::SWAP },
10 {
"memset", IntrinsicType::MEMSET },
11 {
"memcpy", IntrinsicType::MEMCPY },
12 {
"range", IntrinsicType::RANGE },
13 {COMP_PRINT_NAME, IntrinsicType::COMP_PRINT },
14 {
"file", IntrinsicType::FILENAME },
15 {
"line", IntrinsicType::LINENO },
16 {
"define", IntrinsicType::DEFINE },
17 {
"sizeof", IntrinsicType::SIZE_OF },
18 {
"offsetof", IntrinsicType::OFFSET_OF },
19 {
"isa", IntrinsicType::ISA },
20 {
"alignof", IntrinsicType::ALIGN_OF },
21 {
"min_of", IntrinsicType::MIN_OF },
22 {
"max_of", IntrinsicType::MAX_OF },
23 {
"is_unsigned", IntrinsicType::IS_UNSIGNED },
24 {
"unlikely", IntrinsicType::UNLIKELY },
25 {
"likely", IntrinsicType::LIKELY },
26 {
"expect", IntrinsicType::EXPECT },
27 {
"noop", IntrinsicType::NOOP },
28 {
"get_decl", IntrinsicType::GET_DECL },
29 {TEST_COMP_ERROR_NAME, IntrinsicType::TEST_COMP_ERROR},
30 {ABORT_NAME, IntrinsicType::ABORT },
31 {
"stack_trace", IntrinsicType::STACK_TRACE },
32 {STACK_TRACE_FUNCTION_REAL_NAME, IntrinsicType::STACK_TRACE }
36 vector<FunctionDecl *> ret{};
40 ret.push_back(FunctionDecl::Create(src,
42 Type::GetFunctionType(Type::GetVoidType(), {Type::GetStringType()}),
49 ret.push_back(FunctionDecl::Create(
50 src, ABORT_NAME, Type::GetFunctionType(Type::GetVoidType(), {}),
true,
false,
nullptr,
true));
57 Intrinsic::Intrinsic(TokenizedSourceFile *src) : Expr(ASTNodeType::INTRINSIC, src, 0) {}
59 IntrinsicType Intrinsic::get_intrinsic_type()
const {
return _intrinsic_type; }
61 void Intrinsic::set_intrinsic_type(IntrinsicType intrinsic_type) { _intrinsic_type = intrinsic_type; }
63 ASTBase *Intrinsic::get_sub()
const {
return _sub; }
65 void Intrinsic::set_sub(ASTBase *sub) { _sub = sub; }
75 if (_intrinsic_type == IntrinsicType::TEST_COMP_ERROR) {
virtual vector< ASTBase * > get_children() const
Get a ordered list of child nodes.
A generic representation of Intrinsic variables/functions.
static umap< str, IntrinsicType > INTRINSIC_NAME_TO_TYPES
A mapping from intrinsic names to IntrinsicType.
static vector< FunctionDecl * > GetIntrinsicFunctionDeclarations()
Generate a list of intrinsics function prototypes/declarations, such as @abort
vector< ASTBase * > get_children() const override
Get a ordered list of child nodes.
str terminal_token() const override
Which terminal token is expected immediately after this node.
Different from SourceFile, TokenizedSourceFile manages the tokenized text of a source file.