Page Menu
Home
Xreate
Search
Configure Global Search
Log In
Docs
Questions
Repository
Issues
Patches
Internal API
Files
F3996044
ExternLayer.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jul 8, 8:22 AM
Size
1 KB
Mime Type
text/x-c++
Expires
Fri, Jul 10, 8:22 AM (1 d, 15 h)
Engine
blob
Format
Raw Data
Handle
271789
Attached To
rXR Xreate
ExternLayer.h
View Options
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* ExternLayer.h
*
* Created on: 4/21/15
* Author: pgess <v.melnychenko@xreate.org>
*/
/**
* \file ExternLayer.h
* \brief An external C code interaction support
*/
#ifndef XREATE_EXTERNLAYER_H
#define XREATE_EXTERNLAYER_H
#include "llvmlayer.h"
#include <vector>
#include <string>
#include <map>
#include "ast.h"
#include "clang/AST/ASTContext.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CodeGenOptions.h"
#include "clang/CodeGen/CodeGenABITypes.h"
#include "clang/Lex/PreprocessorOptions.h"
namespace clang{
class CodeGenerator;
}
namespace xreate{
/** \brief A wrapper over Clang */
class ExternLayer{
public:
ExternLayer(LLVMLayer* llvm);
void init(const AST* ast);
llvm::Function* lookupFunction(const std::string& name);
clang::QualType lookupType(const std::string& id);
std::vector<std::string> getStructFields(const clang::QualType& ty);
llvm::Type* toLLVMType(const clang::QualType& t);
bool isPointer(const clang::QualType& t);
bool isArrayType(const std::string& type);
bool isRecordType(const std::string& type);
static std::vector<std::string> fetchPackageFlags(const std::string& package);
static std::vector<std::string> fetchPackageLibs(const std::string& package);
private:
std::unique_ptr<clang::ASTUnit> ast;
std::unique_ptr<clang::CodeGenerator> __codegen;
std::unique_ptr<clang::CompilerInstance> __clang;
LLVMLayer* __llvm;
std::map<std::string, llvm::Function*> __functions;
void loadLibraries(std::vector<std::string>&& libs);
};
}
#endif //XREATE_EXTERNLAYER_H
Event Timeline
Log In to Comment