1 //===-- DILEval.h -----------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_VALUEOBJECT_DILEVAL_H 10 #define LLDB_VALUEOBJECT_DILEVAL_H 11 12 #include "lldb/ValueObject/DILAST.h" 13 #include "lldb/ValueObject/DILParser.h" 14 #include "llvm/ADT/StringRef.h" 15 #include "llvm/Support/Error.h" 16 #include <memory> 17 #include <vector> 18 19 namespace lldb_private::dil { 20 21 /// Given the name of an identifier (variable name, member name, type name, 22 /// etc.), find the ValueObject for that name (if it exists), excluding global 23 /// variables, and create and return an IdentifierInfo object containing all 24 /// the relevant information about that object (for DIL parsing and 25 /// evaluating). 26 lldb::ValueObjectSP LookupIdentifier(llvm::StringRef name_ref, 27 std::shared_ptr<StackFrame> frame_sp, 28 lldb::DynamicValueType use_dynamic); 29 30 /// Given the name of an identifier, check to see if it matches the name of a 31 /// global variable. If so, find the ValueObject for that global variable, and 32 /// create and return an IdentifierInfo object containing all the relevant 33 /// informatin about it. 34 lldb::ValueObjectSP LookupGlobalIdentifier(llvm::StringRef name_ref, 35 std::shared_ptr<StackFrame> frame_sp, 36 lldb::TargetSP target_sp, 37 lldb::DynamicValueType use_dynamic); 38 39 class Interpreter : Visitor { 40 public: 41 Interpreter(lldb::TargetSP target, llvm::StringRef expr, 42 std::shared_ptr<StackFrame> frame_sp, 43 lldb::DynamicValueType use_dynamic, bool use_synthetic, 44 bool fragile_ivar, bool check_ptr_vs_member); 45 46 llvm::Expected<lldb::ValueObjectSP> Evaluate(const ASTNode *node); 47 48 private: 49 llvm::Expected<lldb::ValueObjectSP> 50 Visit(const IdentifierNode *node) override; 51 llvm::Expected<lldb::ValueObjectSP> Visit(const MemberOfNode *node) override; 52 llvm::Expected<lldb::ValueObjectSP> Visit(const UnaryOpNode *node) override; 53 llvm::Expected<lldb::ValueObjectSP> 54 Visit(const ArraySubscriptNode *node) override; 55 llvm::Expected<lldb::ValueObjectSP> 56 Visit(const BitFieldExtractionNode *node) override; 57 58 // Used by the interpreter to create objects, perform casts, etc. 59 lldb::TargetSP m_target; 60 llvm::StringRef m_expr; 61 lldb::ValueObjectSP m_scope; 62 std::shared_ptr<StackFrame> m_exe_ctx_scope; 63 lldb::DynamicValueType m_use_dynamic; 64 bool m_use_synthetic; 65 bool m_fragile_ivar; 66 bool m_check_ptr_vs_member; 67 }; 68 69 } // namespace lldb_private::dil 70 71 #endif // LLDB_VALUEOBJECT_DILEVAL_H 72