-
Notifications
You must be signed in to change notification settings - Fork 10
/
SrcGen.h
48 lines (38 loc) · 1.57 KB
/
SrcGen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef CCONS_SRC_GEN_H
#define CCONS_SRC_GEN_H
//
// Header for SrcGen.cpp, which provides various utility functions for
// re-writing and generating strings with C code for various use cases.
//
// Part of ccons, the interactive console for the C programming language.
//
// Copyright (c) 2009 Alexei Svitkine. This file is distributed under the
// terms of MIT Open Source License. See file LICENSE for details.
//
#include <string>
namespace clang {
struct PrintingPolicy;
class ASTContext;
class QualType;
class FunctionDecl;
} // namespace clang
namespace ccons {
class Parser;
// Generate a variable declaration (like "int i;") for the specified type
// and variable name. Works for non-trivial types like function pointers.
std::string genVarDecl(const clang::PrintingPolicy& PP,
const clang::QualType& type,
const std::string& vName);
// Generate a function definition with the specified parameters. Returns
// the offset of the start of the body in variable bodyOffset.
std::string genFunction(const clang::PrintingPolicy& PP,
const clang::QualType *retType,
clang::ASTContext *context,
const std::string& fName,
const std::string& fBody,
int& bodyOffset);
// Get the function declaration as a string, from the FunctionDecl specified.
std::string getFunctionDeclAsString(const clang::PrintingPolicy& PP,
const clang::FunctionDecl *FD);
} // namespace ccons
#endif // CCONS_SRC_GEN_H