Zonr Chang | c383a50 | 2010-10-12 01:52:08 +0800 | [diff] [blame] | 1 | /* |
Stephen Hines | 9999ec3 | 2012-02-10 18:22:14 -0800 | [diff] [blame] | 2 | * Copyright 2010-2012, The Android Open Source Project |
Zonr Chang | c383a50 | 2010-10-12 01:52:08 +0800 | [diff] [blame] | 3 | * |
| 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 | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 17 | #include "slang_rs_context.h" |
| 18 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 19 | #include <string> |
| 20 | |
| 21 | #include "clang/AST/ASTContext.h" |
| 22 | #include "clang/AST/Decl.h" |
| 23 | #include "clang/AST/DeclBase.h" |
Logan | be27482 | 2011-02-16 22:02:54 +0800 | [diff] [blame] | 24 | #include "clang/AST/Mangle.h" |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 25 | #include "clang/AST/Type.h" |
| 26 | |
| 27 | #include "clang/Basic/Linkage.h" |
| 28 | #include "clang/Basic/TargetInfo.h" |
| 29 | |
Stephen Hines | 23c4358 | 2013-01-09 20:02:04 -0800 | [diff] [blame] | 30 | #include "llvm/IR/LLVMContext.h" |
| 31 | #include "llvm/IR/DataLayout.h" |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 32 | |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 33 | #include "slang.h" |
Stephen Hines | 6e6578a | 2011-02-07 18:05:48 -0800 | [diff] [blame] | 34 | #include "slang_assert.h" |
Stephen Hines | 593a894 | 2011-05-10 15:29:50 -0700 | [diff] [blame] | 35 | #include "slang_rs_export_foreach.h" |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 36 | #include "slang_rs_export_func.h" |
| 37 | #include "slang_rs_export_type.h" |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 38 | #include "slang_rs_export_var.h" |
| 39 | #include "slang_rs_exportable.h" |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 40 | #include "slang_rs_pragma_handler.h" |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 41 | #include "slang_rs_reflection.h" |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 42 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 43 | namespace slang { |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 44 | |
Stephen Hines | 9e5b503 | 2010-11-03 13:19:14 -0700 | [diff] [blame] | 45 | RSContext::RSContext(clang::Preprocessor &PP, |
| 46 | clang::ASTContext &Ctx, |
Stephen Hines | 3fd0a94 | 2011-01-18 12:27:39 -0800 | [diff] [blame] | 47 | const clang::TargetInfo &Target, |
Stephen Hines | 4cc67fc | 2011-01-31 16:48:57 -0800 | [diff] [blame] | 48 | PragmaList *Pragmas, |
Stephen Hines | fc4f78b | 2014-06-10 18:07:10 -0700 | [diff] [blame] | 49 | unsigned int TargetAPI, |
| 50 | bool Verbose) |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 51 | : mPP(PP), |
| 52 | mCtx(Ctx), |
Stephen Hines | 3fd0a94 | 2011-01-18 12:27:39 -0800 | [diff] [blame] | 53 | mPragmas(Pragmas), |
Stephen Hines | 4a4bf92 | 2011-08-18 17:20:33 -0700 | [diff] [blame] | 54 | mTargetAPI(TargetAPI), |
Stephen Hines | fc4f78b | 2014-06-10 18:07:10 -0700 | [diff] [blame] | 55 | mVerbose(Verbose), |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 56 | mDataLayout(nullptr), |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 57 | mLLVMContext(llvm::getGlobalContext()), |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 58 | mLicenseNote(nullptr), |
Stephen Hines | 0a813a3 | 2012-08-03 16:52:40 -0700 | [diff] [blame] | 59 | mRSPackageName("android.renderscript"), |
Shih-wei Liao | 3fa286b | 2011-02-10 11:04:44 -0800 | [diff] [blame] | 60 | version(0), |
Stephen Hines | 9ae18b2 | 2014-06-10 23:53:00 -0700 | [diff] [blame] | 61 | mMangleCtx(Ctx.createMangleContext()), |
| 62 | mIs64Bit(Target.getPointerWidth(0) == 64) { |
Stephen Hines | 4cc67fc | 2011-01-31 16:48:57 -0800 | [diff] [blame] | 63 | |
Jean-Luc Brouillet | 109e90a | 2014-07-07 17:36:07 -0700 | [diff] [blame] | 64 | AddPragmaHandlers(PP, this); |
Stephen Hines | 96ab06c | 2011-01-05 15:29:26 -0800 | [diff] [blame] | 65 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 66 | // Prepare target data |
Stephen Hines | 23c4358 | 2013-01-09 20:02:04 -0800 | [diff] [blame] | 67 | mDataLayout = new llvm::DataLayout(Target.getTargetDescription()); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 70 | bool RSContext::processExportVar(const clang::VarDecl *VD) { |
Stephen Hines | 6e6578a | 2011-02-07 18:05:48 -0800 | [diff] [blame] | 71 | slangAssert(!VD->getName().empty() && "Variable name should not be empty"); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 72 | |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 73 | // TODO(zonr): some check on variable |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 74 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 75 | RSExportType *ET = RSExportType::CreateFromDecl(this, VD); |
| 76 | if (!ET) |
| 77 | return false; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 78 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 79 | RSExportVar *EV = new RSExportVar(this, VD, ET); |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 80 | if (EV == nullptr) |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 81 | return false; |
| 82 | else |
| 83 | mExportVars.push_back(EV); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 84 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 85 | return true; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 86 | } |
| 87 | |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 88 | bool RSContext::processExportFunc(const clang::FunctionDecl *FD) { |
Stephen Hines | 6e6578a | 2011-02-07 18:05:48 -0800 | [diff] [blame] | 89 | slangAssert(!FD->getName().empty() && "Function name should not be empty"); |
Shih-wei Liao | 537446c | 2010-06-11 16:05:55 -0700 | [diff] [blame] | 90 | |
Stephen Hines | 3fbe68a | 2010-11-17 17:28:59 -0800 | [diff] [blame] | 91 | if (!FD->isThisDeclarationADefinition()) { |
| 92 | return true; |
| 93 | } |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 94 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 95 | if (FD->getStorageClass() != clang::SC_None) { |
| 96 | fprintf(stderr, "RSContext::processExportFunc : cannot export extern or " |
| 97 | "static function '%s'\n", FD->getName().str().c_str()); |
| 98 | return false; |
| 99 | } |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 100 | |
Stephen Hines | 9999ec3 | 2012-02-10 18:22:14 -0800 | [diff] [blame] | 101 | if (RSExportForEach::isSpecialRSFunc(mTargetAPI, FD)) { |
| 102 | // Do not reflect specialized functions like init, dtor, or graphics root. |
Jean-Luc Brouillet | d3f7527 | 2014-01-16 18:20:28 -0800 | [diff] [blame] | 103 | return RSExportForEach::validateSpecialFuncDecl(mTargetAPI, this, FD); |
| 104 | } else if (RSExportForEach::isRSForEachFunc(mTargetAPI, this, FD)) { |
Stephen Hines | 593a894 | 2011-05-10 15:29:50 -0700 | [diff] [blame] | 105 | RSExportForEach *EFE = RSExportForEach::Create(this, FD); |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 106 | if (EFE == nullptr) |
Stephen Hines | 593a894 | 2011-05-10 15:29:50 -0700 | [diff] [blame] | 107 | return false; |
| 108 | else |
| 109 | mExportForEach.push_back(EFE); |
| 110 | return true; |
Stephen Hines | 3fbe68a | 2010-11-17 17:28:59 -0800 | [diff] [blame] | 111 | } |
| 112 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 113 | RSExportFunc *EF = RSExportFunc::Create(this, FD); |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 114 | if (EF == nullptr) |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 115 | return false; |
| 116 | else |
| 117 | mExportFuncs.push_back(EF); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 118 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 119 | return true; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 123 | bool RSContext::processExportType(const llvm::StringRef &Name) { |
Stephen Hines | 9e5b503 | 2010-11-03 13:19:14 -0700 | [diff] [blame] | 124 | clang::TranslationUnitDecl *TUDecl = mCtx.getTranslationUnitDecl(); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 125 | |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 126 | slangAssert(TUDecl != nullptr && "Translation unit declaration (top-level " |
| 127 | "declaration) is null object"); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 128 | |
Stephen Hines | 9e5b503 | 2010-11-03 13:19:14 -0700 | [diff] [blame] | 129 | const clang::IdentifierInfo *II = mPP.getIdentifierInfo(Name); |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 130 | if (II == nullptr) |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 131 | // TODO(zonr): alert identifier @Name mark as an exportable type cannot be |
| 132 | // found |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 133 | return false; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 134 | |
Stephen Hines | c706907 | 2015-03-18 14:53:14 -0700 | [diff] [blame] | 135 | clang::DeclContext::lookup_result R = TUDecl->lookup(II); |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 136 | RSExportType *ET = nullptr; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 137 | |
Stephen Hines | c706907 | 2015-03-18 14:53:14 -0700 | [diff] [blame] | 138 | for (clang::DeclContext::lookup_iterator I = R.begin(), E = R.end(); |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 139 | I != E; |
| 140 | I++) { |
| 141 | clang::NamedDecl *const ND = *I; |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 142 | const clang::Type *T = nullptr; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 143 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 144 | switch (ND->getKind()) { |
| 145 | case clang::Decl::Typedef: { |
| 146 | T = static_cast<const clang::TypedefDecl*>( |
| 147 | ND)->getCanonicalDecl()->getUnderlyingType().getTypePtr(); |
| 148 | break; |
| 149 | } |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 150 | case clang::Decl::Record: { |
| 151 | T = static_cast<const clang::RecordDecl*>(ND)->getTypeForDecl(); |
| 152 | break; |
| 153 | } |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 154 | default: { |
| 155 | // unsupported, skip |
| 156 | break; |
Shih-wei Liao | ac91815 | 2010-08-29 02:43:24 -0700 | [diff] [blame] | 157 | } |
| 158 | } |
Shih-wei Liao | 537446c | 2010-06-11 16:05:55 -0700 | [diff] [blame] | 159 | |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 160 | if (T != nullptr) |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 161 | ET = RSExportType::Create(this, T); |
| 162 | } |
| 163 | |
Chris Wailes | 5abbe0e | 2014-08-12 15:58:29 -0700 | [diff] [blame] | 164 | return (ET != nullptr); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Stephen Hines | c17e198 | 2012-02-22 12:30:45 -0800 | [diff] [blame] | 167 | |
| 168 | // Possibly re-order ForEach exports (maybe generating a dummy "root" function). |
| 169 | // We require "root" to be listed as slot 0 of our exported compute kernels, |
| 170 | // so this only needs to be created if we have other non-root kernels. |
| 171 | void RSContext::cleanupForEach() { |
| 172 | bool foundNonRoot = false; |
| 173 | ExportForEachList::iterator begin = mExportForEach.begin(); |
| 174 | |
| 175 | for (ExportForEachList::iterator I = begin, E = mExportForEach.end(); |
| 176 | I != E; |
| 177 | I++) { |
| 178 | RSExportForEach *EFE = *I; |
| 179 | if (!EFE->getName().compare("root")) { |
| 180 | if (I == begin) { |
| 181 | // Nothing to do, since it is the first function |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | mExportForEach.erase(I); |
| 186 | mExportForEach.push_front(EFE); |
| 187 | return; |
| 188 | } else { |
| 189 | foundNonRoot = true; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // If we found a non-root kernel, but no root() function, we need to add a |
| 194 | // dummy version (so that script->script calls of rsForEach don't behave |
| 195 | // erratically). |
| 196 | if (foundNonRoot) { |
| 197 | RSExportForEach *DummyRoot = RSExportForEach::CreateDummyRoot(this); |
| 198 | mExportForEach.push_front(DummyRoot); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | |
Stephen Hines | c808a99 | 2010-11-29 17:20:42 -0800 | [diff] [blame] | 203 | bool RSContext::processExport() { |
Stephen Hines | b6809ed | 2011-05-09 13:05:04 -0700 | [diff] [blame] | 204 | bool valid = true; |
Stephen Hines | 593a894 | 2011-05-10 15:29:50 -0700 | [diff] [blame] | 205 | |
| 206 | if (getDiagnostics()->hasErrorOccurred()) { |
| 207 | return false; |
| 208 | } |
| 209 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 210 | // Export variable |
Stephen Hines | 9e5b503 | 2010-11-03 13:19:14 -0700 | [diff] [blame] | 211 | clang::TranslationUnitDecl *TUDecl = mCtx.getTranslationUnitDecl(); |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 212 | for (clang::DeclContext::decl_iterator DI = TUDecl->decls_begin(), |
| 213 | DE = TUDecl->decls_end(); |
Stephen Hines | c97a333 | 2010-11-30 15:31:08 -0800 | [diff] [blame] | 214 | DI != DE; |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 215 | DI++) { |
| 216 | if (DI->getKind() == clang::Decl::Var) { |
| 217 | clang::VarDecl *VD = (clang::VarDecl*) (*DI); |
Stephen Hines | 44f1006 | 2013-06-13 00:33:23 -0700 | [diff] [blame] | 218 | if (VD->getFormalLinkage() == clang::ExternalLinkage) { |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 219 | if (!processExportVar(VD)) { |
Stephen Hines | b6809ed | 2011-05-09 13:05:04 -0700 | [diff] [blame] | 220 | valid = false; |
Ying Wang | 3f8b44d | 2010-09-04 01:17:01 -0700 | [diff] [blame] | 221 | } |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 222 | } |
| 223 | } else if (DI->getKind() == clang::Decl::Function) { |
| 224 | // Export functions |
| 225 | clang::FunctionDecl *FD = (clang::FunctionDecl*) (*DI); |
Stephen Hines | 44f1006 | 2013-06-13 00:33:23 -0700 | [diff] [blame] | 226 | if (FD->getFormalLinkage() == clang::ExternalLinkage) { |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 227 | if (!processExportFunc(FD)) { |
Stephen Hines | b6809ed | 2011-05-09 13:05:04 -0700 | [diff] [blame] | 228 | valid = false; |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 229 | } |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 230 | } |
Ying Wang | 3f8b44d | 2010-09-04 01:17:01 -0700 | [diff] [blame] | 231 | } |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 232 | } |
Ying Wang | 3f8b44d | 2010-09-04 01:17:01 -0700 | [diff] [blame] | 233 | |
Stephen Hines | c17e198 | 2012-02-22 12:30:45 -0800 | [diff] [blame] | 234 | if (valid) { |
| 235 | cleanupForEach(); |
| 236 | } |
| 237 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 238 | // Finally, export type forcely set to be exported by user |
| 239 | for (NeedExportTypeSet::const_iterator EI = mNeedExportTypes.begin(), |
| 240 | EE = mNeedExportTypes.end(); |
| 241 | EI != EE; |
| 242 | EI++) { |
| 243 | if (!processExportType(EI->getKey())) { |
Stephen Hines | b6809ed | 2011-05-09 13:05:04 -0700 | [diff] [blame] | 244 | valid = false; |
Ying Wang | 3f8b44d | 2010-09-04 01:17:01 -0700 | [diff] [blame] | 245 | } |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 246 | } |
Shih-wei Liao | 537446c | 2010-06-11 16:05:55 -0700 | [diff] [blame] | 247 | |
Stephen Hines | b6809ed | 2011-05-09 13:05:04 -0700 | [diff] [blame] | 248 | return valid; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 251 | bool RSContext::insertExportType(const llvm::StringRef &TypeName, |
| 252 | RSExportType *ET) { |
| 253 | ExportTypeMap::value_type *NewItem = |
Stephen Hines | 2eb9a3f | 2014-07-15 16:50:03 -0700 | [diff] [blame] | 254 | ExportTypeMap::value_type::Create(TypeName, |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 255 | mExportTypes.getAllocator(), |
| 256 | ET); |
Shih-wei Liao | 6de8927 | 2010-07-15 15:26:20 -0700 | [diff] [blame] | 257 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 258 | if (mExportTypes.insert(NewItem)) { |
Shih-wei Liao | 6de8927 | 2010-07-15 15:26:20 -0700 | [diff] [blame] | 259 | return true; |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 260 | } else { |
| 261 | free(NewItem); |
| 262 | return false; |
| 263 | } |
| 264 | } |
| 265 | |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 266 | RSContext::~RSContext() { |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 267 | delete mLicenseNote; |
Stephen Hines | 23c4358 | 2013-01-09 20:02:04 -0800 | [diff] [blame] | 268 | delete mDataLayout; |
Zonr Chang | a41ce1d | 2010-10-06 02:23:12 +0800 | [diff] [blame] | 269 | for (ExportableList::iterator I = mExportables.begin(), |
| 270 | E = mExportables.end(); |
| 271 | I != E; |
| 272 | I++) { |
Zonr Chang | 641558f | 2010-10-12 21:07:06 +0800 | [diff] [blame] | 273 | if (!(*I)->isKeep()) |
| 274 | delete *I; |
Zonr Chang | a41ce1d | 2010-10-06 02:23:12 +0800 | [diff] [blame] | 275 | } |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 276 | } |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 277 | |
| 278 | } // namespace slang |