blob: 7ec84d9bf98a914e6bad19114ffb81c4582f096b [file] [log] [blame]
Zonr Chang19218c02012-04-05 10:44:53 +08001/*
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 Hines2f6a4932012-05-03 12:27:13 -070017#include "RSScript.h"
Zonr Chang19218c02012-04-05 10:44:53 +080018
Stephen Hines7dfc4d82012-05-03 12:25:21 -070019#include <cstring>
20
21#include <llvm/ADT/STLExtras.h>
22
Stephen Hines2f6a4932012-05-03 12:27:13 -070023#include "DebugHelper.h"
Zonr Chang19218c02012-04-05 10:44:53 +080024
Zonr Changfef9a1b2012-04-13 15:58:24 +080025using namespace bcc;
Zonr Chang19218c02012-04-05 10:44:53 +080026
Stephen Hines7dfc4d82012-05-03 12:25:21 -070027RSScript::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 Chang19218c02012-04-05 10:44:53 +080034RSScript::RSScript(Source &pSource)
Zonr Changfef9a1b2012-04-13 15:58:24 +080035 : Script(pSource), mInfo(NULL), mCompilerVersion(0),
36 mOptimizationLevel(kOptLvl3) { }
Zonr Chang19218c02012-04-05 10:44:53 +080037
Stephen Hines7dfc4d82012-05-03 12:25:21 -070038RSScript::~RSScript() {
39 llvm::DeleteContainerPointers(mSourceDependencies);
40}
41
Zonr Chang19218c02012-04-05 10:44:53 +080042bool RSScript::doReset() {
Zonr Changfef9a1b2012-04-13 15:58:24 +080043 mInfo = NULL;
44 mCompilerVersion = 0;
45 mOptimizationLevel = kOptLvl3;
Stephen Hines7dfc4d82012-05-03 12:25:21 -070046 llvm::DeleteContainerPointers(mSourceDependencies);
47 return true;
48}
49
50bool 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 Chang19218c02012-04-05 10:44:53 +080061 return true;
62}