reduce memory usage and cleanup code
This commit is contained in:
@ -16,7 +16,7 @@ auto asset::serialize() -> std::vector<std::uint8_t>
|
||||
std::memset(data.data(), 0, data.size());
|
||||
|
||||
auto pos = 0u;
|
||||
|
||||
|
||||
std::memcpy(&data[pos], name.data(), name.size() + 1);
|
||||
pos += name.size() + 1;
|
||||
|
||||
|
@ -30,10 +30,10 @@ void block::transfer(const block::ptr& child)
|
||||
auto& v = child->local_vars;
|
||||
if (pos > std::int32_t(i))
|
||||
std::rotate(v.rend() - pos - 1, v.rend() - pos, v.rend() - i);
|
||||
else
|
||||
else
|
||||
std::rotate(v.begin() + pos, v.begin() + pos + 1, v.begin() + i + 1);
|
||||
child->local_vars.at(i).init = this->local_vars.at(i).init;
|
||||
|
||||
|
||||
if (child->local_vars_public_count <= i)
|
||||
child->local_vars_public_count++;
|
||||
}
|
||||
@ -83,7 +83,7 @@ void block::merge(const std::vector<block*>& childs)
|
||||
{
|
||||
if (childs.size() == 0) return;
|
||||
|
||||
for (std::size_t childidx = 0; childidx < childs.size(); childidx++ )
|
||||
for (std::size_t childidx = 0; childidx < childs.size(); childidx++)
|
||||
{
|
||||
auto child = childs[childidx];
|
||||
|
||||
@ -93,7 +93,7 @@ void block::merge(const std::vector<block*>& childs)
|
||||
auto& name = this->local_vars.at(i).name;
|
||||
|
||||
auto pos = child->find_variable(i, name);
|
||||
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
child->local_vars.insert(child->local_vars.begin() + i, this->local_vars.at(i));
|
||||
|
@ -28,7 +28,7 @@ struct block
|
||||
abort_t abort;
|
||||
bool is_last;
|
||||
|
||||
block();
|
||||
block();
|
||||
void transfer(const block::ptr& child);
|
||||
void copy(const block::ptr& child);
|
||||
void append(const std::vector<block*>& childs);
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
namespace xsk::gsc
|
||||
{
|
||||
|
||||
|
||||
class decompiler
|
||||
{
|
||||
public:
|
||||
|
@ -75,7 +75,7 @@ auto node::is_binary() -> bool
|
||||
case kind::expr_div:
|
||||
case kind::expr_mod:
|
||||
return true;
|
||||
default:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -326,7 +326,7 @@ stmt_call::stmt_call(const location& loc, ast::expr expr) : node(kind::stmt_call
|
||||
|
||||
stmt_assign::stmt_assign(ast::expr expr) : node(kind::stmt_assign), expr(std::move(expr)) {}
|
||||
stmt_assign::stmt_assign(const location& loc, ast::expr expr) : node(kind::stmt_assign, loc), expr(std::move(expr)) {}
|
||||
|
||||
|
||||
stmt_endon::stmt_endon(expr obj, expr event) : node(kind::stmt_endon), obj(std::move(obj)), event(std::move(event)) {}
|
||||
stmt_endon::stmt_endon(const location& loc, expr obj, expr event) : node(kind::stmt_endon, loc), obj(std::move(obj)), event(std::move(event)) {}
|
||||
|
||||
@ -503,7 +503,7 @@ auto expr_istring::print() const -> std::string
|
||||
|
||||
auto expr_path::print() const -> std::string
|
||||
{
|
||||
return value;
|
||||
return utils::string::backslash(value);
|
||||
}
|
||||
|
||||
auto expr_identifier::print() const -> std::string
|
||||
@ -630,7 +630,7 @@ auto expr_pointer::print() const -> std::string
|
||||
data += "call ";
|
||||
else if (mode == call::mode::thread)
|
||||
data += "thread ";
|
||||
else if (mode == call::mode::childthread)
|
||||
else if (mode == call::mode::childthread)
|
||||
data += "childthread ";
|
||||
|
||||
return data += "[[ "s + func.print() + " ]](" + args->print() + ")";
|
||||
@ -642,7 +642,7 @@ auto expr_function::print() const -> std::string
|
||||
|
||||
if (mode == call::mode::thread)
|
||||
data += "thread ";
|
||||
else if (mode == call::mode::childthread)
|
||||
else if (mode == call::mode::childthread)
|
||||
data += "childthread ";
|
||||
|
||||
if (path->value != "")
|
||||
@ -903,7 +903,7 @@ auto stmt_endon::print() const -> std::string
|
||||
auto stmt_notify::print() const -> std::string
|
||||
{
|
||||
if (args->list.size() == 0)
|
||||
return obj.print() + " notify( " + event.print() + " );";
|
||||
return obj.print() + " notify( " + event.print() + " );";
|
||||
else
|
||||
return obj.print() + " notify( " + event.print() + ", " + args->print() + " );";
|
||||
};
|
||||
@ -956,7 +956,7 @@ auto stmt_if::print() const -> std::string
|
||||
data += indented(indent_) + stmt.print();
|
||||
indent_ -= 4;
|
||||
}
|
||||
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
@ -995,7 +995,7 @@ auto stmt_ifelse::print() const -> std::string
|
||||
indent_ -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
@ -1092,9 +1092,9 @@ auto stmt_foreach::print() const -> std::string
|
||||
std::string data;
|
||||
|
||||
data += "foreach ( ";
|
||||
|
||||
|
||||
if (use_key) data += key_expr.print() + ", ";
|
||||
|
||||
|
||||
data += value_expr.print() + " in " + array_expr.print() + " )\n";
|
||||
|
||||
if (stmt == kind::stmt_list)
|
||||
|
@ -460,7 +460,7 @@ public:
|
||||
protected:
|
||||
static std::uint32_t indent_;
|
||||
static void reset_indentation();
|
||||
static std::string indented(std::uint32_t indent);
|
||||
static std::string indented(std::uint32_t indent);
|
||||
};
|
||||
|
||||
struct expr_true : public node
|
||||
|
@ -10,8 +10,8 @@ namespace xsk::gsc
|
||||
|
||||
enum class build
|
||||
{
|
||||
dev,
|
||||
prod,
|
||||
dev,
|
||||
prod,
|
||||
};
|
||||
|
||||
enum class abort_t
|
||||
@ -83,22 +83,4 @@ struct function
|
||||
function() : index(0), size(0), id(0) {}
|
||||
};
|
||||
|
||||
struct pair_8C
|
||||
{
|
||||
std::uint8_t key;
|
||||
const char* value;
|
||||
};
|
||||
|
||||
struct pair_16C
|
||||
{
|
||||
std::uint16_t key;
|
||||
const char* value;
|
||||
};
|
||||
|
||||
struct pair_32C
|
||||
{
|
||||
std::uint32_t key;
|
||||
const char* value;
|
||||
};
|
||||
|
||||
} // namespace xsk::gsc
|
||||
|
@ -79,7 +79,7 @@ auto byte_buffer::read_c_string() -> std::string
|
||||
auto byte_buffer::print_bytes(std::size_t pos, std::size_t count) -> std::string
|
||||
{
|
||||
std::string shit;
|
||||
|
||||
|
||||
for (auto i = pos; i < pos + count; i++)
|
||||
{
|
||||
shit += utils::string::va("%s %02X", shit.data(), (*reinterpret_cast<std::uint8_t*>(data_.data() + i)));
|
||||
|
@ -17,11 +17,11 @@ auto zlib::compress(const std::vector<std::uint8_t>& data) -> std::vector<std::u
|
||||
output.resize(length);
|
||||
|
||||
auto result = compress2(reinterpret_cast<Bytef*>(output.data()), &length, reinterpret_cast<const Bytef*>(data.data()), static_cast<uLong>(data.size()), Z_BEST_COMPRESSION);
|
||||
|
||||
|
||||
if (result != Z_OK) return {};
|
||||
|
||||
output.resize(length);
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user