blob: eb2bdbbc2ee17760345f4871924687b4d80867a5 [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
Jason Sams1b6a0882012-03-12 15:07:58 -070039#include "slang_rs_reflection_cpp.h"
40
Stephen Hinese639eb52010-11-08 19:27:20 -080041namespace slang {
Zonr Chang3a9ca1f2010-10-06 17:52:56 +080042
Stephen Hines11274a72012-09-26 19:14:20 -070043#define FS_SUFFIX "fs"
44
Zonr Chang3c250c52010-10-07 12:19:23 +080045#define RS_HEADER_SUFFIX "rsh"
46
Stephen Hines2d35edd2011-08-09 11:33:27 -070047/* RS_HEADER_ENTRY(name) */
Zonr Chang3c250c52010-10-07 12:19:23 +080048#define ENUM_RS_HEADER() \
Stephen Hines2d35edd2011-08-09 11:33:27 -070049 RS_HEADER_ENTRY(rs_allocation) \
50 RS_HEADER_ENTRY(rs_atomic) \
51 RS_HEADER_ENTRY(rs_cl) \
52 RS_HEADER_ENTRY(rs_core) \
Stephen Hinesa7ab54d2014-01-08 09:41:49 -080053 RS_HEADER_ENTRY(rs_core_math) \
Stephen Hines2d35edd2011-08-09 11:33:27 -070054 RS_HEADER_ENTRY(rs_debug) \
Alex Sakhartchouk4eb4b382012-03-21 09:58:39 -070055 RS_HEADER_ENTRY(rs_element) \
Stephen Hines2d35edd2011-08-09 11:33:27 -070056 RS_HEADER_ENTRY(rs_graphics) \
57 RS_HEADER_ENTRY(rs_math) \
Alex Sakhartchouk4eb4b382012-03-21 09:58:39 -070058 RS_HEADER_ENTRY(rs_mesh) \
Stephen Hines2d35edd2011-08-09 11:33:27 -070059 RS_HEADER_ENTRY(rs_matrix) \
60 RS_HEADER_ENTRY(rs_object) \
Alex Sakhartchouk4eb4b382012-03-21 09:58:39 -070061 RS_HEADER_ENTRY(rs_program) \
Stephen Hines2d35edd2011-08-09 11:33:27 -070062 RS_HEADER_ENTRY(rs_quaternion) \
Alex Sakhartchouk4eb4b382012-03-21 09:58:39 -070063 RS_HEADER_ENTRY(rs_sampler) \
Stephen Hines2d35edd2011-08-09 11:33:27 -070064 RS_HEADER_ENTRY(rs_time) \
65 RS_HEADER_ENTRY(rs_types) \
66
Stephen Hines11274a72012-09-26 19:14:20 -070067// Returns true if \p Filename ends in ".fs".
68bool SlangRS::isFilterscript(const char *Filename) {
69 const char *c = strrchr(Filename, '.');
70 if (c && !strncmp(FS_SUFFIX, c + 1, strlen(FS_SUFFIX) + 1)) {
71 return true;
72 } else {
73 return false;
74 }
75}
Zonr Chang3c250c52010-10-07 12:19:23 +080076
Jean-Luc Brouillet7fda9842014-06-04 19:23:55 +000077bool SlangRS::reflectToJava(const std::string &OutputPathBase,
78 const std::string &RSPackageName,
79 bool EmbedBitcodeInJava) {
80 return mRSContext->reflectToJava(OutputPathBase,
81 RSPackageName,
82 getInputFileName(),
83 getOutputFileName(),
84 EmbedBitcodeInJava);
85}
86
Jean-Luc Brouillet129fd822014-05-28 17:46:10 -070087bool SlangRS::generateJavaBitcodeAccessor(const std::string &OutputPathBase,
Jean-Luc Brouillet7fda9842014-06-04 19:23:55 +000088 const std::string &PackageName,
89 const std::string *LicenseNote) {
Zonr Changcf6af6a2010-10-12 12:38:51 +080090 RSSlangReflectUtils::BitCodeAccessorContext BCAccessorContext;
91
92 BCAccessorContext.rsFileName = getInputFileName().c_str();
93 BCAccessorContext.bcFileName = getOutputFileName().c_str();
94 BCAccessorContext.reflectPath = OutputPathBase.c_str();
95 BCAccessorContext.packageName = PackageName.c_str();
Jean-Luc Brouillet129fd822014-05-28 17:46:10 -070096 BCAccessorContext.licenseNote = LicenseNote;
Zonr Changcf6af6a2010-10-12 12:38:51 +080097 BCAccessorContext.bcStorage = BCST_JAVA_CODE; // Must be BCST_JAVA_CODE
98
Jean-Luc Brouillet129fd822014-05-28 17:46:10 -070099 return RSSlangReflectUtils::GenerateJavaBitCodeAccessor(BCAccessorContext);
Zonr Changcf6af6a2010-10-12 12:38:51 +0800100}
101
Zonr Change86245a2010-10-12 21:42:13 +0800102bool SlangRS::checkODR(const char *CurInputFile) {
Zonr Chang641558f2010-10-12 21:07:06 +0800103 for (RSContext::ExportableList::iterator I = mRSContext->exportable_begin(),
104 E = mRSContext->exportable_end();
105 I != E;
106 I++) {
Stephen Hinesa858cb62011-01-17 12:17:51 -0800107 RSExportable *RSE = *I;
108 if (RSE->getKind() != RSExportable::EX_TYPE)
Zonr Chang641558f2010-10-12 21:07:06 +0800109 continue;
110
Stephen Hinesa858cb62011-01-17 12:17:51 -0800111 RSExportType *ET = static_cast<RSExportType *>(RSE);
Zonr Chang641558f2010-10-12 21:07:06 +0800112 if (ET->getClass() != RSExportType::ExportClassRecord)
113 continue;
114
115 RSExportRecordType *ERT = static_cast<RSExportRecordType *>(ET);
116
117 // Artificial record types (create by us not by user in the source) always
118 // conforms the ODR.
119 if (ERT->isArtificial())
120 continue;
121
122 // Key to lookup ERT in ReflectedDefinitions
123 llvm::StringRef RDKey(ERT->getName());
124 ReflectedDefinitionListTy::const_iterator RD =
125 ReflectedDefinitions.find(RDKey);
126
127 if (RD != ReflectedDefinitions.end()) {
128 const RSExportRecordType *Reflected = RD->getValue().first;
129 // There's a record (struct) with the same name reflected before. Enforce
130 // ODR checking - the Reflected must hold *exactly* the same "definition"
131 // as the one defined previously. We say two record types A and B have the
132 // same definition iff:
133 //
134 // struct A { struct B {
135 // Type(a1) a1, Type(b1) b1,
136 // Type(a2) a2, Type(b1) b2,
137 // ... ...
138 // Type(aN) aN Type(b3) b3,
139 // }; }
140 // Cond. #1. They have same number of fields, i.e., N = M;
141 // Cond. #2. for (i := 1 to N)
142 // Type(ai) = Type(bi) must hold;
143 // Cond. #3. for (i := 1 to N)
144 // Name(ai) = Name(bi) must hold;
145 //
146 // where,
147 // Type(F) = the type of field F and
148 // Name(F) = the field name.
149
150 bool PassODR = false;
151 // Cond. #1 and Cond. #2
152 if (Reflected->equals(ERT)) {
153 // Cond #3.
154 RSExportRecordType::const_field_iterator AI = Reflected->fields_begin(),
155 BI = ERT->fields_begin();
156
157 for (unsigned i = 0, e = Reflected->getFields().size(); i != e; i++) {
158 if ((*AI)->getName() != (*BI)->getName())
159 break;
160 AI++;
161 BI++;
162 }
163 PassODR = (AI == (Reflected->fields_end()));
164 }
165
166 if (!PassODR) {
167 getDiagnostics().Report(mDiagErrorODR) << Reflected->getName()
168 << getInputFileName()
169 << RD->getValue().second;
170 return false;
171 }
172 } else {
173 llvm::StringMapEntry<ReflectedDefinitionTy> *ME =
174 llvm::StringMapEntry<ReflectedDefinitionTy>::Create(RDKey.begin(),
175 RDKey.end());
Zonr Change86245a2010-10-12 21:42:13 +0800176 ME->setValue(std::make_pair(ERT, CurInputFile));
Zonr Chang641558f2010-10-12 21:07:06 +0800177
178 if (!ReflectedDefinitions.insert(ME))
179 delete ME;
180
181 // Take the ownership of ERT such that it won't be freed in ~RSContext().
182 ERT->keep();
183 }
Zonr Chang641558f2010-10-12 21:07:06 +0800184 }
185 return true;
186}
Zonr Changcf6af6a2010-10-12 12:38:51 +0800187
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800188void SlangRS::initDiagnostic() {
Logan Chien9207a2e2011-10-21 15:39:28 +0800189 clang::DiagnosticsEngine &DiagEngine = getDiagnostics();
Zonr Changcf6af6a2010-10-12 12:38:51 +0800190
Logan Chien9207a2e2011-10-21 15:39:28 +0800191 if (DiagEngine.setDiagnosticGroupMapping("implicit-function-declaration",
192 clang::diag::MAP_ERROR))
193 DiagEngine.Report(clang::diag::warn_unknown_warning_option)
194 << "implicit-function-declaration";
195
196 DiagEngine.setDiagnosticMapping(
197 clang::diag::ext_typecheck_convert_discards_qualifiers,
198 clang::diag::MAP_ERROR,
199 clang::SourceLocation());
Zonr Chang641558f2010-10-12 21:07:06 +0800200
201 mDiagErrorInvalidOutputDepParameter =
Logan Chien9207a2e2011-10-21 15:39:28 +0800202 DiagEngine.getCustomDiagID(
203 clang::DiagnosticsEngine::Error,
204 "invalid parameter for output dependencies files.");
Zonr Chang641558f2010-10-12 21:07:06 +0800205
206 mDiagErrorODR =
Logan Chien9207a2e2011-10-21 15:39:28 +0800207 DiagEngine.getCustomDiagID(
208 clang::DiagnosticsEngine::Error,
209 "type '%0' in different translation unit (%1 v.s. %2) "
210 "has incompatible type definition");
Zonr Chang641558f2010-10-12 21:07:06 +0800211
Logan Chien9207a2e2011-10-21 15:39:28 +0800212 mDiagErrorTargetAPIRange =
213 DiagEngine.getCustomDiagID(
214 clang::DiagnosticsEngine::Error,
Stephen Hines2e35b132011-07-22 02:50:19 -0700215 "target API level '%0' is out of range ('%1' - '%2')");
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800216}
217
218void SlangRS::initPreprocessor() {
219 clang::Preprocessor &PP = getPreprocessor();
220
Stephen Hines2e35b132011-07-22 02:50:19 -0700221 std::stringstream RSH;
Jean-Luc Brouillet29689212014-05-27 13:25:31 -0700222 RSH << "#define RS_VERSION " << mTargetAPI << "\n";
223 RSH << "#include \"rs_core." RS_HEADER_SUFFIX "\"\n";
Stephen Hines2e35b132011-07-22 02:50:19 -0700224 PP.setPredefines(RSH.str());
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800225}
226
227void SlangRS::initASTContext() {
Stephen Hines9e5b5032010-11-03 13:19:14 -0700228 mRSContext = new RSContext(getPreprocessor(),
229 getASTContext(),
Stephen Hines3fd0a942011-01-18 12:27:39 -0800230 getTargetInfo(),
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800231 &mPragmas,
Stephen Hines4a4bf922011-08-18 17:20:33 -0700232 mTargetAPI,
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800233 &mGeneratedFileNames);
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800234}
235
236clang::ASTConsumer
237*SlangRS::createBackend(const clang::CodeGenOptions& CodeGenOpts,
238 llvm::raw_ostream *OS,
239 Slang::OutputType OT) {
240 return new RSBackend(mRSContext,
Stephen Hinese639eb52010-11-08 19:27:20 -0800241 &getDiagnostics(),
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800242 CodeGenOpts,
243 getTargetOptions(),
Stephen Hines3fd0a942011-01-18 12:27:39 -0800244 &mPragmas,
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800245 OS,
246 OT,
247 getSourceManager(),
Stephen Hines11274a72012-09-26 19:14:20 -0700248 mAllowRSPrefix,
249 mIsFilterscript);
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800250}
251
Zonr Chang592a9542010-10-07 20:03:58 +0800252bool SlangRS::IsRSHeaderFile(const char *File) {
Stephen Hines2d35edd2011-08-09 11:33:27 -0700253#define RS_HEADER_ENTRY(name) \
Tim Murrayee4016d2014-04-10 15:49:08 -0700254 if (::strcmp(File, #name "." RS_HEADER_SUFFIX) == 0) \
Zonr Chang592a9542010-10-07 20:03:58 +0800255 return true;
256ENUM_RS_HEADER()
257#undef RS_HEADER_ENTRY
Zonr Chang592a9542010-10-07 20:03:58 +0800258 return false;
259}
260
Stephen Hines11274a72012-09-26 19:14:20 -0700261bool SlangRS::IsLocInRSHeaderFile(const clang::SourceLocation &Loc,
262 const clang::SourceManager &SourceMgr) {
263 clang::FullSourceLoc FSL(Loc, SourceMgr);
Stephen Hinesfcda2352010-10-19 16:49:32 -0700264 clang::PresumedLoc PLoc = SourceMgr.getPresumedLoc(FSL);
Stephen Hinesfcda2352010-10-19 16:49:32 -0700265
Stephen Hines688e64b2011-08-23 16:01:25 -0700266 const char *Filename = PLoc.getFilename();
267 if (!Filename) {
268 return false;
269 } else {
270 return IsRSHeaderFile(llvm::sys::path::filename(Filename).data());
271 }
Stephen Hinesfcda2352010-10-19 16:49:32 -0700272}
273
Logan Chien9207a2e2011-10-21 15:39:28 +0800274SlangRS::SlangRS()
Stephen Hines11274a72012-09-26 19:14:20 -0700275 : Slang(), mRSContext(NULL), mAllowRSPrefix(false), mTargetAPI(0),
276 mIsFilterscript(false) {
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800277}
278
Zonr Changcf6af6a2010-10-12 12:38:51 +0800279bool SlangRS::compile(
280 const std::list<std::pair<const char*, const char*> > &IOFiles,
281 const std::list<std::pair<const char*, const char*> > &DepFiles,
282 const std::vector<std::string> &IncludePaths,
283 const std::vector<std::string> &AdditionalDepTargets,
284 Slang::OutputType OutputType, BitCodeStorageType BitcodeStorage,
285 bool AllowRSPrefix, bool OutputDep,
mkopec1c460b372012-01-09 11:21:50 -0500286 unsigned int TargetAPI, bool EmitDebug,
287 llvm::CodeGenOpt::Level OptimizationLevel,
Zonr Changcf6af6a2010-10-12 12:38:51 +0800288 const std::string &JavaReflectionPathBase,
Stephen Hines0a813a32012-08-03 16:52:40 -0700289 const std::string &JavaReflectionPackageName,
290 const std::string &RSPackageName) {
Zonr Changcf6af6a2010-10-12 12:38:51 +0800291 if (IOFiles.empty())
292 return true;
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800293
Zonr Changcf6af6a2010-10-12 12:38:51 +0800294 if (OutputDep && (DepFiles.size() != IOFiles.size())) {
Zonr Chang641558f2010-10-12 21:07:06 +0800295 getDiagnostics().Report(mDiagErrorInvalidOutputDepParameter);
Zonr Changcf6af6a2010-10-12 12:38:51 +0800296 return false;
297 }
298
299 std::string RealPackageName;
300
301 const char *InputFile, *OutputFile, *BCOutputFile, *DepOutputFile;
302 std::list<std::pair<const char*, const char*> >::const_iterator
303 IOFileIter = IOFiles.begin(), DepFileIter = DepFiles.begin();
304
305 setIncludePaths(IncludePaths);
306 setOutputType(OutputType);
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800307 if (OutputDep) {
Zonr Changcf6af6a2010-10-12 12:38:51 +0800308 setAdditionalDepTargets(AdditionalDepTargets);
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800309 }
Zonr Changcf6af6a2010-10-12 12:38:51 +0800310
mkopec1c460b372012-01-09 11:21:50 -0500311 setDebugMetadataEmission(EmitDebug);
312
313 setOptimizationLevel(OptimizationLevel);
314
Zonr Changcf6af6a2010-10-12 12:38:51 +0800315 mAllowRSPrefix = AllowRSPrefix;
316
Stephen Hines2e35b132011-07-22 02:50:19 -0700317 mTargetAPI = TargetAPI;
Stephen Hines4cc499d2011-08-24 19:06:17 -0700318 if (mTargetAPI < SLANG_MINIMUM_TARGET_API ||
319 mTargetAPI > SLANG_MAXIMUM_TARGET_API) {
Stephen Hines2e35b132011-07-22 02:50:19 -0700320 getDiagnostics().Report(mDiagErrorTargetAPIRange) << mTargetAPI
Stephen Hines4cc499d2011-08-24 19:06:17 -0700321 << SLANG_MINIMUM_TARGET_API << SLANG_MAXIMUM_TARGET_API;
Stephen Hines2e35b132011-07-22 02:50:19 -0700322 return false;
323 }
324
Stephen Hinesc632be22011-09-23 15:53:16 -0700325 // Skip generation of warnings a second time if we are doing more than just
326 // a single pass over the input file.
327 bool SuppressAllWarnings = (OutputType != Slang::OT_Dependency);
328
Zonr Changcf6af6a2010-10-12 12:38:51 +0800329 for (unsigned i = 0, e = IOFiles.size(); i != e; i++) {
330 InputFile = IOFileIter->first;
331 OutputFile = IOFileIter->second;
332
333 reset();
334
335 if (!setInputSource(InputFile))
336 return false;
337
338 if (!setOutput(OutputFile))
339 return false;
340
Stephen Hines11274a72012-09-26 19:14:20 -0700341 mIsFilterscript = isFilterscript(InputFile);
342
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800343 if (Slang::compile() > 0)
344 return false;
345
Stephen Hines925879f2013-07-19 18:19:04 -0700346 if (!JavaReflectionPackageName.empty()) {
347 mRSContext->setReflectJavaPackageName(JavaReflectionPackageName);
348 }
349 const std::string &RealPackageName =
350 mRSContext->getReflectJavaPackageName();
351
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800352 if (OutputType != Slang::OT_Dependency) {
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800353
Stephen Hines5c25c512012-02-27 12:58:17 -0800354 if (BitcodeStorage == BCST_CPP_CODE) {
Jason Sams1b6a0882012-03-12 15:07:58 -0700355 RSReflectionCpp R(mRSContext);
356 bool ret = R.reflect(JavaReflectionPathBase, getInputFileName(), getOutputFileName());
357 if (!ret) {
358 return false;
359 }
Stephen Hines5c25c512012-02-27 12:58:17 -0800360 } else {
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800361
Jean-Luc Brouillet7fda9842014-06-04 19:23:55 +0000362 if (!reflectToJava(JavaReflectionPathBase, RSPackageName, (BitcodeStorage == BCST_JAVA_CODE))) {
363 return false;
Stephen Hines5c25c512012-02-27 12:58:17 -0800364 }
365
366 for (std::vector<std::string>::const_iterator
367 I = mGeneratedFileNames.begin(), E = mGeneratedFileNames.end();
368 I != E;
369 I++) {
370 std::string ReflectedName = RSSlangReflectUtils::ComputePackagedPath(
371 JavaReflectionPathBase.c_str(),
372 (RealPackageName + OS_PATH_SEPARATOR_STR + *I).c_str());
373 appendGeneratedFileName(ReflectedName + ".java");
374 }
375
376 if ((OutputType == Slang::OT_Bitcode) &&
377 (BitcodeStorage == BCST_JAVA_CODE) &&
Jean-Luc Brouillet129fd822014-05-28 17:46:10 -0700378 !generateJavaBitcodeAccessor(JavaReflectionPathBase,
379 RealPackageName.c_str(),
380 mRSContext->getLicenseNote())) {
Stephen Hines5c25c512012-02-27 12:58:17 -0800381 return false;
382 }
383 }
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800384 }
385
Zonr Changcf6af6a2010-10-12 12:38:51 +0800386 if (OutputDep) {
387 BCOutputFile = DepFileIter->first;
388 DepOutputFile = DepFileIter->second;
389
390 setDepTargetBC(BCOutputFile);
391
392 if (!setDepOutput(DepOutputFile))
393 return false;
394
Stephen Hinesc632be22011-09-23 15:53:16 -0700395 if (SuppressAllWarnings) {
396 getDiagnostics().setSuppressAllDiagnostics(true);
397 }
Zonr Changcf6af6a2010-10-12 12:38:51 +0800398 if (generateDepFile() > 0)
399 return false;
Stephen Hinesc632be22011-09-23 15:53:16 -0700400 if (SuppressAllWarnings) {
401 getDiagnostics().setSuppressAllDiagnostics(false);
402 }
Zonr Changcf6af6a2010-10-12 12:38:51 +0800403
404 DepFileIter++;
405 }
406
Zonr Change86245a2010-10-12 21:42:13 +0800407 if (!checkODR(InputFile))
Zonr Chang641558f2010-10-12 21:07:06 +0800408 return false;
409
Zonr Changcf6af6a2010-10-12 12:38:51 +0800410 IOFileIter++;
411 }
412
413 return true;
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800414}
415
Zonr Chang641558f2010-10-12 21:07:06 +0800416void SlangRS::reset() {
417 delete mRSContext;
418 mRSContext = NULL;
Stephen Hines4cc67fc2011-01-31 16:48:57 -0800419 mGeneratedFileNames.clear();
Zonr Chang641558f2010-10-12 21:07:06 +0800420 Slang::reset();
Zonr Chang641558f2010-10-12 21:07:06 +0800421}
422
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800423SlangRS::~SlangRS() {
424 delete mRSContext;
Zonr Chang641558f2010-10-12 21:07:06 +0800425 for (ReflectedDefinitionListTy::iterator I = ReflectedDefinitions.begin(),
426 E = ReflectedDefinitions.end();
427 I != E;
428 I++) {
429 delete I->getValue().first;
430 }
Zonr Chang3a9ca1f2010-10-06 17:52:56 +0800431}
Stephen Hinese639eb52010-11-08 19:27:20 -0800432
433} // namespace slang