Skip to content

Commit

Permalink
misc cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Dodd authored and ChrisDodd committed Feb 16, 2017
1 parent 2a2d5f4 commit efd9a12
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion backends/bmv2/bmv2stf.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,11 @@ def do_command(self, cmd):
interface, data = nextWord(cmd)
data = ''.join(data.split())
time.sleep(self.packetDelay)
self.interfaces[interface]._write_packet(HexToByte(data))
try:
self.interfaces[interface]._write_packet(HexToByte(data))
except ValueError:
reportError("Invalid packet data", data)
return FAILURE
self.interfaces[interface].flush()
self.packetDelay = 0
elif first == "expect":
Expand Down
6 changes: 3 additions & 3 deletions frontends/common/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,13 @@ void CompilerOptions::dumpPass(const char* manager, unsigned seq, const char* pa
P4::ToP4 toP4(stream, Log::verbose(), file);
node->apply(toP4);
}
break;
}
}
}

DebugHook CompilerOptions::getDebugHook() const {
auto dp = std::bind(&CompilerOptions::dumpPass, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, std::placeholders::_4);
using namespace std::placeholders;
auto dp = std::bind(&CompilerOptions::dumpPass, this, _1, _2, _3, _4);
return dp;
}
1 change: 1 addition & 0 deletions frontends/common/parseInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const IR::P4Program* parseP4File(CompilerOptions& options) {
bool compiling10 = options.isv1();
if (compiling10) {
P4V1::Converter converter;
converter.addDebugHook(options.getDebugHook());
converter.loadModel();
// Model is loaded before parsing the input file.
// In this way the SourceInfo in the model comes first.
Expand Down
4 changes: 2 additions & 2 deletions frontends/p4/fromv1.0/programStructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,9 @@ void ProgramStructure::include(cstring filename) {
options.file = path.toString();
if (FILE* file = options.preprocess()) {
if (!::errorCount()) {
if (auto std = parse_P4_16_file(options.file, file)) {
if (auto code = parse_P4_16_file(options.file, file)) {
if (!::errorCount()) {
for (auto decl : *std->declarations) {
for (auto decl : *code->declarations) {
declarations->push_back(decl); } } } }
options.closeInput(file); }
}
Expand Down
1 change: 1 addition & 0 deletions frontends/p4/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class FrontEnd {
std::vector<DebugHook> hooks;
public:
FrontEnd() = default;
explicit FrontEnd(DebugHook hook) { hooks.push_back(hook); }
void addDebugHook(DebugHook hook) { hooks.push_back(hook); }
const IR::P4Program* run(const CompilerOptions& options, const IR::P4Program* program);
};
Expand Down

0 comments on commit efd9a12

Please sign in to comment.