Skip to content

Commit

Permalink
First two items in #78.
Browse files Browse the repository at this point in the history
  • Loading branch information
GregUtas committed Jan 14, 2018
1 parent 8d8ed29 commit 257d603
Show file tree
Hide file tree
Showing 28 changed files with 2,621 additions and 2,368 deletions.
7 changes: 7 additions & 0 deletions clihelp/cli.ct.export.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The options are specified in a string that contains any of the following:
n (display namespace view)
c (display canonical file view: items sorted in a fixed order)
o (display original file view: items shown in their original order)
h (display class hierarchy)
s (include statistics, such as the number of reads and writes)
If no options are entered, they default to "nchs".
7 changes: 7 additions & 0 deletions clihelp/cli.ct.parse.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The options are specified in a string that contains any of the following:
p (save parse tree on failure)
s (always save parse tree)
x (generate "object code" during execution)
i (immediate tracing: needed if 'x' causes trace buffer to overflow)
f (enable FunctionTracer)
For no options, use the skip character ('-').
10 changes: 1 addition & 9 deletions clihelp/cli.ct.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,4 @@ Here are some examples of library commands:
>assign c1 ab Thread.h : c1 = files that could be affected by
changing Thread.h
>assign s1 h1 & c1 : s1 = SessionBase .cpps that could be affected
by changing Thread.h

Parser options in the >parse command:
- (none)
p (save parse tree on failure)
s (always save parse tree)
x (generate "object code" during execution)
i (immediate tracing: needed if 'x' causes trace buffer to overflow)
f (enable FunctionTracer)
by changing Thread.h
33 changes: 19 additions & 14 deletions ct/CodeFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1970,29 +1970,34 @@ void CodeFile::DisplayItems(ostream& stream, const string& opts) const
{
if(dir_ == nullptr) return;

stream << FullName();
if(parsed_ == Unparsed) stream << ": NOT PARSED";
stream << CRLF;
if(parsed_ == Unparsed) return;

auto lead = spaces(Indent_Size);
auto qual = Flags(FQ_Mask);
auto options = Flags(FQ_Mask);
if(opts.find(ItemStatistics) != string::npos) options.set(DispStats);

if(opts.find('c') != string::npos)
if(opts.find(CanonicalFileView) != string::npos)
{
stream << FullName() << CRLF;
stream << '{' << CRLF;
DisplayObjects(incls_, stream, lead, qual);
DisplayObjects(macros_, stream, lead, qual);
DisplayObjects(forws_, stream, lead, qual);
DisplayObjects(usings_, stream, lead, qual);
DisplayObjects(enums_, stream, lead, qual);
DisplayObjects(types_, stream, lead, qual);
DisplayObjects(funcs_, stream, lead, qual);
DisplayObjects(data_, stream, lead, qual);
DisplayObjects(classes_, stream, lead, qual);
DisplayObjects(incls_, stream, lead, options);
DisplayObjects(macros_, stream, lead, options);
DisplayObjects(forws_, stream, lead, options);
DisplayObjects(usings_, stream, lead, options);
DisplayObjects(enums_, stream, lead, options);
DisplayObjects(types_, stream, lead, options);
DisplayObjects(funcs_, stream, lead, options);
DisplayObjects(data_, stream, lead, options);
DisplayObjects(classes_, stream, lead, options);
stream << '}' << CRLF;
}

if(opts.find('o') != string::npos)
if(opts.find(OriginalFileView) != string::npos)
{
stream << '{' << CRLF;
DisplayObjects(items_, stream, lead, qual);
DisplayObjects(items_, stream, lead, options);
stream << '}' << CRLF;
}
}
Expand Down
21 changes: 8 additions & 13 deletions ct/CodeIncrement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,14 @@ word CountlinesCommand::ProcessCommand(CliThread& cli) const
//
// The EXPORT command.
//
class OrderParm : public CliCharParm
class ViewsParm : public CliTextParm
{
public: OrderParm();
public: ViewsParm();
};

fixed_string OrderStr = "co";
fixed_string OrderExpl = "'c'=canonical 'o'=original (default='c')";
fixed_string ViewsExpl = "options (enter \">help export full\" for details)";

OrderParm::OrderParm() : CliCharParm(OrderExpl, OrderStr, true) { }
ViewsParm::ViewsParm() : CliTextParm(ViewsExpl, true) { }

class ExportCommand : public CliCommand
{
Expand All @@ -448,7 +447,7 @@ fixed_string ExportExpl = "Exports library information.";
ExportCommand::ExportCommand() : CliCommand(ExportStr, ExportExpl)
{
BindParm(*new FileMandParm);
BindParm(*new OrderParm);
BindParm(*new ViewsParm);
}

fn_name ExportCommand_ProcessCommand = "ExportCommand.ProcessCommand";
Expand All @@ -460,17 +459,13 @@ word ExportCommand::ProcessCommand(CliThread& cli) const
string title;

if(!GetFileName(title, cli)) return -1;
cli.EndOfInput(false);

auto stream = cli.FileStream();
if(stream == nullptr) return cli.Report(-7, CreateStreamFailure);

string opts;
char c;
if(GetCharParmRc(c, cli) == CliParm::Ok)
opts = c;
else
opts = "c";
if(!GetString(opts, cli)) opts = "nchs";
cli.EndOfInput(false);

auto lib = Singleton< Library >::Instance();
auto rc = lib->Export(*stream, opts);
Expand Down Expand Up @@ -717,7 +712,7 @@ class OptionsParm : public CliTextParm
public: OptionsParm();
};

fixed_string OptionsExpl = "parser options (enter >help full for details)";
fixed_string OptionsExpl = "options (enter \">help parse full\" for details)";

OptionsParm::OptionsParm() : CliTextParm(OptionsExpl) { }

Expand Down
1 change: 1 addition & 0 deletions ct/CodeTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const Flags Last_Mask = Flags(1 << DispLast);
const Flags Code_Mask = Flags(1 << DispCode);
const Flags NoAC_Mask = Flags(1 << DispNoAC);
const Flags NoTP_Mask = Flags(1 << DispNoTP);
const Flags Stats_Mask = Flags(1 << DispStats);

uint8_t Indent_Size = 3;

Expand Down
6 changes: 4 additions & 2 deletions ct/CodeTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,14 @@ std::ostream& operator<<(std::ostream& stream, LineType type);
enum CodeDisplayOptions
{
DispFQ, // display fully qualified name
DispNS, // display namespace view (else file view)
DispNS, // display in namespace view (else in file view)
DispLF, // insert optional line feed
DispNoLF, // omit line feed
DispLast, // set for the last item in a series
DispCode, // output will be used to generate code
DispNoAC, // omit access control prefix
DispNoTP // omit template parameters definition list
DispNoTP, // omit template parameters definition list
DispStats // include statistics (e.g. reads, writes)
};

extern const Flags FQ_Mask;
Expand All @@ -510,6 +511,7 @@ extern const Flags Last_Mask;
extern const Flags Code_Mask;
extern const Flags NoAC_Mask;
extern const Flags NoTP_Mask;
extern const Flags Stats_Mask;

extern uint8_t Indent_Size;

Expand Down
26 changes: 16 additions & 10 deletions ct/CxxArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,16 +975,14 @@ void Class::Display(ostream& stream,
}
}

auto size = tmplts_.size();

if(size > 0)
if(!tmplts_.empty())
{
stream << prefix << spaces(Indent_Size)
<< "instantiations (" << size << "):" << CRLF;
<< "instantiations (" << tmplts_.size() << "):" << CRLF;

for(size_t i = 0; i < size; ++i)
for(auto t = tmplts_.cbegin(); t != tmplts_.cend(); ++t)
{
tmplts_.at(i)->Display(stream, lead, options);
(*t)->Display(stream, lead, options);
}
}
}
Expand All @@ -998,7 +996,7 @@ void Class::DisplayBase(ostream& stream, const Flags& options) const
{
if(!options.test(DispNoTP))
{
if(parms_ != nullptr) parms_->Print(stream);
if(parms_ != nullptr) parms_->Print(stream, options);
}

if(OuterClass() != nullptr) stream << GetAccess() << ": ";
Expand Down Expand Up @@ -1799,15 +1797,23 @@ void ClassInst::Display(ostream& stream,
stream << prefix;
Class::DisplayBase(stream, options);
if(!created_) stream << ";";
if(!code) stream << " // r=" << refs_ << SPACE;

std::ostringstream buff;
buff << " // ";
if(options.test(DispStats)) buff << "r=" << refs_ << SPACE;

if(!created_)
{
if(!code) stream << "<@uninst" << CRLF;
if(!code) buff << "<@uninst" << CRLF;
auto str = buff.str();
if(str.size() > 4) stream << str;
return;
}

if(!compiled_ && !code) stream << "<@failed to parse";
if(!compiled_ && !code) buff << "<@failed to parse";
auto str = buff.str();
if(str.size() > 4) stream << str;

stream << CRLF << prefix << '{' << CRLF;

if(!compiled_)
Expand Down
22 changes: 14 additions & 8 deletions ct/CxxDirective.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <bitset>
#include <iosfwd>
#include <ostream>
#include <sstream>
#include <vector>
#include "CodeFile.h"
#include "CodeTypes.h"
Expand Down Expand Up @@ -70,7 +71,7 @@ Conditional::Conditional()
void Conditional::Display(ostream& stream,
const string& prefix, const Flags& options) const
{
condition_->Print(stream);
condition_->Print(stream, options);
stream << CRLF;
OptionalCode::Display(stream, prefix, options);
}
Expand Down Expand Up @@ -166,14 +167,18 @@ void Define::Display(ostream& stream,
if(rhs_ != nullptr)
{
stream << SPACE;
rhs_->Print(stream);
rhs_->Print(stream, options);
}

if(!options.test(DispCode))
{
stream << " // r=" << refs_ << SPACE;
if(!defined_) stream << "[not defined]" << SPACE;
if(!options.test(DispFQ)) DisplayFiles(stream);
std::ostringstream buff;
buff << " // ";
if(options.test(DispStats)) buff << "r=" << refs_ << SPACE;
if(!defined_) buff << "[not defined]" << SPACE;
if(!options.test(DispFQ)) DisplayFiles(buff);
auto str = buff.str();
if(str.size() > 4) stream << str;
}

stream << CRLF;
Expand Down Expand Up @@ -686,8 +691,9 @@ void Macro::Display(ostream& stream,

if(!options.test(DispCode))
{
stream << " // r=" << refs_ << SPACE;
stream << "built-in";
stream << " // ";
if(options.test(DispStats)) stream << "r=" << refs_ << SPACE;
stream << "[built-in]";
}

stream << CRLF;
Expand Down Expand Up @@ -816,7 +822,7 @@ void MacroName::GetUsages(const CodeFile& file, CxxUsageSets& symbols) const

//------------------------------------------------------------------------------

void MacroName::Print(ostream& stream) const
void MacroName::Print(ostream& stream, const Flags& options) const
{
stream << name_;
}
Expand Down
3 changes: 2 additions & 1 deletion ct/CxxDirective.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ class MacroName : public CxxNamed

// Overridden to display the name, including any template arguments.
//
virtual void Print(std::ostream& stream) const override;
virtual void Print
(std::ostream& stream, const Flags& options) const override;

// Overridden to return the macro's name.
//
Expand Down
2 changes: 1 addition & 1 deletion ct/CxxExecute.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ extern const StackArg NilStackArg;

//------------------------------------------------------------------------------
//
// Parser options for the CLI >parse command.
// Options for the CLI >parse command.
//
constexpr char TraceParse = 'p';
constexpr char SaveParseTrace = 's';
Expand Down
Loading

0 comments on commit 257d603

Please sign in to comment.