From 943350a7c2607821dec50d27333e011fd9fce180 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Fri, 28 Feb 2014 10:08:13 +0100 Subject: [PATCH] Implement .stats command printing out statistics about internal ADT --- lib/MetaProcessor/MetaParser.cpp | 25 ++++++++++++++++++++----- lib/MetaProcessor/MetaParser.h | 4 +++- lib/MetaProcessor/MetaSema.cpp | 6 ++++++ lib/MetaProcessor/MetaSema.h | 6 ++++++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/lib/MetaProcessor/MetaParser.cpp b/lib/MetaProcessor/MetaParser.cpp index 03322e67..7b0784c2 100644 --- a/lib/MetaProcessor/MetaParser.cpp +++ b/lib/MetaProcessor/MetaParser.cpp @@ -112,11 +112,11 @@ namespace cling { || isXCommand(actionResult, resultValue) || isqCommand() || isUCommand(actionResult) || isICommand() || isOCommand() || israwInputCommand() || isprintASTCommand() - || isdynamicExtensionsCommand() - || ishelpCommand() || isfileExCommand() || isfilesCommand() || isClassCommand() - || isgCommand() || isTypedefCommand() || isprintIRCommand() - || isShellCommand(actionResult, resultValue) - || isstoreStateCommand() || iscompareStateCommand() || isundoCommand() + || isdynamicExtensionsCommand() || ishelpCommand() || isfileExCommand() + || isfilesCommand() || isClassCommand() || isgCommand() + || isTypedefCommand() || isprintIRCommand() + || isShellCommand(actionResult, resultValue) || isstoreStateCommand() + || iscompareStateCommand() || isstatsCommand() || isundoCommand() || isRedirectCommand(actionResult); } @@ -404,6 +404,21 @@ namespace cling { return false; } + bool MetaParser::isstatsCommand() { + if (getCurTok().is(tok::ident) && + getCurTok().getIdent().equals("stats")) { + consumeToken(); + skipWhitespace(); + if (!getCurTok().is(tok::ident)) + return false; // FIXME: Issue proper diagnostics + std::string ident = getCurTok().getIdent(); + consumeToken(); + m_Actions->actOnstatsCommand(ident); + return true; + } + return false; + } + bool MetaParser::isundoCommand() { if (getCurTok().is(tok::ident) && getCurTok().getIdent().equals("undo")) { diff --git a/lib/MetaProcessor/MetaParser.h b/lib/MetaProcessor/MetaParser.h index 3776c631..1e51f5fc 100644 --- a/lib/MetaProcessor/MetaParser.h +++ b/lib/MetaProcessor/MetaParser.h @@ -31,7 +31,7 @@ namespace cling { // PrintASTCommand | DynamicExtensionsCommand | HelpCommand | // FileExCommand | FilesCommand | ClassCommand | // GCommand | PrintIRCommand | StoreStateCommand | - // CompareStateCommand | undoCommand + // CompareStateCommand | StatsCommand | undoCommand // LCommand := 'L' FilePath // >Command := '>' FilePath // qCommand := 'q' @@ -44,6 +44,7 @@ namespace cling { // PrintIRCommand := 'printIR' [Constant] // StoreStateCommand := 'storeState' "Ident" // CompareStateCommand := 'compareState' "Ident" + // StatsCommand := 'stats' ['ast'] // undoCommand := 'undo' [Constant] // DynamicExtensionsCommand := 'dynamicExtensions' [Constant] // HelpCommand := 'help' @@ -93,6 +94,7 @@ namespace cling { bool isprintIRCommand(); bool isstoreStateCommand(); bool iscompareStateCommand(); + bool isstatsCommand(); bool isundoCommand(); bool isdynamicExtensionsCommand(); bool ishelpCommand(); diff --git a/lib/MetaProcessor/MetaSema.cpp b/lib/MetaProcessor/MetaSema.cpp index 255b6b81..c4b8de29 100644 --- a/lib/MetaProcessor/MetaSema.cpp +++ b/lib/MetaProcessor/MetaSema.cpp @@ -154,6 +154,12 @@ namespace cling { m_Interpreter.compareInterpreterState(name); } + void MetaSema::actOnstatsCommand(llvm::StringRef name) const { + if (name.equals("ast")) { + m_Interpreter.getCI()->getSema().getASTContext().PrintStats(); + } + } + void MetaSema::actOndynamicExtensionsCommand(SwitchMode mode/* = kToggle*/) const { if (mode == kToggle) { diff --git a/lib/MetaProcessor/MetaSema.h b/lib/MetaProcessor/MetaSema.h index 80b774cb..3a90c3eb 100644 --- a/lib/MetaProcessor/MetaSema.h +++ b/lib/MetaProcessor/MetaSema.h @@ -145,6 +145,12 @@ namespace cling { /// void actOncompareStateCommand(llvm::StringRef name) const; + ///\brief Show stats for various internal data structures. + /// + ///\param[in] name - Name of the structure. + /// + void actOnstatsCommand(llvm::StringRef name) const; + ///\brief Switches on/off the experimental dynamic extensions (dynamic /// scopes) and late binding. ///