blob: 277516db4e78eb9148417c3381999cb8f52ea12a [file] [log] [blame]
Zonr Changc383a502010-10-12 01:52:08 +08001/*
Stephen Hines0a813a32012-08-03 16:52:40 -07002 * Copyright 2010-2012, The Android Open Source Project
Zonr Changc383a502010-10-12 01:52:08 +08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Zonr Chang3a9ca1f2010-10-06 17:52:56 +080017#include "slang_rs.h"
18
Shih-wei Liaob81c6a42010-10-10 14:15:00 -070019#include <cstring>
Stephen Hinese639eb52010-11-08 19:27:20 -080020#include <list>
Stephen Hines2e35b132011-07-22 02:50:19 -070021#include <sstream>
Stephen Hinese639eb52010-11-08 19:27:20 -080022#include <string>
23#include <utility>
24#include <vector>
Stephen Hinesfcda2352010-10-19 16:49:32 -070025
Loganbe274822011-02-16 22:02:54 +080026#include "clang/Basic/SourceLocation.h"
27
Zonr Changcf6af6a2010-10-12 12:38:51 +080028#include "clang/Frontend/FrontendDiagnostic.h"
29
Zonr Chang3a9ca1f2010-10-06 17:52:56 +080030#include "clang/Sema/SemaDiagnostic.h"
31
Loganbe274822011-02-16 22:02:54 +080032#include "llvm/Support/Path.h"
Stephen Hinese639eb52010-11-08 19:27:20 -080033
Raphael8d5a2f62011-02-08 00:15:05 -080034#include "os_sep.h"
Zonr Chang3a9ca1f2010-10-06 17:52:56 +080035#include "slang_rs_backend.h"
36#include "slang_rs_context.h"
Zonr Chang641558f2010-10-12 21:07:06 +080037#include "slang_rs_export_type.h"
Zonr Chang3a9ca1f2010-10-06 17:52:56 +080038
Jean-Luc Brouillet12fc2832014-06-04 21:32:31 +000039#include "slang_rs_reflection.h"
Jason Sams1b6a0882012-03-12 15:07:58 -070040#include "slang_rs_reflection_cpp.h"
41
Stephen Hinese639eb52010-11-08 19:27:20 -080042namespace slang {
Zonr Chang3a9ca1f2010-10-06 17:52:56 +080043
Stephen Hines11274a72012-09-26 19:14:20 -070044#define FS_SUFFIX "fs"
45
Zonr Chang3c250c52010-10-07 12:19:23 +080046#define RS_HEADER_SUFFIX "rsh"
47
Stephen Hines2d35edd2011-08-09 11:33:27 -070048/* RS_HEADER_ENTRY(name) */
Zonr Chang3c250c52010-10-07 12:19:23 +080049#define ENUM_RS_HEADER() \
Stephen Hines2d35edd2011-08-09 11:33:27 -070050 RS_HEADER_ENTRY(rs_allocation) \
51 RS_HEADER_ENTRY(rs_atomic) \
52 RS_HEADER_ENTRY(rs_cl) \
53 RS_HEADER_ENTRY(rs_core) \
Stephen Hinesa7ab54d2014-01-08 09:41:49 -080054 RS_HEADER_ENTRY(rs_core_math) \
Stephen Hines2d35edd2011-08-09 11:33:27 -070055 RS_HEADER_ENTRY(rs_debug) \
Alex Sakhartchouk4eb4b382012-03-21 09:58:39 -070056 RS_HEADER_ENTRY(rs_element) \
Stephen Hines2d35edd2011-08-09 11:33:27 -070057 RS_HEADER_ENTRY(rs_graphics) \
58 RS_HEADER_ENTRY(rs_math) \
Alex Sakhartchouk4eb4b382012-03-21 09:58:39 -070059 RS_HEADER_ENTRY(rs_mesh) \
Stephen Hines2d35edd2011-08-09 11:33:27 -070060 RS_HEADER_ENTRY(rs_matrix) \
61 RS_HEADER_ENTRY(rs_object) \
Alex Sakhartchouk4eb4b382012-03-21 09:58:39 -070062 RS_HEADER_ENTRY(rs_program) \
Stephen Hines2d35edd2011-08-09 11:33:27 -070063 RS_HEADER_ENTRY(rs_quaternion) \
Alex Sakhartchouk4eb4b382012-03-21 09:58:39 -070064 RS_HEADER_ENTRY(rs_sampler) \
Stephen Hines2d35edd2011-08-09 11:33:27 -070065 RS_HEADER_ENTRY(rs_time) \
66 RS_HEADER_ENTRY(rs_types) \
67
Stephen Hines11274a72012-09-26 19:14:20 -070068// Returns true if \p Filename ends in ".fs".
69bool SlangRS::isFilterscript(const char *Filename) {
70 const char *c = strrchr(Filename, '.');
71 if (c && !strncmp(FS_SUFFIX, c + 1, strlen(FS_SUFFIX) + 1)) {
72 return true;
73 } else {
74 return false;
75 }
76}
Zonr Chang3c250c52010-10-07 12:19:23 +080077
Jean-Luc Brouillet129fd822014-05-28 17:46:10 -070078bool SlangRS::generateJavaBitcodeAccessor(const std::string &OutputPathBase,
Jean-Luc Brouillet12fc2832014-06-04 21:32:31 +000079 const std::string &PackageName,
80 const std::string *LicenseNote) {
Zonr Changcf6af6a2010-10-12 12:38:51 +080081 RSSlangReflectUtils::BitCodeAccessorContext BCAccessorContext;
82
83 BCAccessorContext.rsFileName = getInputFileName().c_str();
84 BCAccessorContext.bcFileName = getOutputFileName().c_str();
85 BCAccessorContext.reflectPath = OutputPathBase.c_str();
86 BCAccessorContext.packageName = PackageName.c_str();
Jean-Luc Brouillet129fd822014-05-28 17:46:10 -070087 BCAccessorContext.licenseNote = LicenseNote;
Zonr Changcf6af6a2010-10-12 12:38:51 +080088 BCAccessorContext.bcStorage = BCST_JAVA_CODE; // Must be BCST_JAVA_CODE
89
Jean-Luc Brouillet129fd822014-05-28 17:46:10 -070090 return RSSlangReflectUtils::GenerateJavaBitCodeAccessor(BCAccessorContext);
Zonr Changcf6af6a2010-10-12 12:38:51 +080091}
92
Zonr Change86245a2010-10-12 21:42:13 +080093bool SlangRS::checkODR(const char *CurInputFile) {
Zonr Chang641558f2010-10-12 21:07:06 +080094 for (RSContext::ExportableList::iterator I = mRSContext->exportable_begin(),
95 E = mRSContext->exportable_end();
96 I != E;
97 I++) {
Stephen Hinesa858cb62011-01-17 12:17:51 -080098 RSExportable *RSE = *I;
99 if (RSE->getKind() != RSExportable::EX_TYPE)
Zonr Chang641558f2010-10-12 21:07:06 +0800100 continue;
101
Stephen Hinesa858cb62011-01-17 12:17:51 -0800102 RSExportType *ET = static_cast<RSExportType *>(RSE);
Zonr Chang641558f2010-10-12 21:07:06 +0800103 if (ET->getClass() != RSExportType::ExportClassRecord)
104 continue;
105
106 RSExportRecordType *ERT = static_cast<RSExportRecordType *>(ET);
107
108 // Artificial record types (create by us not by user in the source) always
109 // conforms the ODR.
110 if (ERT->isArtificial())
111 continue;
112
113 // Key to lookup ERT in ReflectedDefinitions
114 llvm::StringRef RDKey(ERT->getName());
115 ReflectedDefinitionListTy::const_iterator RD =
116 ReflectedDefinitions.find(RDKey);
117
118 if (RD != ReflectedDefinitions.end()) {
119 const RSExportRecordType *Reflected = RD->getValue().first;
120 // There's a record (struct) with the same name reflected before. Enforce
121 // ODR checking - the Reflected must hold *exactly* the same "definition"
122 // as the one defined previously. We say two record types A and B have the
123 // same definition iff:
124 //
125 // struct A { struct B {
126 // Type(a1) a1, Type(b1) b1,
127 // Type(a2) a2, Type(b1) b2,
128 // ... ...
129 // Type(aN) aN Type(b3) b3,
130 // }; }
131 // Cond. #1. They have same number of fields, i.e., N = M;
132 // Cond. #2. for (i := 1 to N)
133 // Type(ai) = Type(bi) must hold;
134 // Cond. #3. for (i := 1 to N)
135 // Name(ai) = Name(bi) must hold;
136 //
137 // where,
138 // Type(F) = the type of field F and
139 // Name(F) = the field name.
140
141 bool PassODR = false;
142 // Cond. #1 and Cond. #2
143 if (Reflected->equals(ERT)) {
144 // Cond #3.
145 RSExportRecordType::const_field_iterator AI = Reflected->fields_begin(),
146 BI = ERT->fields_begin();
147
148 for (unsigned i = 0, e = Reflected->getFields().size(); i != e; i++) {
149 if ((*AI)->getName() != (*BI)->getName())
150 break;
151 AI++;
152 BI++;
153 }
154 PassODR = (AI == (Reflected->fields_end()));
155 }
156
157 if (!PassODR) {
158 getDiagnostics().Report(mDiagErrorODR) << Reflected->getName()
159 << getInputFileName()
160 << RD->getValue().second;
161 return false;
162 }
163 } else {
164 llvm::StringMapEntry<ReflectedDefinitionTy> *ME =
165 llvm::StringMapEntry<ReflectedDefinitionTy>::Create(RDKey.begin(),
166 RDKey.end());
Zonr Change86245a2010-10-12 21:42:13 +0800167 ME->setValue(std::make_pair(ERT, CurInputFile));
Zonr Chang641558f2010-10-12 21:07:06 +0800168
169 if (!ReflectedDefinitions.insert(ME))
170 delete ME;
171
172 // Take the ownership of ERT such that it won't be freed in ~RSContext().
173 ERT->keep();
174 }
Zonr Chang641558f2010-10-12 21:07:06 +0800175 }
176 return true;
177}
Zonr Changcf6af6a2010-10-12 12:38:51 +0800178
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800179void SlangRS::initDiagnostic() {
Logan Chien9207a2e2011-10-21 15:39:28 +0800180 clang::DiagnosticsEngine &DiagEngine = getDiagnostics();
Zonr Changcf6af6a2010-10-12 12:38:51 +0800181
Logan Chien9207a2e2011-10-21 15:39:28 +0800182 if (DiagEngine.setDiagnosticGroupMapping("implicit-function-declaration",
183 clang::diag::MAP_ERROR))
184 DiagEngine.Report(clang::diag::warn_unknown_warning_option)
185 << "implicit-function-declaration";
186
187 DiagEngine.setDiagnosticMapping(
188 clang::diag::ext_typecheck_convert_discards_qualifiers,
189 clang::diag::MAP_ERROR,
190 clang::SourceLocation());
Zonr Chang641558f2010-10-12 21:07:06 +0800191
192 mDiagErrorInvalidOutputDepParameter =
Logan Chien9207a2e2011-10-21 15:39:28 +0800193 DiagEngine.getCustomDiagID(
194 clang::DiagnosticsEngine::Error,
195 "invalid parameter for output dependencies files.");
Zonr Chang641558f2010-10-12 21:07:06 +0800196
197 mDiagErrorODR =
Logan Chien9207a2e2011-10-21 15:39:28 +0800198 DiagEngine.getCustomDiagID(
199 clang::DiagnosticsEngine::Error,
200 "type '%0' in different translation unit (%1 v.s. %2) "
201 "has incompatible type definition");
Zonr Chang641558f2010-10-12 21:07:06 +0800202
Logan Chien9207a2e2011-10-21 15:39:28 +0800203 mDiagErrorTargetAPIRange =
204 DiagEngine.getCustomDiagID(
205 clang::DiagnosticsEngine::Error,
Stephen Hines2e35b132011-07-22 02:50:19 -0700206 "target API level '%0' is out of range ('%1' - '%2')");
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800207}
208
209void SlangRS::initPreprocessor() {
210 clang::Preprocessor &PP = getPreprocessor();
211
Stephen Hines2e35b132011-07-22 02:50:19 -0700212 std::stringstream RSH;
Stephen Hines0e4ee652014-06-10 14:32:26 -0700213 RSH << PP.getPredefines();
Jean-Luc Brouillet29689212014-05-27 13:25:31 -0700214 RSH << "#define RS_VERSION " << mTargetAPI << "\n";
215 RSH << "#include \"rs_core." RS_HEADER_SUFFIX "\"\n";
Stephen Hines2e35b132011-07-22 02:50:19 -0700216 PP.setPredefines(RSH.str());
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800217}
218
219void SlangRS::initASTContext() {
Stephen Hines9e5b5032010-11-03 13:19:14 -0700220 mRSContext = new RSContext(getPreprocessor(),
221 getASTContext(),
Stephen Hines3fd0a942011-01-18 12:27:39 -0800222 getTargetInfo(),
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800223 &mPragmas,
Jean-Luc Brouillet12fc2832014-06-04 21:32:31 +0000224 mTargetAPI);
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800225}
226
227clang::ASTConsumer
228*SlangRS::createBackend(const clang::CodeGenOptions& CodeGenOpts,
229 llvm::raw_ostream *OS,
230 Slang::OutputType OT) {
231 return new RSBackend(mRSContext,
Stephen Hinese639eb52010-11-08 19:27:20 -0800232 &getDiagnostics(),
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800233 CodeGenOpts,
234 getTargetOptions(),
Stephen Hines3fd0a942011-01-18 12:27:39 -0800235 &mPragmas,
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800236 OS,
237 OT,
238 getSourceManager(),
Stephen Hines11274a72012-09-26 19:14:20 -0700239 mAllowRSPrefix,
240 mIsFilterscript);
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800241}
242
Zonr Chang592a9542010-10-07 20:03:58 +0800243bool SlangRS::IsRSHeaderFile(const char *File) {
Stephen Hines2d35edd2011-08-09 11:33:27 -0700244#define RS_HEADER_ENTRY(name) \
Tim Murrayee4016d2014-04-10 15:49:08 -0700245 if (::strcmp(File, #name "." RS_HEADER_SUFFIX) == 0) \
Zonr Chang592a9542010-10-07 20:03:58 +0800246 return true;
247ENUM_RS_HEADER()
248#undef RS_HEADER_ENTRY
Zonr Chang592a9542010-10-07 20:03:58 +0800249 return false;
250}
251
Stephen Hines11274a72012-09-26 19:14:20 -0700252bool SlangRS::IsLocInRSHeaderFile(const clang::SourceLocation &Loc,
253 const clang::SourceManager &SourceMgr) {
254 clang::FullSourceLoc FSL(Loc, SourceMgr);
Stephen Hinesfcda2352010-10-19 16:49:32 -0700255 clang::PresumedLoc PLoc = SourceMgr.getPresumedLoc(FSL);
Stephen Hinesfcda2352010-10-19 16:49:32 -0700256
Stephen Hines688e64b2011-08-23 16:01:25 -0700257 const char *Filename = PLoc.getFilename();
258 if (!Filename) {
259 return false;
260 } else {
261 return IsRSHeaderFile(llvm::sys::path::filename(Filename).data());
262 }
Stephen Hinesfcda2352010-10-19 16:49:32 -0700263}
264
Logan Chien9207a2e2011-10-21 15:39:28 +0800265SlangRS::SlangRS()
Stephen Hines11274a72012-09-26 19:14:20 -0700266 : Slang(), mRSContext(NULL), mAllowRSPrefix(false), mTargetAPI(0),
267 mIsFilterscript(false) {
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800268}
269
Zonr Changcf6af6a2010-10-12 12:38:51 +0800270bool SlangRS::compile(
271 const std::list<std::pair<const char*, const char*> > &IOFiles,
272 const std::list<std::pair<const char*, const char*> > &DepFiles,
273 const std::vector<std::string> &IncludePaths,
274 const std::vector<std::string> &AdditionalDepTargets,
275 Slang::OutputType OutputType, BitCodeStorageType BitcodeStorage,
276 bool AllowRSPrefix, bool OutputDep,
mkopec1c460b372012-01-09 11:21:50 -0500277 unsigned int TargetAPI, bool EmitDebug,
278 llvm::CodeGenOpt::Level OptimizationLevel,
Zonr Changcf6af6a2010-10-12 12:38:51 +0800279 const std::string &JavaReflectionPathBase,
Stephen Hines0a813a32012-08-03 16:52:40 -0700280 const std::string &JavaReflectionPackageName,
281 const std::string &RSPackageName) {
Zonr Changcf6af6a2010-10-12 12:38:51 +0800282 if (IOFiles.empty())
283 return true;
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800284
Zonr Changcf6af6a2010-10-12 12:38:51 +0800285 if (OutputDep && (DepFiles.size() != IOFiles.size())) {
Zonr Chang641558f2010-10-12 21:07:06 +0800286 getDiagnostics().Report(mDiagErrorInvalidOutputDepParameter);
Zonr Changcf6af6a2010-10-12 12:38:51 +0800287 return false;
288 }
289
290 std::string RealPackageName;
291
292 const char *InputFile, *OutputFile, *BCOutputFile, *DepOutputFile;
293 std::list<std::pair<const char*, const char*> >::const_iterator
294 IOFileIter = IOFiles.begin(), DepFileIter = DepFiles.begin();
295
296 setIncludePaths(IncludePaths);
297 setOutputType(OutputType);
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800298 if (OutputDep) {
Zonr Changcf6af6a2010-10-12 12:38:51 +0800299 setAdditionalDepTargets(AdditionalDepTargets);
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800300 }
Zonr Changcf6af6a2010-10-12 12:38:51 +0800301
mkopec1c460b372012-01-09 11:21:50 -0500302 setDebugMetadataEmission(EmitDebug);
303
304 setOptimizationLevel(OptimizationLevel);
305
Zonr Changcf6af6a2010-10-12 12:38:51 +0800306 mAllowRSPrefix = AllowRSPrefix;
307
Stephen Hines2e35b132011-07-22 02:50:19 -0700308 mTargetAPI = TargetAPI;
Stephen Hines4cc499d2011-08-24 19:06:17 -0700309 if (mTargetAPI < SLANG_MINIMUM_TARGET_API ||
310 mTargetAPI > SLANG_MAXIMUM_TARGET_API) {
Stephen Hines2e35b132011-07-22 02:50:19 -0700311 getDiagnostics().Report(mDiagErrorTargetAPIRange) << mTargetAPI
Stephen Hines4cc499d2011-08-24 19:06:17 -0700312 << SLANG_MINIMUM_TARGET_API << SLANG_MAXIMUM_TARGET_API;
Stephen Hines2e35b132011-07-22 02:50:19 -0700313 return false;
314 }
315
Stephen Hinesc632be22011-09-23 15:53:16 -0700316 // Skip generation of warnings a second time if we are doing more than just
317 // a single pass over the input file.
318 bool SuppressAllWarnings = (OutputType != Slang::OT_Dependency);
319
Zonr Changcf6af6a2010-10-12 12:38:51 +0800320 for (unsigned i = 0, e = IOFiles.size(); i != e; i++) {
321 InputFile = IOFileIter->first;
322 OutputFile = IOFileIter->second;
323
324 reset();
325
326 if (!setInputSource(InputFile))
327 return false;
328
329 if (!setOutput(OutputFile))
330 return false;
331
Stephen Hines11274a72012-09-26 19:14:20 -0700332 mIsFilterscript = isFilterscript(InputFile);
333
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800334 if (Slang::compile() > 0)
335 return false;
336
Stephen Hines925879f2013-07-19 18:19:04 -0700337 if (!JavaReflectionPackageName.empty()) {
338 mRSContext->setReflectJavaPackageName(JavaReflectionPackageName);
339 }
340 const std::string &RealPackageName =
341 mRSContext->getReflectJavaPackageName();
342
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800343 if (OutputType != Slang::OT_Dependency) {
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800344
Stephen Hines5c25c512012-02-27 12:58:17 -0800345 if (BitcodeStorage == BCST_CPP_CODE) {
Jean-Luc Brouillet59f22c32014-06-04 14:53:48 -0700346 RSReflectionCpp R(mRSContext, JavaReflectionPathBase, getInputFileName(),
347 getOutputFileName());
348 if (!R.reflect()) {
Jason Sams1b6a0882012-03-12 15:07:58 -0700349 return false;
350 }
Stephen Hines5c25c512012-02-27 12:58:17 -0800351 } else {
Jean-Luc Brouillet12fc2832014-06-04 21:32:31 +0000352 if (!RSPackageName.empty()) {
353 mRSContext->setRSPackageName(RSPackageName);
354 }
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800355
Jean-Luc Brouillet59f22c32014-06-04 14:53:48 -0700356 RSReflectionJava R(mRSContext, &mGeneratedFileNames,
357 JavaReflectionPathBase, getInputFileName(),
358 getOutputFileName(),
359 BitcodeStorage == BCST_JAVA_CODE);
360 if (!R.reflect()) {
Jean-Luc Brouillet12fc2832014-06-04 21:32:31 +0000361 // TODO Is this needed or will the error message have been printed
362 // already? and why not for the C++ case?
363 fprintf(stderr, "RSContext::reflectToJava : failed to do reflection "
364 "(%s)\n",
365 R.getLastError());
Jean-Luc Brouillet7fda9842014-06-04 19:23:55 +0000366 return false;
Stephen Hines5c25c512012-02-27 12:58:17 -0800367 }
368
369 for (std::vector<std::string>::const_iterator
370 I = mGeneratedFileNames.begin(), E = mGeneratedFileNames.end();
371 I != E;
372 I++) {
373 std::string ReflectedName = RSSlangReflectUtils::ComputePackagedPath(
374 JavaReflectionPathBase.c_str(),
375 (RealPackageName + OS_PATH_SEPARATOR_STR + *I).c_str());
376 appendGeneratedFileName(ReflectedName + ".java");
377 }
378
379 if ((OutputType == Slang::OT_Bitcode) &&
380 (BitcodeStorage == BCST_JAVA_CODE) &&
Jean-Luc Brouillet129fd822014-05-28 17:46:10 -0700381 !generateJavaBitcodeAccessor(JavaReflectionPathBase,
382 RealPackageName.c_str(),
383 mRSContext->getLicenseNote())) {
Stephen Hines5c25c512012-02-27 12:58:17 -0800384 return false;
385 }
386 }
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800387 }
388
Zonr Changcf6af6a2010-10-12 12:38:51 +0800389 if (OutputDep) {
390 BCOutputFile = DepFileIter->first;
391 DepOutputFile = DepFileIter->second;
392
393 setDepTargetBC(BCOutputFile);
394
395 if (!setDepOutput(DepOutputFile))
396 return false;
397
Stephen Hinesc632be22011-09-23 15:53:16 -0700398 if (SuppressAllWarnings) {
399 getDiagnostics().setSuppressAllDiagnostics(true);
400 }
Zonr Changcf6af6a2010-10-12 12:38:51 +0800401 if (generateDepFile() > 0)
402 return false;
Stephen Hinesc632be22011-09-23 15:53:16 -0700403 if (SuppressAllWarnings) {
404 getDiagnostics().setSuppressAllDiagnostics(false);
405 }
Zonr Changcf6af6a2010-10-12 12:38:51 +0800406
407 DepFileIter++;
408 }
409
Zonr Change86245a2010-10-12 21:42:13 +0800410 if (!checkODR(InputFile))
Zonr Chang641558f2010-10-12 21:07:06 +0800411 return false;
412
Zonr Changcf6af6a2010-10-12 12:38:51 +0800413 IOFileIter++;
414 }
415
416 return true;
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800417}
418
Zonr Chang641558f2010-10-12 21:07:06 +0800419void SlangRS::reset() {
420 delete mRSContext;
421 mRSContext = NULL;
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800422 mGeneratedFileNames.clear();
Zonr Chang641558f2010-10-12 21:07:06 +0800423 Slang::reset();
Zonr Chang641558f2010-10-12 21:07:06 +0800424}
425
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800426SlangRS::~SlangRS() {
427 delete mRSContext;
Zonr Chang641558f2010-10-12 21:07:06 +0800428 for (ReflectedDefinitionListTy::iterator I = ReflectedDefinitions.begin(),
429 E = ReflectedDefinitions.end();
430 I != E;
431 I++) {
432 delete I->getValue().first;
433 }
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800434}
Stephen Hinese639eb52010-11-08 19:27:20 -0800435
436} // namespace slang