1 /* 2 * RCntxtUtils.hpp 3 * 4 * Copyright (C) 2021 by RStudio, PBC 5 * 6 * Unless you have received this program directly from RStudio pursuant 7 * to the terms of a commercial license agreement with RStudio, then 8 * this program is licensed to you under the terms of version 3 of the 9 * GNU Affero General Public License. This program is distributed WITHOUT 10 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT, 11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the 12 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details. 13 * 14 */ 15 16 #ifndef R_CONTEXT_UTILS_HPP 17 #define R_CONTEXT_UTILS_HPP 18 19 #include <shared_core/Error.hpp> 20 #include "RCntxt.hpp" 21 22 namespace rstudio { 23 namespace r { 24 namespace context { 25 26 #define BROWSER_FUNCTION 0 27 28 // represents the version of the memory layout of the RCNTXT structure 29 enum RCntxtVersion 30 { 31 RVersion40, // R 4.0 and above 32 RVersion34, // R 3.4 until R 4.0 (exclusive) 33 RVersion33, // R 3.3 (all versions) 34 RVersion32, // R 3.2.5 and below 35 RVersionUnknown 36 }; 37 38 RCntxtVersion contextVersion(); 39 40 RCntxt globalContext(); 41 42 bool inBrowseContext(); 43 44 bool inDebugHiddenContext(); 45 46 RCntxt firstFunctionContext(); 47 48 RCntxt getFunctionContext(const int depth, 49 int* pFoundDepth = nullptr, 50 SEXP* pEnvironment = nullptr); 51 52 bool isByteCodeContext(const RCntxt& cntxt); 53 bool isByteCodeSrcRef(SEXP srcref); 54 55 } // namespace context 56 } // namespace r 57 } // namespace rstudio 58 59 #endif 60