c5a8df6c88
seconds, but I don't like where EvaluateInternal is going. At first place it shouldn't do any smart guessing what the transformers would do. Second it shouldn't try to attach expression evaluation (storing the result in cling::Value) while preparing for value printing. To sum up: * Simplify the old craft in EvaluateInternal - Move the value printing logic into the value printer transformer. - Move the expression evaluation login (mainly coming through the Interpreter::evaluate interface) into separate transformer. * Attach the new transformer to the list of transformers (the size of it was increased as well.) * Add new compilation option switch that the new transformer will react on. * Turn on the switch where necessary. * Simplify value printer logic. Now everything is at one place, which makes it simpler and easier to debug. * Make IncrementalParser::Parse to take compilation options' reference instead of constructing it's own. * As consequence of the new implementation - two bugs in the testsuite were uncovered. Propose a fix for them. * Improve documentation. * TODO: There is some code duplication, which will be factored out soon. git-svn-id: http://root.cern.ch/svn/root/trunk@46549 27541ba8-7e3a-0410-8455-c3a389f83636
70 lines
2.0 KiB
C++
70 lines
2.0 KiB
C++
//------------------------------------------------------------------------------
|
|
// CLING - the C++ LLVM-based InterpreterG :)
|
|
// version: $Id$
|
|
// author: Vassil Vassilev <vasil.georgiev.vasilev@cern.ch>
|
|
//------------------------------------------------------------------------------
|
|
|
|
#ifndef CLING_VALUE_PRINTER_SYNTHESIZER_H
|
|
#define CLING_VALUE_PRINTER_SYNTHESIZER_H
|
|
|
|
#include "TransactionTransformer.h"
|
|
|
|
#include "llvm/ADT/OwningPtr.h"
|
|
|
|
namespace clang {
|
|
class ASTContext;
|
|
class CompoundStmt;
|
|
class DeclGroupRef;
|
|
class Expr;
|
|
class Sema;
|
|
}
|
|
|
|
namespace llvm {
|
|
class raw_ostream;
|
|
}
|
|
|
|
namespace cling {
|
|
|
|
class ValuePrinterSynthesizer : public TransactionTransformer {
|
|
|
|
private:
|
|
///\brief Needed for the AST transformations, owned by Sema.
|
|
///
|
|
clang::ASTContext* m_Context;
|
|
|
|
///\brief Stream to dump values into.
|
|
///
|
|
llvm::OwningPtr<llvm::raw_ostream> m_ValuePrinterStream;
|
|
|
|
public:
|
|
///\ brief Constructs the value printer synthesizer.
|
|
///
|
|
///\param[in] S - The semantic analysis object
|
|
///\param[in] Stream - The output stream where the value printer will write
|
|
/// to. Defaults to std::cout. Owns the stream.
|
|
ValuePrinterSynthesizer(clang::Sema* S, llvm::raw_ostream* Stream);
|
|
|
|
virtual ~ValuePrinterSynthesizer();
|
|
|
|
virtual void Transform();
|
|
|
|
private:
|
|
///\brief Tries to attach a value printing mechanism to the given decl group
|
|
/// ref.
|
|
///
|
|
///\param[in] DGR - A decl group ref the value printer is being attached to.
|
|
///
|
|
///\returns true if the attachment was considered as success. I.e. even if
|
|
/// even if the value printer wasn't attached because of the compilation
|
|
/// options disallowint it - it will return still true. Returns false on
|
|
/// critical error.
|
|
bool tryAttachVP(clang::DeclGroupRef DGR);
|
|
clang::Expr* SynthesizeCppVP(clang::Expr* E);
|
|
clang::Expr* SynthesizeVP(clang::Expr* E);
|
|
unsigned ClearNullStmts(clang::CompoundStmt* CS);
|
|
};
|
|
|
|
} // namespace cling
|
|
|
|
#endif // CLING_DECL_EXTRACTOR_H
|