Skip to content

Commit

Permalink
A bit more cleanup. StreamWriter is now fully inlined.
Browse files Browse the repository at this point in the history
  • Loading branch information
Orvid committed Dec 1, 2015
1 parent 2adb2c4 commit 6edbb79
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 34 deletions.
3 changes: 0 additions & 3 deletions Decompiler/Coder.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#pragma once

#include <memory>

#include <sstream>

#include "OutputWriter.hpp"
#include "Pex/Binary.hpp"



namespace Decompiler {
/**
* @brief Base class for program writer
Expand Down
11 changes: 2 additions & 9 deletions Decompiler/PscCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
#include "Node/Nodes.hpp"
#include "Node/WithNode.hpp"

static inline
bool isTempVar(const Pex::StringTable::Index& var)
static bool isTempVar(const Pex::StringTable::Index& var)
{
auto& name = var.asString();
return name.length() > 6 && name.substr(0, 6) == "::temp" && name.substr(name.length() - 4, 4) != "_var";
}

static inline
std::string getVarName(const Pex::StringTable::Index& var)
static std::string getVarName(const Pex::StringTable::Index& var)
{
auto& name = var.asString();
if (name.length() > 6 && name.substr(0, 2) == "::" && name.substr(name.length() - 4, 4) == "_var")
Expand All @@ -26,16 +24,11 @@ std::string getVarName(const Pex::StringTable::Index& var)


Decompiler::PscCodeGenerator::PscCodeGenerator(Decompiler::PscDecompiler* decompiler) :
m_Level(0),
m_Decompiler(decompiler)
{
assert(decompiler);
}

Decompiler::PscCodeGenerator::~PscCodeGenerator()
{

}
/*
std::ostringstream& Disassembler::PscCodeGenerator::indent()
{
Expand Down
4 changes: 2 additions & 2 deletions Decompiler/PscCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PscCodeGenerator : public Node::Visitor
{
public:
PscCodeGenerator(Decompiler::PscDecompiler* decompiler);
virtual ~PscCodeGenerator();
virtual ~PscCodeGenerator() = default;


virtual void visit(Node::Scope* node);
Expand All @@ -46,7 +46,7 @@ class PscCodeGenerator : public Node::Visitor
void newLine();

std::ostringstream m_Result;
std::uint8_t m_Level;
std::uint8_t m_Level{ 0 };
Decompiler::PscDecompiler* m_Decompiler;
};

Expand Down
15 changes: 0 additions & 15 deletions Decompiler/StreamWriter.cpp

This file was deleted.

14 changes: 9 additions & 5 deletions Decompiler/StreamWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
#include "OutputWriter.hpp"

namespace Decompiler {
class StreamWriter :
public OutputWriter

class StreamWriter : public OutputWriter
{
public:
StreamWriter(std::ostream& stream);
virtual ~StreamWriter();
StreamWriter(std::ostream& stream) : m_Stream(stream) { }
virtual ~StreamWriter() = default;

virtual void writeLine(const std::string& line);
virtual void writeLine(const std::string& line)
{
m_Stream << line << '\n';
}

protected:
std::ostream& m_Stream;
};

}

0 comments on commit 6edbb79

Please sign in to comment.