-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathslang_rs.h
132 lines (103 loc) · 4.46 KB
/
slang_rs.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* Copyright 2010-2012, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_H_ // NOLINT
#define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_H_
#include "slang.h"
#include <list>
#include <string>
#include <utility>
#include <vector>
#include "llvm/ADT/StringMap.h"
#include "slang_rs_reflect_utils.h"
#include "slang_version.h"
namespace slang {
class RSCCOptions;
class RSContext;
class RSExportRecordType;
class SlangRS : public Slang {
private:
// Context for Renderscript
RSContext *mRSContext;
bool mAllowRSPrefix;
unsigned int mTargetAPI;
bool mVerbose;
bool mIsFilterscript;
// Custom diagnostic identifiers
unsigned mDiagErrorInvalidOutputDepParameter;
unsigned mDiagErrorODR;
unsigned mDiagErrorTargetAPIRange;
// Collect generated filenames (without the .java) for dependency generation
std::vector<std::string> mGeneratedFileNames;
// FIXME: Should be std::list<RSExportable *> here. But currently we only
// check ODR on record type.
//
// ReflectedDefinitions maps record type name to a pair:
// <its RSExportRecordType instance,
// the first file contains this record type definition>
typedef std::pair<RSExportRecordType*, const char*> ReflectedDefinitionTy;
typedef llvm::StringMap<ReflectedDefinitionTy> ReflectedDefinitionListTy;
ReflectedDefinitionListTy ReflectedDefinitions;
bool generateJavaBitcodeAccessor(const std::string &OutputPathBase,
const std::string &PackageName,
const std::string *LicenseNote);
// CurInputFile is the pointer to a char array holding the input filename
// and is valid before compile() ends.
bool checkODR(const char *CurInputFile);
// Returns true if this is a Filterscript file.
static bool isFilterscript(const char *Filename);
protected:
virtual void initDiagnostic();
virtual void initPreprocessor();
virtual void initASTContext();
virtual clang::ASTConsumer
*createBackend(const clang::CodeGenOptions& CodeGenOpts,
llvm::raw_ostream *OS,
Slang::OutputType OT);
public:
static bool IsRSHeaderFile(const char *File);
// FIXME: Determine whether a location is in RS header (i.e., one of the RS
// built-in APIs) should only need its names (we need a "list" of RS
// built-in APIs).
static bool IsLocInRSHeaderFile(const clang::SourceLocation &Loc,
const clang::SourceManager &SourceMgr);
SlangRS();
// Compile bunch of RS files given in the llvm-rs-cc arguments. Return true if
// all given input files are successfully compiled without errors.
//
// @IOFiles - List of pairs of <input file path, output file path>.
//
// @DepFiles - List of pairs of <output dep. file path, dependent bitcode
// target>. If @OutputDep is true, this parameter must be given
// with the same number of pairs given in @IOFiles.
//
// @Opts - Selection of options defined from invoking llvm-rs-cc
bool compile(const std::list<std::pair<const char*, const char*> > &IOFiles64,
const std::list<std::pair<const char*, const char*> > &IOFiles32,
const std::list<std::pair<const char*, const char*> > &DepFiles,
const RSCCOptions &Opts);
virtual void reset(bool SuppressWarnings = false);
virtual ~SlangRS();
virtual void makeModuleVisible(clang::Module *Mod,
clang::Module::NameVisibilityKind Visibility,
clang::SourceLocation ImportLoc,
bool Complain = false) { }
virtual clang::GlobalModuleIndex *loadGlobalModuleIndex(
clang::SourceLocation TriggerLoc) { }
virtual bool lookupMissingImports(llvm::StringRef Name,
clang::SourceLocation TriggerLoc) { }
};
} // namespace slang
#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_H_ NOLINT