1 //===-- Expression.h --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_Expression_h_
11 #define liblldb_Expression_h_
19 // Other libraries and framework includes
22 #include "lldb/Expression/ExpressionTypeSystemHelper.h"
23 #include "lldb/lldb-forward.h"
24 #include "lldb/lldb-private.h"
26 namespace lldb_private {
28 class RecordingMemoryManager;
30 //----------------------------------------------------------------------
31 /// @class Expression Expression.h "lldb/Expression/Expression.h" Encapsulates
32 /// a single expression for use in lldb
34 /// LLDB uses expressions for various purposes, notably to call functions
35 /// and as a backend for the expr command. Expression encapsulates the
36 /// objects needed to parse and interpret or JIT an expression. It uses the
37 /// expression parser appropriate to the language of the expression to produce
38 /// LLVM IR from the expression.
39 //----------------------------------------------------------------------
42 enum ResultType { eResultTypeAny, eResultTypeId };
44 Expression(Target &target);
46 Expression(ExecutionContextScope &exe_scope);
48 //------------------------------------------------------------------
50 //------------------------------------------------------------------
51 virtual ~Expression() {}
53 //------------------------------------------------------------------
54 /// Return the string that the parser should parse. Must be a full
56 //------------------------------------------------------------------
57 virtual const char *Text() = 0;
59 //------------------------------------------------------------------
60 /// Return the function name that should be used for executing the
61 /// expression. Text() should contain the definition of this function.
62 //------------------------------------------------------------------
63 virtual const char *FunctionName() = 0;
65 //------------------------------------------------------------------
66 /// Return the language that should be used when parsing. To use the
67 /// default, return eLanguageTypeUnknown.
68 //------------------------------------------------------------------
69 virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
71 //------------------------------------------------------------------
72 /// Return the desired result type of the function, or eResultTypeAny if
74 //------------------------------------------------------------------
75 virtual ResultType DesiredResultType() { return eResultTypeAny; }
77 //------------------------------------------------------------------
79 //------------------------------------------------------------------
81 //------------------------------------------------------------------
82 /// Return true if validation code should be inserted into the expression.
83 //------------------------------------------------------------------
84 virtual bool NeedsValidation() = 0;
86 //------------------------------------------------------------------
87 /// Return true if external variables in the expression should be resolved.
88 //------------------------------------------------------------------
89 virtual bool NeedsVariableResolution() = 0;
91 virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
93 //------------------------------------------------------------------
94 /// Return the address of the function's JIT-compiled code, or
95 /// LLDB_INVALID_ADDRESS if the function is not JIT compiled
96 //------------------------------------------------------------------
97 lldb::addr_t StartAddress() { return m_jit_start_addr; }
99 //------------------------------------------------------------------
100 /// Called to notify the expression that it is about to be executed.
101 //------------------------------------------------------------------
102 virtual void WillStartExecuting() {}
104 //------------------------------------------------------------------
105 /// Called to notify the expression that its execution has finished.
106 //------------------------------------------------------------------
107 virtual void DidFinishExecuting() {}
109 virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; }
112 lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
113 lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but
114 /// it doesn't need to (e.g. calculator
116 lldb::addr_t m_jit_start_addr; ///< The address of the JITted function within
117 ///the JIT allocation. LLDB_INVALID_ADDRESS if
119 lldb::addr_t m_jit_end_addr; ///< The address of the JITted function within
120 ///the JIT allocation. LLDB_INVALID_ADDRESS if
124 } // namespace lldb_private
126 #endif // liblldb_Expression_h_