Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012, The Android Open Source Project |
| 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 | |
Stephen Hines | 2f6a493 | 2012-05-03 12:27:13 -0700 | [diff] [blame] | 17 | #include "RSScript.h" |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 18 | |
Stephen Hines | 7dfc4d8 | 2012-05-03 12:25:21 -0700 | [diff] [blame] | 19 | #include <cstring> |
| 20 | |
| 21 | #include <llvm/ADT/STLExtras.h> |
| 22 | |
Stephen Hines | 2f6a493 | 2012-05-03 12:27:13 -0700 | [diff] [blame] | 23 | #include "DebugHelper.h" |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 24 | |
Zonr Chang | fef9a1b | 2012-04-13 15:58:24 +0800 | [diff] [blame] | 25 | using namespace bcc; |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 26 | |
Stephen Hines | 7dfc4d8 | 2012-05-03 12:25:21 -0700 | [diff] [blame] | 27 | RSScript::SourceDependency::SourceDependency(const std::string &pSourceName, |
| 28 | const uint8_t *pSHA1) |
| 29 | : mSourceName(pSourceName) { |
| 30 | ::memcpy(mSHA1, pSHA1, sizeof(mSHA1)); |
| 31 | return; |
| 32 | } |
| 33 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 34 | RSScript::RSScript(Source &pSource) |
Zonr Chang | fef9a1b | 2012-04-13 15:58:24 +0800 | [diff] [blame] | 35 | : Script(pSource), mInfo(NULL), mCompilerVersion(0), |
| 36 | mOptimizationLevel(kOptLvl3) { } |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 37 | |
Stephen Hines | 7dfc4d8 | 2012-05-03 12:25:21 -0700 | [diff] [blame] | 38 | RSScript::~RSScript() { |
| 39 | llvm::DeleteContainerPointers(mSourceDependencies); |
| 40 | } |
| 41 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 42 | bool RSScript::doReset() { |
Zonr Chang | fef9a1b | 2012-04-13 15:58:24 +0800 | [diff] [blame] | 43 | mInfo = NULL; |
| 44 | mCompilerVersion = 0; |
| 45 | mOptimizationLevel = kOptLvl3; |
Stephen Hines | 7dfc4d8 | 2012-05-03 12:25:21 -0700 | [diff] [blame] | 46 | llvm::DeleteContainerPointers(mSourceDependencies); |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | bool RSScript::addSourceDependency(const std::string &pSourceName, |
| 51 | const uint8_t *pSHA1) { |
| 52 | SourceDependency *source_dep = |
| 53 | new (std::nothrow) SourceDependency(pSourceName, pSHA1); |
| 54 | if (source_dep == NULL) { |
| 55 | ALOGE("Out of memory when record dependency information of `%s'!", |
| 56 | pSourceName.c_str()); |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | mSourceDependencies.push_back(source_dep); |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 61 | return true; |
| 62 | } |