blob: 5a30de3768b14ad2f8992de6638bd9be59fae729 [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;
Jean-Luc Brouillet29689212014-05-27 13:25:31 -0700213 RSH << "#define RS_VERSION " << mTargetAPI << "\n";
214 RSH << "#include \"rs_core." RS_HEADER_SUFFIX "\"\n";
Stephen Hines2e35b132011-07-22 02:50:19 -0700215 PP.setPredefines(RSH.str());
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800216}
217
218void SlangRS::initASTContext() {
Stephen Hines9e5b5032010-11-03 13:19:14 -0700219 mRSContext = new RSContext(getPreprocessor(),
220 getASTContext(),
Stephen Hines3fd0a942011-01-18 12:27:39 -0800221 getTargetInfo(),
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800222 &mPragmas,
Jean-Luc Brouillet12fc2832014-06-04 21:32:31 +0000223 mTargetAPI);
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800224}
225
226clang::ASTConsumer
227*SlangRS::createBackend(const clang::CodeGenOptions& CodeGenOpts,
228 llvm::raw_ostream *OS,
229 Slang::OutputType OT) {
230 return new RSBackend(mRSContext,
Stephen Hinese639eb52010-11-08 19:27:20 -0800231 &getDiagnostics(),
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800232 CodeGenOpts,
233 getTargetOptions(),
Stephen Hines3fd0a942011-01-18 12:27:39 -0800234 &mPragmas,
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800235 OS,
236 OT,
237 getSourceManager(),
Stephen Hines11274a72012-09-26 19:14:20 -0700238 mAllowRSPrefix,
239 mIsFilterscript);
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800240}
241
Zonr Chang592a9542010-10-07 20:03:58 +0800242bool SlangRS::IsRSHeaderFile(const char *File) {
Stephen Hines2d35edd2011-08-09 11:33:27 -0700243#define RS_HEADER_ENTRY(name) \
Tim Murrayee4016d2014-04-10 15:49:08 -0700244 if (::strcmp(File, #name "." RS_HEADER_SUFFIX) == 0) \
Zonr Chang592a9542010-10-07 20:03:58 +0800245 return true;
246ENUM_RS_HEADER()
247#undef RS_HEADER_ENTRY
Zonr Chang592a9542010-10-07 20:03:58 +0800248 return false;
249}
250
Stephen Hines11274a72012-09-26 19:14:20 -0700251bool SlangRS::IsLocInRSHeaderFile(const clang::SourceLocation &Loc,
252 const clang::SourceManager &SourceMgr) {
253 clang::FullSourceLoc FSL(Loc, SourceMgr);
Stephen Hinesfcda2352010-10-19 16:49:32 -0700254 clang::PresumedLoc PLoc = SourceMgr.getPresumedLoc(FSL);
Stephen Hinesfcda2352010-10-19 16:49:32 -0700255
Stephen Hines688e64b2011-08-23 16:01:25 -0700256 const char *Filename = PLoc.getFilename();
257 if (!Filename) {
258 return false;
259 } else {
260 return IsRSHeaderFile(llvm::sys::path::filename(Filename).data());
261 }
Stephen Hinesfcda2352010-10-19 16:49:32 -0700262}
263
Logan Chien9207a2e2011-10-21 15:39:28 +0800264SlangRS::SlangRS()
Stephen Hines11274a72012-09-26 19:14:20 -0700265 : Slang(), mRSContext(NULL), mAllowRSPrefix(false), mTargetAPI(0),
266 mIsFilterscript(false) {
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800267}
268
Zonr Changcf6af6a2010-10-12 12:38:51 +0800269bool SlangRS::compile(
270 const std::list<std::pair<const char*, const char*> > &IOFiles,
271 const std::list<std::pair<const char*, const char*> > &DepFiles,
272 const std::vector<std::string> &IncludePaths,
273 const std::vector<std::string> &AdditionalDepTargets,
274 Slang::OutputType OutputType, BitCodeStorageType BitcodeStorage,
275 bool AllowRSPrefix, bool OutputDep,
mkopec1c460b372012-01-09 11:21:50 -0500276 unsigned int TargetAPI, bool EmitDebug,
277 llvm::CodeGenOpt::Level OptimizationLevel,
Zonr Changcf6af6a2010-10-12 12:38:51 +0800278 const std::string &JavaReflectionPathBase,
Stephen Hines0a813a32012-08-03 16:52:40 -0700279 const std::string &JavaReflectionPackageName,
280 const std::string &RSPackageName) {
Zonr Changcf6af6a2010-10-12 12:38:51 +0800281 if (IOFiles.empty())
282 return true;
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800283
Zonr Changcf6af6a2010-10-12 12:38:51 +0800284 if (OutputDep && (DepFiles.size() != IOFiles.size())) {
Zonr Chang641558f2010-10-12 21:07:06 +0800285 getDiagnostics().Report(mDiagErrorInvalidOutputDepParameter);
Zonr Changcf6af6a2010-10-12 12:38:51 +0800286 return false;
287 }
288
289 std::string RealPackageName;
290
291 const char *InputFile, *OutputFile, *BCOutputFile, *DepOutputFile;
292 std::list<std::pair<const char*, const char*> >::const_iterator
293 IOFileIter = IOFiles.begin(), DepFileIter = DepFiles.begin();
294
295 setIncludePaths(IncludePaths);
296 setOutputType(OutputType);
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800297 if (OutputDep) {
Zonr Changcf6af6a2010-10-12 12:38:51 +0800298 setAdditionalDepTargets(AdditionalDepTargets);
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800299 }
Zonr Changcf6af6a2010-10-12 12:38:51 +0800300
mkopec1c460b372012-01-09 11:21:50 -0500301 setDebugMetadataEmission(EmitDebug);
302
303 setOptimizationLevel(OptimizationLevel);
304
Zonr Changcf6af6a2010-10-12 12:38:51 +0800305 mAllowRSPrefix = AllowRSPrefix;
306
Stephen Hines2e35b132011-07-22 02:50:19 -0700307 mTargetAPI = TargetAPI;
Stephen Hines4cc499d2011-08-24 19:06:17 -0700308 if (mTargetAPI < SLANG_MINIMUM_TARGET_API ||
309 mTargetAPI > SLANG_MAXIMUM_TARGET_API) {
Stephen Hines2e35b132011-07-22 02:50:19 -0700310 getDiagnostics().Report(mDiagErrorTargetAPIRange) << mTargetAPI
Stephen Hines4cc499d2011-08-24 19:06:17 -0700311 << SLANG_MINIMUM_TARGET_API << SLANG_MAXIMUM_TARGET_API;
Stephen Hines2e35b132011-07-22 02:50:19 -0700312 return false;
313 }
314
Stephen Hinesc632be22011-09-23 15:53:16 -0700315 // Skip generation of warnings a second time if we are doing more than just
316 // a single pass over the input file.
317 bool SuppressAllWarnings = (OutputType != Slang::OT_Dependency);
318
Zonr Changcf6af6a2010-10-12 12:38:51 +0800319 for (unsigned i = 0, e = IOFiles.size(); i != e; i++) {
320 InputFile = IOFileIter->first;
321 OutputFile = IOFileIter->second;
322
323 reset();
324
325 if (!setInputSource(InputFile))
326 return false;
327
328 if (!setOutput(OutputFile))
329 return false;
330
Stephen Hines11274a72012-09-26 19:14:20 -0700331 mIsFilterscript = isFilterscript(InputFile);
332
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800333 if (Slang::compile() > 0)
334 return false;
335
Stephen Hines925879f2013-07-19 18:19:04 -0700336 if (!JavaReflectionPackageName.empty()) {
337 mRSContext->setReflectJavaPackageName(JavaReflectionPackageName);
338 }
339 const std::string &RealPackageName =
340 mRSContext->getReflectJavaPackageName();
341
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800342 if (OutputType != Slang::OT_Dependency) {
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800343
Stephen Hines5c25c512012-02-27 12:58:17 -0800344 if (BitcodeStorage == BCST_CPP_CODE) {
Jean-Luc Brouillet59f22c32014-06-04 14:53:48 -0700345 RSReflectionCpp R(mRSContext, JavaReflectionPathBase, getInputFileName(),
346 getOutputFileName());
347 if (!R.reflect()) {
Jason Sams1b6a0882012-03-12 15:07:58 -0700348 return false;
349 }
Stephen Hines5c25c512012-02-27 12:58:17 -0800350 } else {
Jean-Luc Brouillet12fc2832014-06-04 21:32:31 +0000351 if (!RSPackageName.empty()) {
352 mRSContext->setRSPackageName(RSPackageName);
353 }
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800354
Jean-Luc Brouillet59f22c32014-06-04 14:53:48 -0700355 RSReflectionJava R(mRSContext, &mGeneratedFileNames,
356 JavaReflectionPathBase, getInputFileName(),
357 getOutputFileName(),
358 BitcodeStorage == BCST_JAVA_CODE);
359 if (!R.reflect()) {
Jean-Luc Brouillet12fc2832014-06-04 21:32:31 +0000360 // TODO Is this needed or will the error message have been printed
361 // already? and why not for the C++ case?
362 fprintf(stderr, "RSContext::reflectToJava : failed to do reflection "
363 "(%s)\n",
364 R.getLastError());
Jean-Luc Brouillet7fda9842014-06-04 19:23:55 +0000365 return false;
Stephen Hines5c25c512012-02-27 12:58:17 -0800366 }
367
368 for (std::vector<std::string>::const_iterator
369 I = mGeneratedFileNames.begin(), E = mGeneratedFileNames.end();
370 I != E;
371 I++) {
372 std::string ReflectedName = RSSlangReflectUtils::ComputePackagedPath(
373 JavaReflectionPathBase.c_str(),
374 (RealPackageName + OS_PATH_SEPARATOR_STR + *I).c_str());
375 appendGeneratedFileName(ReflectedName + ".java");
376 }
377
378 if ((OutputType == Slang::OT_Bitcode) &&
379 (BitcodeStorage == BCST_JAVA_CODE) &&
Jean-Luc Brouillet129fd822014-05-28 17:46:10 -0700380 !generateJavaBitcodeAccessor(JavaReflectionPathBase,
381 RealPackageName.c_str(),
382 mRSContext->getLicenseNote())) {
Stephen Hines5c25c512012-02-27 12:58:17 -0800383 return false;
384 }
385 }
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800386 }
387
Zonr Changcf6af6a2010-10-12 12:38:51 +0800388 if (OutputDep) {
389 BCOutputFile = DepFileIter->first;
390 DepOutputFile = DepFileIter->second;
391
392 setDepTargetBC(BCOutputFile);
393
394 if (!setDepOutput(DepOutputFile))
395 return false;
396
Stephen Hinesc632be22011-09-23 15:53:16 -0700397 if (SuppressAllWarnings) {
398 getDiagnostics().setSuppressAllDiagnostics(true);
399 }
Zonr Changcf6af6a2010-10-12 12:38:51 +0800400 if (generateDepFile() > 0)
401 return false;
Stephen Hinesc632be22011-09-23 15:53:16 -0700402 if (SuppressAllWarnings) {
403 getDiagnostics().setSuppressAllDiagnostics(false);
404 }
Zonr Changcf6af6a2010-10-12 12:38:51 +0800405
406 DepFileIter++;
407 }
408
Zonr Change86245a2010-10-12 21:42:13 +0800409 if (!checkODR(InputFile))
Zonr Chang641558f2010-10-12 21:07:06 +0800410 return false;
411
Zonr Changcf6af6a2010-10-12 12:38:51 +0800412 IOFileIter++;
413 }
414
415 return true;
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800416}
417
Zonr Chang641558f2010-10-12 21:07:06 +0800418void SlangRS::reset() {
419 delete mRSContext;
420 mRSContext = NULL;
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800421 mGeneratedFileNames.clear();
Zonr Chang641558f2010-10-12 21:07:06 +0800422 Slang::reset();
Zonr Chang641558f2010-10-12 21:07:06 +0800423}
424
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800425SlangRS::~SlangRS() {
426 delete mRSContext;
Zonr Chang641558f2010-10-12 21:07:06 +0800427 for (ReflectedDefinitionListTy::iterator I = ReflectedDefinitions.begin(),
428 E = ReflectedDefinitions.end();
429 I != E;
430 I++) {
431 delete I->getValue().first;
432 }
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800433}
Stephen Hinese639eb52010-11-08 19:27:20 -0800434
435} // namespace slang