Make getRootScope const
Add a getMutableRootScope method with original functionality.
getRootScope should not provide a pointer since callers should not be
modifying the scope directly. This changes all but one of the callers.
Bug: N/A
Test: ./test/run_all_host_tests.sh && ./test/run_all_device_tests.sh
Change-Id: I0b6ecad3322bb98fd7f1950ee25312c3a8c2faad
diff --git a/AST.cpp b/AST.cpp
index 834dc5a..b05c458 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -41,10 +41,14 @@
mRootScope("(root scope)", FQName(), Location::startOf(fileHash->getPath()),
nullptr /* parent */) {}
-Scope* AST::getRootScope() {
+Scope* AST::getMutableRootScope() {
return &mRootScope;
}
+const Scope& AST::getRootScope() const {
+ return mRootScope;
+}
+
// used by the parser.
void AST::addSyntaxError() {
mSyntaxErrors++;