fix warnings

This commit is contained in:
xensik 2022-04-12 19:13:10 +02:00
parent a7cd82508c
commit 8c59bf78ee
123 changed files with 4465 additions and 4240 deletions

View File

@ -26,10 +26,12 @@
%code requires
{
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "h1.hpp"
namespace xsk::gsc::h1 { class lexer; }
typedef void *yyscan_t;
#define YY_DECL xsk::gsc::h1::parser::symbol_type yylex(yyscan_t yyscanner, xsk::gsc::location& loc)
}
%code top

View File

@ -26,6 +26,10 @@
%code requires
{
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "h2.hpp"
namespace xsk::gsc::h2 { class lexer; }
}

View File

@ -26,6 +26,10 @@
%code requires
{
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "iw5.hpp"
namespace xsk::gsc::iw5 { class lexer; }
}

View File

@ -26,6 +26,10 @@
%code requires
{
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "iw6.hpp"
namespace xsk::gsc::iw6 { class lexer; }
}

View File

@ -26,6 +26,10 @@
%code requires
{
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "iw7.hpp"
namespace xsk::gsc::iw7 { class lexer; }
}

View File

@ -26,6 +26,10 @@
%code requires
{
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "iw8.hpp"
namespace xsk::gsc::iw8 { class lexer; }
}

View File

@ -26,6 +26,10 @@
%code requires
{
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "s1.hpp"
namespace xsk::gsc::s1 { class lexer; }
}

View File

@ -26,6 +26,10 @@
%code requires
{
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "s2.hpp"
namespace xsk::gsc::s2 { class lexer; }
}

View File

@ -26,6 +26,10 @@
%code requires
{
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "s4.hpp"
namespace xsk::gsc::s4 { class lexer; }
}

View File

@ -26,6 +26,10 @@
%code requires
{
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "t6.hpp"
namespace xsk::arc::t6 { class lexer; }
}

View File

@ -5,34 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4005)
#pragma warning(disable:4065)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/iw5_console.hpp"

View File

@ -5,34 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4005)
#pragma warning(disable:4065)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/iw6_console.hpp"

View File

@ -5,34 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4005)
#pragma warning(disable:4065)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/s1_console.hpp"

View File

@ -5,35 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4005)
#pragma warning(disable:4065)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <cassert>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/t4.hpp"

View File

@ -5,35 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4005)
#pragma warning(disable:4065)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <cassert>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/t5.hpp"

View File

@ -5,38 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4005)
#pragma warning(disable:4018)
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4389)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <set>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/h1.hpp"

View File

@ -143,7 +143,7 @@ void assembler::assemble_function(const function::ptr& func)
func->id = resolver::token_id(func->name);
stack_->write<std::uint32_t>(func->size);
stack_->write<std::uint16_t>(func->id);
stack_->write<std::uint16_t>(static_cast<std::uint16_t>(func->id));
if (func->id == 0)
{
@ -453,7 +453,7 @@ void assembler::assemble_end_switch(const instruction::ptr& inst)
const auto count = std::stoul(inst->data[0]);
script_->write<std::uint16_t>(count);
script_->write<std::uint16_t>(static_cast<std::uint16_t>(count));
std::uint32_t index = inst->index + 3;
@ -520,15 +520,15 @@ void assembler::assemble_jump(const instruction::ptr& inst, bool expr, bool back
if (expr)
{
script_->write<std::int16_t>(addr - inst->index - 3);
script_->write<std::int16_t>(static_cast<std::int16_t>(addr - inst->index - 3));
}
else if (back)
{
script_->write<std::int16_t>((inst->index + 3) - addr);
script_->write<std::int16_t>(static_cast<std::int16_t>((inst->index + 3) - addr));
}
else
{
script_->write<std::int32_t>(addr - inst->index - 5);
script_->write<std::int32_t>(static_cast<std::int32_t>(addr - inst->index - 5));
}
}
@ -547,11 +547,11 @@ void assembler::assemble_offset(std::int32_t offset)
auto assembler::resolve_function(const std::string& name) -> std::int32_t
{
for (const auto& func : functions_)
for (const auto& entry : functions_)
{
if (func->name == name)
if (entry->name == name)
{
return func->index;
return entry->index;
}
}
@ -560,11 +560,11 @@ auto assembler::resolve_function(const std::string& name) -> std::int32_t
auto assembler::resolve_label(const std::string& name) -> std::int32_t
{
for (const auto& func : labels_)
for (const auto& entry : labels_)
{
if (func.second == name)
if (entry.second == name)
{
return func.first;
return entry.first;
}
}

View File

@ -848,7 +848,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
emit_opcode(opcode::OP_endswitch, data);
auto offset = 7 * stmt->stmt->list.size();
auto offset = static_cast<std::uint32_t>(7 * stmt->stmt->list.size());
function_->instructions.back()->size += offset;
index_ += offset;
@ -2670,7 +2670,7 @@ auto compiler::variable_stack_index(const ast::expr_identifier::ptr& name, const
{
if (blk->local_vars.at(i).init)
{
return blk->local_vars_create_count - 1 - i;
return static_cast<std::uint8_t>(blk->local_vars_create_count - 1 - i);
}
throw comp_error(name->loc(), "local variable '" + name->value + "' not initialized.");

View File

@ -1787,7 +1787,7 @@ void decompiler::decompile_statements(const ast::stmt_list::ptr& stmt)
void decompiler::decompile_infinites(const ast::stmt_list::ptr& stmt)
{
for (int i = stmt->list.size() - 1; i >= 0; i--)
for (auto i = stmt->list.size() - 1; i > 0; i--)
{
if (stmt->list.at(i) == ast::kind::asm_jump_back)
{
@ -1950,7 +1950,7 @@ void decompiler::decompile_aborts(const ast::stmt_list::ptr& block)
}
}
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_end = stmt->list.at(begin).as_cond->value;
@ -1978,7 +1978,7 @@ void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t beg
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.loc_end = stmt->list.at(end).loc().label();
@ -2029,7 +2029,7 @@ void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.is_last = true;
@ -2089,7 +2089,7 @@ void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uin
}
}
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = last_location_index(stmt, end) ? blocks_.back().loc_end : stmt->list.at(end + 1).loc().label();
@ -2119,7 +2119,7 @@ void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t start, std::uint32_t end)
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::size_t start, std::size_t end)
{
auto& last = block->list.at(end - 1);
@ -2184,7 +2184,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
decompile_while(block, start, end);
}
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2214,7 +2214,7 @@ void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2245,7 +2245,7 @@ void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2299,7 +2299,7 @@ void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t be
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2366,7 +2366,7 @@ void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t start)
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t start)
{
block blk;
blk.loc_continue = blocks_.back().loc_continue;
@ -2479,7 +2479,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + start, std::move(new_stmt));
}
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool
{
for (auto i = begin; i < end; i++)
{
@ -2498,7 +2498,7 @@ auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::u
return false;
}
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t
{
auto index = 0u;
@ -2516,7 +2516,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
throw decomp_error("LOCATION NOT FOUND! (" + location + ")");
}
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool
{
if (index == stmt->list.size() - 1)
return true;
@ -3334,7 +3334,7 @@ void decompiler::process_var_access(ast::expr& expr, const block::ptr& blk)
void decompiler::process_var_remove(const ast::asm_remove::ptr& expr, const block::ptr& blk)
{
blk->local_vars_public_count = blk->local_vars.size() - std::stoi(expr->index);
blk->local_vars_public_count = static_cast<std::uint32_t>(blk->local_vars.size() - std::stoi(expr->index));
}
} // namespace xsk::gsc::h1

View File

@ -34,19 +34,19 @@ private:
void decompile_switches(const ast::stmt_list::ptr& stmt);
void decompile_ifelses(const ast::stmt_list::ptr& stmt);
void decompile_aborts(const ast::stmt_list::ptr& stmt);
void decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool;
void decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool;
void process_stack(const ast::decl_thread::ptr& thread);
void process_parameters(const ast::expr_parameters::ptr& params, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);

View File

@ -51,7 +51,7 @@ void disassembler::disassemble(const std::string& file, std::vector<std::uint8_t
func->index = static_cast<std::uint32_t>(script_->pos());
func->size = stack_->read<std::uint32_t>();
func->id = stack_->read<std::uint16_t>();
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(func->id);
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(static_cast<std::uint16_t>(func->id));
dissasemble_function(func);

View File

@ -97,7 +97,7 @@ void reader::init(const char* data, size_t size)
{
state = reader::ok;
buffer_pos = data;
bytes_remaining = size;
bytes_remaining = static_cast<std::uint32_t>(size);
last_byte = 0;
current_byte = *data;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// A Bison parser, made by GNU Bison 3.7.5.
// A Bison parser, made by GNU Bison 3.8.2.
// Skeleton interface for Bison LALR(1) parsers in C++
@ -15,7 +15,7 @@
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// As a special exception, you may create a larger work that contains
// part or all of the Bison parser skeleton and distribute that work
@ -47,12 +47,14 @@
// "%code requires" blocks.
#line 28 "parser.ypp"
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "h1.hpp"
namespace xsk::gsc::h1 { class lexer; }
typedef void *yyscan_t;
#define YY_DECL xsk::gsc::h1::parser::symbol_type yylex(yyscan_t yyscanner, xsk::gsc::location& loc)
#line 56 "parser.hpp"
#line 58 "parser.hpp"
# include <cassert>
# include <cstdlib> // std::abort
@ -128,12 +130,18 @@ typedef void *yyscan_t;
# define YY_USE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
# else
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
@ -195,7 +203,7 @@ typedef void *yyscan_t;
#line 13 "parser.ypp"
namespace xsk { namespace gsc { namespace h1 {
#line 199 "parser.hpp"
#line 207 "parser.hpp"
@ -204,27 +212,32 @@ namespace xsk { namespace gsc { namespace h1 {
class parser
{
public:
#ifndef H1STYPE
#ifdef H1STYPE
# ifdef __GNUC__
# pragma GCC message "bison: do not #define H1STYPE in C++, use %define api.value.type"
# endif
typedef H1STYPE value_type;
#else
/// A buffer to store and retrieve objects.
///
/// Sort of a variant, but does not keep track of the nature
/// of the stored data, since that knowledge is available
/// via the current parser state.
class semantic_type
class value_type
{
public:
/// Type of *this.
typedef semantic_type self_type;
typedef value_type self_type;
/// Empty construction.
semantic_type () YY_NOEXCEPT
: yybuffer_ ()
value_type () YY_NOEXCEPT
: yyraw_ ()
, yytypeid_ (YY_NULLPTR)
{}
/// Construct and fill.
template <typename T>
semantic_type (YY_RVREF (T) t)
value_type (YY_RVREF (T) t)
: yytypeid_ (&typeid (T))
{
H1_ASSERT (sizeof (T) <= size);
@ -233,13 +246,13 @@ namespace xsk { namespace gsc { namespace h1 {
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
semantic_type (const self_type&) = delete;
value_type (const self_type&) = delete;
/// Non copyable.
self_type& operator= (const self_type&) = delete;
#endif
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
~value_type () YY_NOEXCEPT
{
H1_ASSERT (!yytypeid_);
}
@ -383,7 +396,7 @@ namespace xsk { namespace gsc { namespace h1 {
private:
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
semantic_type (const self_type&);
value_type (const self_type&);
/// Non copyable.
self_type& operator= (const self_type&);
#endif
@ -393,7 +406,7 @@ namespace xsk { namespace gsc { namespace h1 {
T*
yyas_ () YY_NOEXCEPT
{
void *yyp = yybuffer_.yyraw;
void *yyp = yyraw_;
return static_cast<T*> (yyp);
}
@ -402,7 +415,7 @@ namespace xsk { namespace gsc { namespace h1 {
const T*
yyas_ () const YY_NOEXCEPT
{
const void *yyp = yybuffer_.yyraw;
const void *yyp = yyraw_;
return static_cast<const T*> (yyp);
}
@ -637,18 +650,19 @@ namespace xsk { namespace gsc { namespace h1 {
union
{
/// Strongest alignment constraints.
long double yyalign_me;
long double yyalign_me_;
/// A buffer large enough to store any of the semantic values.
char yyraw[size];
} yybuffer_;
char yyraw_[size];
};
/// Whether the content is built: if defined, the name of the stored type.
const std::type_info *yytypeid_;
};
#else
typedef H1STYPE semantic_type;
#endif
/// Backward compatibility (Bison 3.8).
typedef value_type semantic_type;
/// Symbol locations.
typedef xsk::gsc::location location_type;
@ -795,7 +809,7 @@ namespace xsk { namespace gsc { namespace h1 {
};
/// Token kind, as returned by yylex.
typedef token::yytokentype token_kind_type;
typedef token::token_kind_type token_kind_type;
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type token_type;
@ -1025,7 +1039,7 @@ namespace xsk { namespace gsc { namespace h1 {
typedef Base super_type;
/// Default constructor.
basic_symbol ()
basic_symbol () YY_NOEXCEPT
: value ()
, location ()
{}
@ -2293,6 +2307,8 @@ namespace xsk { namespace gsc { namespace h1 {
clear ();
}
/// Destroy contents, and record that is empty.
void clear () YY_NOEXCEPT
{
@ -2619,7 +2635,7 @@ switch (yykind)
void move (basic_symbol& s);
/// The semantic value.
semantic_type value;
value_type value;
/// The location.
location_type location;
@ -2634,22 +2650,24 @@ switch (yykind)
/// Type access provider for token (enum) based symbols.
struct by_kind
{
/// Default constructor.
by_kind ();
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that);
#endif
/// Copy constructor.
by_kind (const by_kind& that);
/// The symbol kind as needed by the constructor.
typedef token_kind_type kind_type;
/// Default constructor.
by_kind () YY_NOEXCEPT;
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that) YY_NOEXCEPT;
#endif
/// Copy constructor.
by_kind (const by_kind& that) YY_NOEXCEPT;
/// Constructor from (external) token numbers.
by_kind (kind_type t);
by_kind (kind_type t) YY_NOEXCEPT;
/// Record that this symbol is empty.
void clear () YY_NOEXCEPT;
@ -2679,30 +2697,34 @@ switch (yykind)
typedef basic_symbol<by_kind> super_type;
/// Empty symbol.
symbol_type () {}
symbol_type () YY_NOEXCEPT {}
/// Constructor for valueless symbols, and symbols from each type.
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, location_type l)
: super_type(token_type (tok), std::move (l))
: super_type (token_kind_type (tok), std::move (l))
#else
symbol_type (int tok, const location_type& l)
: super_type(token_type (tok), l)
: super_type (token_kind_type (tok), l)
#endif
{
#if !defined _MSC_VER || defined __clang__
H1_ASSERT (tok == token::H1EOF
|| (token::H1error <= tok && tok <= token::MOD)
|| (token::SIZEOF <= tok && tok <= token::POSTDEC));
#endif
}
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, std::string v, location_type l)
: super_type(token_type (tok), std::move (v), std::move (l))
: super_type (token_kind_type (tok), std::move (v), std::move (l))
#else
symbol_type (int tok, const std::string& v, const location_type& l)
: super_type(token_type (tok), v, l)
: super_type (token_kind_type (tok), v, l)
#endif
{
#if !defined _MSC_VER || defined __clang__
H1_ASSERT ((token::PATH <= tok && tok <= token::INTEGER));
#endif
}
};
@ -2751,7 +2773,7 @@ switch (yykind)
/// YYSYMBOL. No bounds checking.
static const char *symbol_name (symbol_kind_type yysymbol);
// Implementation of make_symbol for each symbol type.
// Implementation of make_symbol for each token kind.
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4503,19 +4525,19 @@ switch (yykind)
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
static bool yy_pact_value_is_default_ (int yyvalue);
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
/// Whether the given \c yytable_ value indicates a syntax error.
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
static const short yypact_ninf_;
static const short yytable_ninf_;
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
/// are valid, yet not members of the token_kind_type enum.
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
@ -4542,14 +4564,14 @@ switch (yykind)
static const short yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
// YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
// state STATE-NUM.
static const unsigned char yystos_[];
// YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
// YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.
static const unsigned char yyr1_[];
// YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
// YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.
static const signed char yyr2_[];
@ -4648,7 +4670,7 @@ switch (yykind)
typedef typename S::size_type size_type;
typedef typename std::ptrdiff_t index_type;
stack (size_type n = 200)
stack (size_type n = 200) YY_NOEXCEPT
: seq_ (n)
{}
@ -4727,7 +4749,7 @@ switch (yykind)
class slice
{
public:
slice (const stack& stack, index_type range)
slice (const stack& stack, index_type range) YY_NOEXCEPT
: stack_ (stack)
, range_ (range)
{}
@ -4786,7 +4808,7 @@ switch (yykind)
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
void yypop_ (int n = 1) YY_NOEXCEPT;
/// Constants.
enum
@ -4805,7 +4827,7 @@ switch (yykind)
inline
parser::symbol_kind_type
parser::yytranslate_ (int t)
parser::yytranslate_ (int t) YY_NOEXCEPT
{
return static_cast<symbol_kind_type> (t);
}
@ -5114,6 +5136,7 @@ switch (yykind)
template <typename Base>
parser::symbol_kind_type
parser::basic_symbol<Base>::type_get () const YY_NOEXCEPT
@ -5121,6 +5144,7 @@ switch (yykind)
return this->kind ();
}
template <typename Base>
bool
parser::basic_symbol<Base>::empty () const YY_NOEXCEPT
@ -5431,13 +5455,13 @@ switch (yykind)
// by_kind.
inline
parser::by_kind::by_kind ()
parser::by_kind::by_kind () YY_NOEXCEPT
: kind_ (symbol_kind::S_YYEMPTY)
{}
#if 201103L <= YY_CPLUSPLUS
inline
parser::by_kind::by_kind (by_kind&& that)
parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
: kind_ (that.kind_)
{
that.clear ();
@ -5445,15 +5469,17 @@ switch (yykind)
#endif
inline
parser::by_kind::by_kind (const by_kind& that)
parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
: kind_ (that.kind_)
{}
inline
parser::by_kind::by_kind (token_kind_type t)
parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
: kind_ (yytranslate_ (t))
{}
inline
void
parser::by_kind::clear () YY_NOEXCEPT
@ -5476,6 +5502,7 @@ switch (yykind)
return kind_;
}
inline
parser::symbol_kind_type
parser::by_kind::type_get () const YY_NOEXCEPT
@ -5483,9 +5510,10 @@ switch (yykind)
return this->kind ();
}
#line 13 "parser.ypp"
} } } // xsk::gsc::h1
#line 5489 "parser.hpp"
#line 5517 "parser.hpp"

View File

@ -6,6 +6,11 @@
#include "stdafx.hpp"
#include "h1.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4244)
#endif
namespace xsk::gsc::h1
{
@ -61,7 +66,7 @@ auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = function_map_rev.find(name);
@ -90,7 +95,7 @@ auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = method_map_rev.find(name);
@ -119,7 +124,7 @@ auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = file_map_rev.find(name);
@ -148,7 +153,7 @@ auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = token_map_rev.find(name);
@ -212,7 +217,7 @@ auto resolver::make_token(std::string_view str) -> std::string
for (std::size_t i = 0; i < data.size(); i++)
{
data[i] = std::tolower(str[i]);
data[i] = static_cast<char>(std::tolower(static_cast<unsigned char>(str[i])));
if (data[i] == '\\') data[i] = '/';
}
@ -4062,6 +4067,10 @@ __init__ _;
} // namespace xsk::gsc::h1
#ifdef _MSC_VER
#pragma warning(pop)
#endif
// ps4 function_list
/*

View File

@ -5,38 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4005)
#pragma warning(disable:4018)
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4389)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <set>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/h2.hpp"

View File

@ -143,7 +143,7 @@ void assembler::assemble_function(const function::ptr& func)
func->id = resolver::token_id(func->name);
stack_->write<std::uint32_t>(func->size);
stack_->write<std::uint16_t>(func->id);
stack_->write<std::uint16_t>(static_cast<std::uint16_t>(func->id));
if (func->id == 0)
{
@ -453,7 +453,7 @@ void assembler::assemble_end_switch(const instruction::ptr& inst)
const auto count = std::stoul(inst->data[0]);
script_->write<std::uint16_t>(count);
script_->write<std::uint16_t>(static_cast<std::uint16_t>(count));
std::uint32_t index = inst->index + 3;
@ -520,15 +520,15 @@ void assembler::assemble_jump(const instruction::ptr& inst, bool expr, bool back
if (expr)
{
script_->write<std::int16_t>(addr - inst->index - 3);
script_->write<std::int16_t>(static_cast<std::int16_t>(addr - inst->index - 3));
}
else if (back)
{
script_->write<std::int16_t>((inst->index + 3) - addr);
script_->write<std::int16_t>(static_cast<std::int16_t>((inst->index + 3) - addr));
}
else
{
script_->write<std::int32_t>(addr - inst->index - 5);
script_->write<std::int32_t>(static_cast<std::int32_t>(addr - inst->index - 5));
}
}
@ -547,11 +547,11 @@ void assembler::assemble_offset(std::int32_t offset)
auto assembler::resolve_function(const std::string& name) -> std::int32_t
{
for (const auto& func : functions_)
for (const auto& entry : functions_)
{
if (func->name == name)
if (entry->name == name)
{
return func->index;
return entry->index;
}
}
@ -560,11 +560,11 @@ auto assembler::resolve_function(const std::string& name) -> std::int32_t
auto assembler::resolve_label(const std::string& name) -> std::int32_t
{
for (const auto& func : labels_)
for (const auto& entry : labels_)
{
if (func.second == name)
if (entry.second == name)
{
return func.first;
return entry.first;
}
}

View File

@ -848,7 +848,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
emit_opcode(opcode::OP_endswitch, data);
auto offset = 7 * stmt->stmt->list.size();
auto offset = static_cast<std::uint32_t>(7 * stmt->stmt->list.size());
function_->instructions.back()->size += offset;
index_ += offset;
@ -2669,7 +2669,7 @@ auto compiler::variable_stack_index(const ast::expr_identifier::ptr& name, const
{
if (blk->local_vars.at(i).init)
{
return blk->local_vars_create_count - 1 - i;
return static_cast<std::uint8_t>(blk->local_vars_create_count - 1 - i);
}
throw comp_error(name->loc(), "local variable '" + name->value + "' not initialized.");

View File

@ -1787,7 +1787,7 @@ void decompiler::decompile_statements(const ast::stmt_list::ptr& stmt)
void decompiler::decompile_infinites(const ast::stmt_list::ptr& stmt)
{
for (int i = stmt->list.size() - 1; i >= 0; i--)
for (auto i = stmt->list.size() - 1; i > 0; i--)
{
if (stmt->list.at(i) == ast::kind::asm_jump_back)
{
@ -1950,7 +1950,7 @@ void decompiler::decompile_aborts(const ast::stmt_list::ptr& block)
}
}
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_end = stmt->list.at(begin).as_cond->value;
@ -1978,7 +1978,7 @@ void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t beg
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.loc_end = stmt->list.at(end).loc().label();
@ -2029,7 +2029,7 @@ void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.is_last = true;
@ -2089,7 +2089,7 @@ void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uin
}
}
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = last_location_index(stmt, end) ? blocks_.back().loc_end : stmt->list.at(end + 1).loc().label();
@ -2119,7 +2119,7 @@ void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t start, std::uint32_t end)
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::size_t start, std::size_t end)
{
auto& last = block->list.at(end - 1);
@ -2184,7 +2184,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
decompile_while(block, start, end);
}
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2214,7 +2214,7 @@ void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2245,7 +2245,7 @@ void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2299,7 +2299,7 @@ void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t be
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2366,7 +2366,7 @@ void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t start)
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t start)
{
block blk;
blk.loc_continue = blocks_.back().loc_continue;
@ -2479,7 +2479,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + start, std::move(new_stmt));
}
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool
{
for (auto i = begin; i < end; i++)
{
@ -2498,7 +2498,7 @@ auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::u
return false;
}
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t
{
auto index = 0u;
@ -2516,7 +2516,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
throw decomp_error("LOCATION NOT FOUND! (" + location + ")");
}
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool
{
if (index == stmt->list.size() - 1)
return true;
@ -3334,7 +3334,7 @@ void decompiler::process_var_access(ast::expr& expr, const block::ptr& blk)
void decompiler::process_var_remove(const ast::asm_remove::ptr& expr, const block::ptr& blk)
{
blk->local_vars_public_count = blk->local_vars.size() - std::stoi(expr->index);
blk->local_vars_public_count = static_cast<std::uint32_t>(blk->local_vars.size() - std::stoi(expr->index));
}
} // namespace xsk::gsc::h2

View File

@ -34,19 +34,19 @@ private:
void decompile_switches(const ast::stmt_list::ptr& stmt);
void decompile_ifelses(const ast::stmt_list::ptr& stmt);
void decompile_aborts(const ast::stmt_list::ptr& stmt);
void decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool;
void decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool;
void process_stack(const ast::decl_thread::ptr& thread);
void process_parameters(const ast::expr_parameters::ptr& params, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);

View File

@ -51,7 +51,7 @@ void disassembler::disassemble(const std::string& file, std::vector<std::uint8_t
func->index = static_cast<std::uint32_t>(script_->pos());
func->size = stack_->read<std::uint32_t>();
func->id = stack_->read<std::uint16_t>();
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(func->id);
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(static_cast<std::uint16_t>(func->id));
dissasemble_function(func);

View File

@ -97,7 +97,7 @@ void reader::init(const char* data, size_t size)
{
state = reader::ok;
buffer_pos = data;
bytes_remaining = size;
bytes_remaining = static_cast<std::uint32_t>(size);
last_byte = 0;
current_byte = *data;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// A Bison parser, made by GNU Bison 3.7.5.
// A Bison parser, made by GNU Bison 3.8.2.
// Skeleton interface for Bison LALR(1) parsers in C++
@ -15,7 +15,7 @@
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// As a special exception, you may create a larger work that contains
// part or all of the Bison parser skeleton and distribute that work
@ -47,10 +47,14 @@
// "%code requires" blocks.
#line 28 "parser.ypp"
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "h2.hpp"
namespace xsk::gsc::h2 { class lexer; }
#line 54 "parser.hpp"
#line 58 "parser.hpp"
# include <cassert>
# include <cstdlib> // std::abort
@ -126,12 +130,18 @@ namespace xsk::gsc::h2 { class lexer; }
# define YY_USE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
# else
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
@ -193,7 +203,7 @@ namespace xsk::gsc::h2 { class lexer; }
#line 13 "parser.ypp"
namespace xsk { namespace gsc { namespace h2 {
#line 197 "parser.hpp"
#line 207 "parser.hpp"
@ -202,27 +212,32 @@ namespace xsk { namespace gsc { namespace h2 {
class parser
{
public:
#ifndef H2STYPE
#ifdef H2STYPE
# ifdef __GNUC__
# pragma GCC message "bison: do not #define H2STYPE in C++, use %define api.value.type"
# endif
typedef H2STYPE value_type;
#else
/// A buffer to store and retrieve objects.
///
/// Sort of a variant, but does not keep track of the nature
/// of the stored data, since that knowledge is available
/// via the current parser state.
class semantic_type
class value_type
{
public:
/// Type of *this.
typedef semantic_type self_type;
typedef value_type self_type;
/// Empty construction.
semantic_type () YY_NOEXCEPT
: yybuffer_ ()
value_type () YY_NOEXCEPT
: yyraw_ ()
, yytypeid_ (YY_NULLPTR)
{}
/// Construct and fill.
template <typename T>
semantic_type (YY_RVREF (T) t)
value_type (YY_RVREF (T) t)
: yytypeid_ (&typeid (T))
{
H2_ASSERT (sizeof (T) <= size);
@ -231,13 +246,13 @@ namespace xsk { namespace gsc { namespace h2 {
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
semantic_type (const self_type&) = delete;
value_type (const self_type&) = delete;
/// Non copyable.
self_type& operator= (const self_type&) = delete;
#endif
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
~value_type () YY_NOEXCEPT
{
H2_ASSERT (!yytypeid_);
}
@ -381,7 +396,7 @@ namespace xsk { namespace gsc { namespace h2 {
private:
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
semantic_type (const self_type&);
value_type (const self_type&);
/// Non copyable.
self_type& operator= (const self_type&);
#endif
@ -391,7 +406,7 @@ namespace xsk { namespace gsc { namespace h2 {
T*
yyas_ () YY_NOEXCEPT
{
void *yyp = yybuffer_.yyraw;
void *yyp = yyraw_;
return static_cast<T*> (yyp);
}
@ -400,7 +415,7 @@ namespace xsk { namespace gsc { namespace h2 {
const T*
yyas_ () const YY_NOEXCEPT
{
const void *yyp = yybuffer_.yyraw;
const void *yyp = yyraw_;
return static_cast<const T*> (yyp);
}
@ -635,18 +650,19 @@ namespace xsk { namespace gsc { namespace h2 {
union
{
/// Strongest alignment constraints.
long double yyalign_me;
long double yyalign_me_;
/// A buffer large enough to store any of the semantic values.
char yyraw[size];
} yybuffer_;
char yyraw_[size];
};
/// Whether the content is built: if defined, the name of the stored type.
const std::type_info *yytypeid_;
};
#else
typedef H2STYPE semantic_type;
#endif
/// Backward compatibility (Bison 3.8).
typedef value_type semantic_type;
/// Symbol locations.
typedef xsk::gsc::location location_type;
@ -793,7 +809,7 @@ namespace xsk { namespace gsc { namespace h2 {
};
/// Token kind, as returned by yylex.
typedef token::yytokentype token_kind_type;
typedef token::token_kind_type token_kind_type;
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type token_type;
@ -1023,7 +1039,7 @@ namespace xsk { namespace gsc { namespace h2 {
typedef Base super_type;
/// Default constructor.
basic_symbol ()
basic_symbol () YY_NOEXCEPT
: value ()
, location ()
{}
@ -2291,6 +2307,8 @@ namespace xsk { namespace gsc { namespace h2 {
clear ();
}
/// Destroy contents, and record that is empty.
void clear () YY_NOEXCEPT
{
@ -2617,7 +2635,7 @@ switch (yykind)
void move (basic_symbol& s);
/// The semantic value.
semantic_type value;
value_type value;
/// The location.
location_type location;
@ -2632,22 +2650,24 @@ switch (yykind)
/// Type access provider for token (enum) based symbols.
struct by_kind
{
/// Default constructor.
by_kind ();
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that);
#endif
/// Copy constructor.
by_kind (const by_kind& that);
/// The symbol kind as needed by the constructor.
typedef token_kind_type kind_type;
/// Default constructor.
by_kind () YY_NOEXCEPT;
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that) YY_NOEXCEPT;
#endif
/// Copy constructor.
by_kind (const by_kind& that) YY_NOEXCEPT;
/// Constructor from (external) token numbers.
by_kind (kind_type t);
by_kind (kind_type t) YY_NOEXCEPT;
/// Record that this symbol is empty.
void clear () YY_NOEXCEPT;
@ -2677,30 +2697,34 @@ switch (yykind)
typedef basic_symbol<by_kind> super_type;
/// Empty symbol.
symbol_type () {}
symbol_type () YY_NOEXCEPT {}
/// Constructor for valueless symbols, and symbols from each type.
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, location_type l)
: super_type(token_type (tok), std::move (l))
: super_type (token_kind_type (tok), std::move (l))
#else
symbol_type (int tok, const location_type& l)
: super_type(token_type (tok), l)
: super_type (token_kind_type (tok), l)
#endif
{
#if !defined _MSC_VER || defined __clang__
H2_ASSERT (tok == token::H2EOF
|| (token::H2error <= tok && tok <= token::MOD)
|| (token::SIZEOF <= tok && tok <= token::POSTDEC));
#endif
}
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, std::string v, location_type l)
: super_type(token_type (tok), std::move (v), std::move (l))
: super_type (token_kind_type (tok), std::move (v), std::move (l))
#else
symbol_type (int tok, const std::string& v, const location_type& l)
: super_type(token_type (tok), v, l)
: super_type (token_kind_type (tok), v, l)
#endif
{
#if !defined _MSC_VER || defined __clang__
H2_ASSERT ((token::PATH <= tok && tok <= token::INTEGER));
#endif
}
};
@ -2749,7 +2773,7 @@ switch (yykind)
/// YYSYMBOL. No bounds checking.
static const char *symbol_name (symbol_kind_type yysymbol);
// Implementation of make_symbol for each symbol type.
// Implementation of make_symbol for each token kind.
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4501,19 +4525,19 @@ switch (yykind)
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
static bool yy_pact_value_is_default_ (int yyvalue);
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
/// Whether the given \c yytable_ value indicates a syntax error.
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
static const short yypact_ninf_;
static const short yytable_ninf_;
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
/// are valid, yet not members of the token_kind_type enum.
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
@ -4540,14 +4564,14 @@ switch (yykind)
static const short yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
// YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
// state STATE-NUM.
static const unsigned char yystos_[];
// YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
// YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.
static const unsigned char yyr1_[];
// YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
// YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.
static const signed char yyr2_[];
@ -4646,7 +4670,7 @@ switch (yykind)
typedef typename S::size_type size_type;
typedef typename std::ptrdiff_t index_type;
stack (size_type n = 200)
stack (size_type n = 200) YY_NOEXCEPT
: seq_ (n)
{}
@ -4725,7 +4749,7 @@ switch (yykind)
class slice
{
public:
slice (const stack& stack, index_type range)
slice (const stack& stack, index_type range) YY_NOEXCEPT
: stack_ (stack)
, range_ (range)
{}
@ -4784,7 +4808,7 @@ switch (yykind)
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
void yypop_ (int n = 1) YY_NOEXCEPT;
/// Constants.
enum
@ -4803,7 +4827,7 @@ switch (yykind)
inline
parser::symbol_kind_type
parser::yytranslate_ (int t)
parser::yytranslate_ (int t) YY_NOEXCEPT
{
return static_cast<symbol_kind_type> (t);
}
@ -5112,6 +5136,7 @@ switch (yykind)
template <typename Base>
parser::symbol_kind_type
parser::basic_symbol<Base>::type_get () const YY_NOEXCEPT
@ -5119,6 +5144,7 @@ switch (yykind)
return this->kind ();
}
template <typename Base>
bool
parser::basic_symbol<Base>::empty () const YY_NOEXCEPT
@ -5429,13 +5455,13 @@ switch (yykind)
// by_kind.
inline
parser::by_kind::by_kind ()
parser::by_kind::by_kind () YY_NOEXCEPT
: kind_ (symbol_kind::S_YYEMPTY)
{}
#if 201103L <= YY_CPLUSPLUS
inline
parser::by_kind::by_kind (by_kind&& that)
parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
: kind_ (that.kind_)
{
that.clear ();
@ -5443,15 +5469,17 @@ switch (yykind)
#endif
inline
parser::by_kind::by_kind (const by_kind& that)
parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
: kind_ (that.kind_)
{}
inline
parser::by_kind::by_kind (token_kind_type t)
parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
: kind_ (yytranslate_ (t))
{}
inline
void
parser::by_kind::clear () YY_NOEXCEPT
@ -5474,6 +5502,7 @@ switch (yykind)
return kind_;
}
inline
parser::symbol_kind_type
parser::by_kind::type_get () const YY_NOEXCEPT
@ -5481,9 +5510,10 @@ switch (yykind)
return this->kind ();
}
#line 13 "parser.ypp"
} } } // xsk::gsc::h2
#line 5487 "parser.hpp"
#line 5517 "parser.hpp"

View File

@ -6,6 +6,11 @@
#include "stdafx.hpp"
#include "h2.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4244)
#endif
namespace xsk::gsc::h2
{
@ -61,7 +66,7 @@ auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = function_map_rev.find(name);
@ -90,7 +95,7 @@ auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = method_map_rev.find(name);
@ -119,7 +124,7 @@ auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = file_map_rev.find(name);
@ -148,7 +153,7 @@ auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = token_map_rev.find(name);
@ -212,7 +217,7 @@ auto resolver::make_token(std::string_view str) -> std::string
for (std::size_t i = 0; i < data.size(); i++)
{
data[i] = std::tolower(str[i]);
data[i] = static_cast<char>(std::tolower(static_cast<unsigned char>(str[i])));
if (data[i] == '\\') data[i] = '/';
}
@ -2790,3 +2795,7 @@ struct __init__
__init__ _;
} // namespace xsk::gsc::h2
#ifdef _MSC_VER
#pragma warning(pop)
#endif

View File

@ -5,39 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4005)
#pragma warning(disable:4018)
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4389)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <set>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <cassert>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/iw5.hpp"

View File

@ -144,7 +144,7 @@ void assembler::assemble_function(const function::ptr& func)
func->id = resolver::token_id(func->name);
stack_->write<std::uint32_t>(func->size);
stack_->write<std::uint16_t>(func->id);
stack_->write<std::uint16_t>(static_cast<std::uint16_t>(func->id));
if (func->id == 0)
{
@ -452,7 +452,7 @@ void assembler::assemble_end_switch(const instruction::ptr& inst)
const auto count = std::stoul(inst->data[0]);
script_->write<std::uint16_t>(count);
script_->write<std::uint16_t>(static_cast<std::uint16_t>(count));
std::uint32_t index = inst->index + 3;
@ -519,15 +519,15 @@ void assembler::assemble_jump(const instruction::ptr& inst, bool expr, bool back
if (expr)
{
script_->write<std::int16_t>(addr - inst->index - 3);
script_->write<std::int16_t>(static_cast<std::int16_t>(addr - inst->index - 3));
}
else if (back)
{
script_->write<std::int16_t>((inst->index + 3) - addr);
script_->write<std::int16_t>(static_cast<std::int16_t>((inst->index + 3) - addr));
}
else
{
script_->write<std::int32_t>(addr - inst->index - 5);
script_->write<std::int32_t>(static_cast<std::int32_t>(addr - inst->index - 5));
}
}
@ -546,11 +546,11 @@ void assembler::assemble_offset(std::int32_t offset)
auto assembler::resolve_function(const std::string& name) -> std::int32_t
{
for (const auto& func : functions_)
for (const auto& entry : functions_)
{
if (func->name == name)
if (entry->name == name)
{
return func->index;
return entry->index;
}
}
@ -559,11 +559,11 @@ auto assembler::resolve_function(const std::string& name) -> std::int32_t
auto assembler::resolve_label(const std::string& name) -> std::int32_t
{
for (const auto& func : labels_)
for (const auto& entry : labels_)
{
if (func.second == name)
if (entry.second == name)
{
return func.first;
return entry.first;
}
}

View File

@ -840,7 +840,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
emit_opcode(opcode::OP_endswitch, data);
auto offset = 7 * stmt->stmt->list.size();
auto offset = static_cast<std::uint32_t>(7 * stmt->stmt->list.size());
function_->instructions.back()->size += offset;
index_ += offset;
@ -2660,7 +2660,7 @@ auto compiler::variable_stack_index(const ast::expr_identifier::ptr& name, const
{
if (blk->local_vars.at(i).init)
{
return blk->local_vars_create_count - 1 - i;
return static_cast<std::uint8_t>(blk->local_vars_create_count - 1 - i);
}
throw comp_error(name->loc(), "local variable '" + name->value + "' not initialized.");

View File

@ -1781,7 +1781,7 @@ void decompiler::decompile_statements(const ast::stmt_list::ptr& stmt)
void decompiler::decompile_infinites(const ast::stmt_list::ptr& stmt)
{
for (int i = stmt->list.size() - 1; i >= 0; i--)
for (auto i = stmt->list.size() - 1; i > 0; i--)
{
if (stmt->list.at(i) == ast::kind::asm_jump_back)
{
@ -1944,7 +1944,7 @@ void decompiler::decompile_aborts(const ast::stmt_list::ptr& block)
}
}
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_end = stmt->list.at(begin).as_cond->value;
@ -1972,7 +1972,7 @@ void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t beg
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.loc_end = stmt->list.at(end).loc().label();
@ -2023,7 +2023,7 @@ void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.is_last = true;
@ -2083,7 +2083,7 @@ void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uin
}
}
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = last_location_index(stmt, end) ? blocks_.back().loc_end : stmt->list.at(end + 1).loc().label();
@ -2113,7 +2113,7 @@ void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t start, std::uint32_t end)
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::size_t start, std::size_t end)
{
auto& last = block->list.at(end - 1);
@ -2178,7 +2178,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
decompile_while(block, start, end);
}
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2208,7 +2208,7 @@ void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2239,7 +2239,7 @@ void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2293,7 +2293,7 @@ void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t be
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2360,7 +2360,7 @@ void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t start)
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t start)
{
block blk;
blk.loc_continue = blocks_.back().loc_continue;
@ -2473,7 +2473,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + start, std::move(new_stmt));
}
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool
{
for (auto i = begin; i < end; i++)
{
@ -2492,7 +2492,7 @@ auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::u
return false;
}
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t
{
auto index = 0u;
@ -2510,7 +2510,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
throw decomp_error("LOCATION NOT FOUND! (" + location + ")");
}
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool
{
if (index == stmt->list.size() - 1)
return true;
@ -3328,7 +3328,7 @@ void decompiler::process_var_access(ast::expr& expr, const block::ptr& blk)
void decompiler::process_var_remove(const ast::asm_remove::ptr& expr, const block::ptr& blk)
{
blk->local_vars_public_count = blk->local_vars.size() - std::stoi(expr->index);
blk->local_vars_public_count = static_cast<std::uint32_t>(blk->local_vars.size() - std::stoi(expr->index));
}
} // namespace xsk::gsc::iw5

View File

@ -34,19 +34,19 @@ private:
void decompile_switches(const ast::stmt_list::ptr& stmt);
void decompile_ifelses(const ast::stmt_list::ptr& stmt);
void decompile_aborts(const ast::stmt_list::ptr& stmt);
void decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool;
void decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool;
void process_stack(const ast::decl_thread::ptr& thread);
void process_parameters(const ast::expr_parameters::ptr& params, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);

View File

@ -51,7 +51,7 @@ void disassembler::disassemble(const std::string& file, std::vector<std::uint8_t
func->index = static_cast<std::uint32_t>(script_->pos());
func->size = stack_->read<std::uint32_t>();
func->id = stack_->read<std::uint16_t>();
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(func->id);
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(static_cast<std::uint16_t>(func->id));
dissasemble_function(func);

View File

@ -96,7 +96,7 @@ void reader::init(const char* data, size_t size)
{
state = reader::ok;
buffer_pos = data;
bytes_remaining = size;
bytes_remaining = static_cast<std::uint32_t>(size);
last_byte = 0;
current_byte = *data;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// A Bison parser, made by GNU Bison 3.7.5.
// A Bison parser, made by GNU Bison 3.8.2.
// Skeleton interface for Bison LALR(1) parsers in C++
@ -15,7 +15,7 @@
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// As a special exception, you may create a larger work that contains
// part or all of the Bison parser skeleton and distribute that work
@ -47,10 +47,14 @@
// "%code requires" blocks.
#line 28 "parser.ypp"
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "iw5.hpp"
namespace xsk::gsc::iw5 { class lexer; }
#line 54 "parser.hpp"
#line 58 "parser.hpp"
# include <cassert>
# include <cstdlib> // std::abort
@ -126,12 +130,18 @@ namespace xsk::gsc::iw5 { class lexer; }
# define YY_USE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
# else
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
@ -193,7 +203,7 @@ namespace xsk::gsc::iw5 { class lexer; }
#line 13 "parser.ypp"
namespace xsk { namespace gsc { namespace iw5 {
#line 197 "parser.hpp"
#line 207 "parser.hpp"
@ -202,27 +212,32 @@ namespace xsk { namespace gsc { namespace iw5 {
class parser
{
public:
#ifndef IW5STYPE
#ifdef IW5STYPE
# ifdef __GNUC__
# pragma GCC message "bison: do not #define IW5STYPE in C++, use %define api.value.type"
# endif
typedef IW5STYPE value_type;
#else
/// A buffer to store and retrieve objects.
///
/// Sort of a variant, but does not keep track of the nature
/// of the stored data, since that knowledge is available
/// via the current parser state.
class semantic_type
class value_type
{
public:
/// Type of *this.
typedef semantic_type self_type;
typedef value_type self_type;
/// Empty construction.
semantic_type () YY_NOEXCEPT
: yybuffer_ ()
value_type () YY_NOEXCEPT
: yyraw_ ()
, yytypeid_ (YY_NULLPTR)
{}
/// Construct and fill.
template <typename T>
semantic_type (YY_RVREF (T) t)
value_type (YY_RVREF (T) t)
: yytypeid_ (&typeid (T))
{
IW5_ASSERT (sizeof (T) <= size);
@ -231,13 +246,13 @@ namespace xsk { namespace gsc { namespace iw5 {
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
semantic_type (const self_type&) = delete;
value_type (const self_type&) = delete;
/// Non copyable.
self_type& operator= (const self_type&) = delete;
#endif
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
~value_type () YY_NOEXCEPT
{
IW5_ASSERT (!yytypeid_);
}
@ -381,7 +396,7 @@ namespace xsk { namespace gsc { namespace iw5 {
private:
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
semantic_type (const self_type&);
value_type (const self_type&);
/// Non copyable.
self_type& operator= (const self_type&);
#endif
@ -391,7 +406,7 @@ namespace xsk { namespace gsc { namespace iw5 {
T*
yyas_ () YY_NOEXCEPT
{
void *yyp = yybuffer_.yyraw;
void *yyp = yyraw_;
return static_cast<T*> (yyp);
}
@ -400,7 +415,7 @@ namespace xsk { namespace gsc { namespace iw5 {
const T*
yyas_ () const YY_NOEXCEPT
{
const void *yyp = yybuffer_.yyraw;
const void *yyp = yyraw_;
return static_cast<const T*> (yyp);
}
@ -632,18 +647,19 @@ namespace xsk { namespace gsc { namespace iw5 {
union
{
/// Strongest alignment constraints.
long double yyalign_me;
long double yyalign_me_;
/// A buffer large enough to store any of the semantic values.
char yyraw[size];
} yybuffer_;
char yyraw_[size];
};
/// Whether the content is built: if defined, the name of the stored type.
const std::type_info *yytypeid_;
};
#else
typedef IW5STYPE semantic_type;
#endif
/// Backward compatibility (Bison 3.8).
typedef value_type semantic_type;
/// Symbol locations.
typedef xsk::gsc::location location_type;
@ -789,7 +805,7 @@ namespace xsk { namespace gsc { namespace iw5 {
};
/// Token kind, as returned by yylex.
typedef token::yytokentype token_kind_type;
typedef token::token_kind_type token_kind_type;
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type token_type;
@ -1017,7 +1033,7 @@ namespace xsk { namespace gsc { namespace iw5 {
typedef Base super_type;
/// Default constructor.
basic_symbol ()
basic_symbol () YY_NOEXCEPT
: value ()
, location ()
{}
@ -2267,6 +2283,8 @@ namespace xsk { namespace gsc { namespace iw5 {
clear ();
}
/// Destroy contents, and record that is empty.
void clear () YY_NOEXCEPT
{
@ -2589,7 +2607,7 @@ switch (yykind)
void move (basic_symbol& s);
/// The semantic value.
semantic_type value;
value_type value;
/// The location.
location_type location;
@ -2604,22 +2622,24 @@ switch (yykind)
/// Type access provider for token (enum) based symbols.
struct by_kind
{
/// Default constructor.
by_kind ();
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that);
#endif
/// Copy constructor.
by_kind (const by_kind& that);
/// The symbol kind as needed by the constructor.
typedef token_kind_type kind_type;
/// Default constructor.
by_kind () YY_NOEXCEPT;
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that) YY_NOEXCEPT;
#endif
/// Copy constructor.
by_kind (const by_kind& that) YY_NOEXCEPT;
/// Constructor from (external) token numbers.
by_kind (kind_type t);
by_kind (kind_type t) YY_NOEXCEPT;
/// Record that this symbol is empty.
void clear () YY_NOEXCEPT;
@ -2649,30 +2669,34 @@ switch (yykind)
typedef basic_symbol<by_kind> super_type;
/// Empty symbol.
symbol_type () {}
symbol_type () YY_NOEXCEPT {}
/// Constructor for valueless symbols, and symbols from each type.
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, location_type l)
: super_type(token_type (tok), std::move (l))
: super_type (token_kind_type (tok), std::move (l))
#else
symbol_type (int tok, const location_type& l)
: super_type(token_type (tok), l)
: super_type (token_kind_type (tok), l)
#endif
{
#if !defined _MSC_VER || defined __clang__
IW5_ASSERT (tok == token::IW5EOF
|| (token::IW5error <= tok && tok <= token::MOD)
|| (token::SIZEOF <= tok && tok <= token::POSTDEC));
#endif
}
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, std::string v, location_type l)
: super_type(token_type (tok), std::move (v), std::move (l))
: super_type (token_kind_type (tok), std::move (v), std::move (l))
#else
symbol_type (int tok, const std::string& v, const location_type& l)
: super_type(token_type (tok), v, l)
: super_type (token_kind_type (tok), v, l)
#endif
{
#if !defined _MSC_VER || defined __clang__
IW5_ASSERT ((token::PATH <= tok && tok <= token::INTEGER));
#endif
}
};
@ -2721,7 +2745,7 @@ switch (yykind)
/// YYSYMBOL. No bounds checking.
static const char *symbol_name (symbol_kind_type yysymbol);
// Implementation of make_symbol for each symbol type.
// Implementation of make_symbol for each token kind.
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4458,19 +4482,19 @@ switch (yykind)
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
static bool yy_pact_value_is_default_ (int yyvalue);
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
/// Whether the given \c yytable_ value indicates a syntax error.
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
static const short yypact_ninf_;
static const short yytable_ninf_;
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
/// are valid, yet not members of the token_kind_type enum.
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
@ -4497,14 +4521,14 @@ switch (yykind)
static const short yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
// YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
// state STATE-NUM.
static const unsigned char yystos_[];
// YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
// YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.
static const unsigned char yyr1_[];
// YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
// YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.
static const signed char yyr2_[];
@ -4603,7 +4627,7 @@ switch (yykind)
typedef typename S::size_type size_type;
typedef typename std::ptrdiff_t index_type;
stack (size_type n = 200)
stack (size_type n = 200) YY_NOEXCEPT
: seq_ (n)
{}
@ -4682,7 +4706,7 @@ switch (yykind)
class slice
{
public:
slice (const stack& stack, index_type range)
slice (const stack& stack, index_type range) YY_NOEXCEPT
: stack_ (stack)
, range_ (range)
{}
@ -4741,7 +4765,7 @@ switch (yykind)
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
void yypop_ (int n = 1) YY_NOEXCEPT;
/// Constants.
enum
@ -4760,7 +4784,7 @@ switch (yykind)
inline
parser::symbol_kind_type
parser::yytranslate_ (int t)
parser::yytranslate_ (int t) YY_NOEXCEPT
{
return static_cast<symbol_kind_type> (t);
}
@ -5065,6 +5089,7 @@ switch (yykind)
template <typename Base>
parser::symbol_kind_type
parser::basic_symbol<Base>::type_get () const YY_NOEXCEPT
@ -5072,6 +5097,7 @@ switch (yykind)
return this->kind ();
}
template <typename Base>
bool
parser::basic_symbol<Base>::empty () const YY_NOEXCEPT
@ -5378,13 +5404,13 @@ switch (yykind)
// by_kind.
inline
parser::by_kind::by_kind ()
parser::by_kind::by_kind () YY_NOEXCEPT
: kind_ (symbol_kind::S_YYEMPTY)
{}
#if 201103L <= YY_CPLUSPLUS
inline
parser::by_kind::by_kind (by_kind&& that)
parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
: kind_ (that.kind_)
{
that.clear ();
@ -5392,15 +5418,17 @@ switch (yykind)
#endif
inline
parser::by_kind::by_kind (const by_kind& that)
parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
: kind_ (that.kind_)
{}
inline
parser::by_kind::by_kind (token_kind_type t)
parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
: kind_ (yytranslate_ (t))
{}
inline
void
parser::by_kind::clear () YY_NOEXCEPT
@ -5423,6 +5451,7 @@ switch (yykind)
return kind_;
}
inline
parser::symbol_kind_type
parser::by_kind::type_get () const YY_NOEXCEPT
@ -5430,9 +5459,10 @@ switch (yykind)
return this->kind ();
}
#line 13 "parser.ypp"
} } } // xsk::gsc::iw5
#line 5436 "parser.hpp"
#line 5466 "parser.hpp"

View File

@ -6,6 +6,11 @@
#include "stdafx.hpp"
#include "iw5.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4244)
#endif
namespace xsk::gsc::iw5
{
@ -61,7 +66,7 @@ auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = function_map_rev.find(name);
@ -90,7 +95,7 @@ auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = method_map_rev.find(name);
@ -119,7 +124,7 @@ auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = file_map_rev.find(name);
@ -148,7 +153,7 @@ auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = token_map_rev.find(name);
@ -268,7 +273,7 @@ auto resolver::make_token(std::string_view str) -> std::string
for (std::size_t i = 0; i < data.size(); i++)
{
data[i] = std::tolower(str[i]);
data[i] = static_cast<char>(std::tolower(static_cast<unsigned char>(str[i])));
if (data[i] == '\\') data[i] = '/';
}
@ -8037,6 +8042,10 @@ __init__ _;
} // namespace xsk::gsc::iw5
#ifdef _MSC_VER
#pragma warning(pop)
#endif
/* unmaped files */
// "character/character_mp_ally_juggernaut"

View File

@ -5,38 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4005)
#pragma warning(disable:4018)
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4389)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <set>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/iw6.hpp"

View File

@ -143,7 +143,7 @@ void assembler::assemble_function(const function::ptr& func)
func->id = resolver::token_id(func->name);
stack_->write<std::uint32_t>(func->size);
stack_->write<std::uint16_t>(func->id);
stack_->write<std::uint16_t>(static_cast<std::uint16_t>(func->id));
if (func->id == 0)
{
@ -452,7 +452,7 @@ void assembler::assemble_end_switch(const instruction::ptr& inst)
const auto count = std::stoul(inst->data[0]);
script_->write<std::uint16_t>(count);
script_->write<std::uint16_t>(static_cast<std::uint16_t>(count));
std::uint32_t index = inst->index + 3;
@ -519,15 +519,15 @@ void assembler::assemble_jump(const instruction::ptr& inst, bool expr, bool back
if (expr)
{
script_->write<std::int16_t>(addr - inst->index - 3);
script_->write<std::int16_t>(static_cast<std::int16_t>(addr - inst->index - 3));
}
else if (back)
{
script_->write<std::int16_t>((inst->index + 3) - addr);
script_->write<std::int16_t>(static_cast<std::int16_t>((inst->index + 3) - addr));
}
else
{
script_->write<std::int32_t>(addr - inst->index - 5);
script_->write<std::int32_t>(static_cast<std::int32_t>(addr - inst->index - 5));
}
}
@ -546,11 +546,11 @@ void assembler::assemble_offset(std::int32_t offset)
auto assembler::resolve_function(const std::string& name) -> std::int32_t
{
for (const auto& func : functions_)
for (const auto& entry : functions_)
{
if (func->name == name)
if (entry->name == name)
{
return func->index;
return entry->index;
}
}
@ -559,11 +559,11 @@ auto assembler::resolve_function(const std::string& name) -> std::int32_t
auto assembler::resolve_label(const std::string& name) -> std::int32_t
{
for (const auto& func : labels_)
for (const auto& entry : labels_)
{
if (func.second == name)
if (entry.second == name)
{
return func.first;
return entry.first;
}
}

View File

@ -840,7 +840,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
emit_opcode(opcode::OP_endswitch, data);
auto offset = 7 * stmt->stmt->list.size();
auto offset = static_cast<std::uint32_t>(7 * stmt->stmt->list.size());
function_->instructions.back()->size += offset;
index_ += offset;
@ -2660,7 +2660,7 @@ auto compiler::variable_stack_index(const ast::expr_identifier::ptr& name, const
{
if (blk->local_vars.at(i).init)
{
return blk->local_vars_create_count - 1 - i;
return static_cast<std::uint8_t>(blk->local_vars_create_count - 1 - i);
}
throw comp_error(name->loc(), "local variable '" + name->value + "' not initialized.");

View File

@ -1781,7 +1781,7 @@ void decompiler::decompile_statements(const ast::stmt_list::ptr& stmt)
void decompiler::decompile_infinites(const ast::stmt_list::ptr& stmt)
{
for (int i = stmt->list.size() - 1; i >= 0; i--)
for (auto i = stmt->list.size() - 1; i > 0; i--)
{
if (stmt->list.at(i) == ast::kind::asm_jump_back)
{
@ -1944,7 +1944,7 @@ void decompiler::decompile_aborts(const ast::stmt_list::ptr& block)
}
}
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_end = stmt->list.at(begin).as_cond->value;
@ -1972,7 +1972,7 @@ void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t beg
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.loc_end = stmt->list.at(end).loc().label();
@ -2023,7 +2023,7 @@ void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.is_last = true;
@ -2083,7 +2083,7 @@ void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uin
}
}
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = last_location_index(stmt, end) ? blocks_.back().loc_end : stmt->list.at(end + 1).loc().label();
@ -2113,7 +2113,7 @@ void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t start, std::uint32_t end)
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::size_t start, std::size_t end)
{
auto& last = block->list.at(end - 1);
@ -2178,7 +2178,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
decompile_while(block, start, end);
}
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2208,7 +2208,7 @@ void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2239,7 +2239,7 @@ void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2293,7 +2293,7 @@ void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t be
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2360,7 +2360,7 @@ void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t start)
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t start)
{
block blk;
blk.loc_continue = blocks_.back().loc_continue;
@ -2473,7 +2473,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + start, std::move(new_stmt));
}
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool
{
for (auto i = begin; i < end; i++)
{
@ -2492,7 +2492,7 @@ auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::u
return false;
}
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t
{
auto index = 0u;
@ -2510,7 +2510,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
throw decomp_error("LOCATION NOT FOUND! (" + location + ")");
}
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool
{
if (index == stmt->list.size() - 1)
return true;
@ -3328,7 +3328,7 @@ void decompiler::process_var_access(ast::expr& expr, const block::ptr& blk)
void decompiler::process_var_remove(const ast::asm_remove::ptr& expr, const block::ptr& blk)
{
blk->local_vars_public_count = blk->local_vars.size() - std::stoi(expr->index);
blk->local_vars_public_count = static_cast<std::uint32_t>(blk->local_vars.size() - std::stoi(expr->index));
}
} // namespace xsk::gsc::iw6

View File

@ -34,19 +34,19 @@ private:
void decompile_switches(const ast::stmt_list::ptr& stmt);
void decompile_ifelses(const ast::stmt_list::ptr& stmt);
void decompile_aborts(const ast::stmt_list::ptr& stmt);
void decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool;
void decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool;
void process_stack(const ast::decl_thread::ptr& thread);
void process_parameters(const ast::expr_parameters::ptr& params, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);

View File

@ -51,7 +51,7 @@ void disassembler::disassemble(const std::string& file, std::vector<std::uint8_t
func->index = static_cast<std::uint32_t>(script_->pos());
func->size = stack_->read<std::uint32_t>();
func->id = stack_->read<std::uint16_t>();
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(func->id);
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(static_cast<std::uint16_t>(func->id));
dissasemble_function(func);

View File

@ -96,7 +96,7 @@ void reader::init(const char* data, size_t size)
{
state = reader::ok;
buffer_pos = data;
bytes_remaining = size;
bytes_remaining = static_cast<std::uint32_t>(size);
last_byte = 0;
current_byte = *data;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// A Bison parser, made by GNU Bison 3.7.5.
// A Bison parser, made by GNU Bison 3.8.2.
// Skeleton interface for Bison LALR(1) parsers in C++
@ -15,7 +15,7 @@
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// As a special exception, you may create a larger work that contains
// part or all of the Bison parser skeleton and distribute that work
@ -47,10 +47,14 @@
// "%code requires" blocks.
#line 28 "parser.ypp"
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "iw6.hpp"
namespace xsk::gsc::iw6 { class lexer; }
#line 54 "parser.hpp"
#line 58 "parser.hpp"
# include <cassert>
# include <cstdlib> // std::abort
@ -126,12 +130,18 @@ namespace xsk::gsc::iw6 { class lexer; }
# define YY_USE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
# else
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
@ -193,7 +203,7 @@ namespace xsk::gsc::iw6 { class lexer; }
#line 13 "parser.ypp"
namespace xsk { namespace gsc { namespace iw6 {
#line 197 "parser.hpp"
#line 207 "parser.hpp"
@ -202,27 +212,32 @@ namespace xsk { namespace gsc { namespace iw6 {
class parser
{
public:
#ifndef IW6STYPE
#ifdef IW6STYPE
# ifdef __GNUC__
# pragma GCC message "bison: do not #define IW6STYPE in C++, use %define api.value.type"
# endif
typedef IW6STYPE value_type;
#else
/// A buffer to store and retrieve objects.
///
/// Sort of a variant, but does not keep track of the nature
/// of the stored data, since that knowledge is available
/// via the current parser state.
class semantic_type
class value_type
{
public:
/// Type of *this.
typedef semantic_type self_type;
typedef value_type self_type;
/// Empty construction.
semantic_type () YY_NOEXCEPT
: yybuffer_ ()
value_type () YY_NOEXCEPT
: yyraw_ ()
, yytypeid_ (YY_NULLPTR)
{}
/// Construct and fill.
template <typename T>
semantic_type (YY_RVREF (T) t)
value_type (YY_RVREF (T) t)
: yytypeid_ (&typeid (T))
{
IW6_ASSERT (sizeof (T) <= size);
@ -231,13 +246,13 @@ namespace xsk { namespace gsc { namespace iw6 {
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
semantic_type (const self_type&) = delete;
value_type (const self_type&) = delete;
/// Non copyable.
self_type& operator= (const self_type&) = delete;
#endif
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
~value_type () YY_NOEXCEPT
{
IW6_ASSERT (!yytypeid_);
}
@ -381,7 +396,7 @@ namespace xsk { namespace gsc { namespace iw6 {
private:
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
semantic_type (const self_type&);
value_type (const self_type&);
/// Non copyable.
self_type& operator= (const self_type&);
#endif
@ -391,7 +406,7 @@ namespace xsk { namespace gsc { namespace iw6 {
T*
yyas_ () YY_NOEXCEPT
{
void *yyp = yybuffer_.yyraw;
void *yyp = yyraw_;
return static_cast<T*> (yyp);
}
@ -400,7 +415,7 @@ namespace xsk { namespace gsc { namespace iw6 {
const T*
yyas_ () const YY_NOEXCEPT
{
const void *yyp = yybuffer_.yyraw;
const void *yyp = yyraw_;
return static_cast<const T*> (yyp);
}
@ -632,18 +647,19 @@ namespace xsk { namespace gsc { namespace iw6 {
union
{
/// Strongest alignment constraints.
long double yyalign_me;
long double yyalign_me_;
/// A buffer large enough to store any of the semantic values.
char yyraw[size];
} yybuffer_;
char yyraw_[size];
};
/// Whether the content is built: if defined, the name of the stored type.
const std::type_info *yytypeid_;
};
#else
typedef IW6STYPE semantic_type;
#endif
/// Backward compatibility (Bison 3.8).
typedef value_type semantic_type;
/// Symbol locations.
typedef xsk::gsc::location location_type;
@ -789,7 +805,7 @@ namespace xsk { namespace gsc { namespace iw6 {
};
/// Token kind, as returned by yylex.
typedef token::yytokentype token_kind_type;
typedef token::token_kind_type token_kind_type;
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type token_type;
@ -1017,7 +1033,7 @@ namespace xsk { namespace gsc { namespace iw6 {
typedef Base super_type;
/// Default constructor.
basic_symbol ()
basic_symbol () YY_NOEXCEPT
: value ()
, location ()
{}
@ -2267,6 +2283,8 @@ namespace xsk { namespace gsc { namespace iw6 {
clear ();
}
/// Destroy contents, and record that is empty.
void clear () YY_NOEXCEPT
{
@ -2589,7 +2607,7 @@ switch (yykind)
void move (basic_symbol& s);
/// The semantic value.
semantic_type value;
value_type value;
/// The location.
location_type location;
@ -2604,22 +2622,24 @@ switch (yykind)
/// Type access provider for token (enum) based symbols.
struct by_kind
{
/// Default constructor.
by_kind ();
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that);
#endif
/// Copy constructor.
by_kind (const by_kind& that);
/// The symbol kind as needed by the constructor.
typedef token_kind_type kind_type;
/// Default constructor.
by_kind () YY_NOEXCEPT;
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that) YY_NOEXCEPT;
#endif
/// Copy constructor.
by_kind (const by_kind& that) YY_NOEXCEPT;
/// Constructor from (external) token numbers.
by_kind (kind_type t);
by_kind (kind_type t) YY_NOEXCEPT;
/// Record that this symbol is empty.
void clear () YY_NOEXCEPT;
@ -2649,30 +2669,34 @@ switch (yykind)
typedef basic_symbol<by_kind> super_type;
/// Empty symbol.
symbol_type () {}
symbol_type () YY_NOEXCEPT {}
/// Constructor for valueless symbols, and symbols from each type.
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, location_type l)
: super_type(token_type (tok), std::move (l))
: super_type (token_kind_type (tok), std::move (l))
#else
symbol_type (int tok, const location_type& l)
: super_type(token_type (tok), l)
: super_type (token_kind_type (tok), l)
#endif
{
#if !defined _MSC_VER || defined __clang__
IW6_ASSERT (tok == token::IW6EOF
|| (token::IW6error <= tok && tok <= token::MOD)
|| (token::SIZEOF <= tok && tok <= token::POSTDEC));
#endif
}
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, std::string v, location_type l)
: super_type(token_type (tok), std::move (v), std::move (l))
: super_type (token_kind_type (tok), std::move (v), std::move (l))
#else
symbol_type (int tok, const std::string& v, const location_type& l)
: super_type(token_type (tok), v, l)
: super_type (token_kind_type (tok), v, l)
#endif
{
#if !defined _MSC_VER || defined __clang__
IW6_ASSERT ((token::PATH <= tok && tok <= token::INTEGER));
#endif
}
};
@ -2721,7 +2745,7 @@ switch (yykind)
/// YYSYMBOL. No bounds checking.
static const char *symbol_name (symbol_kind_type yysymbol);
// Implementation of make_symbol for each symbol type.
// Implementation of make_symbol for each token kind.
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4458,19 +4482,19 @@ switch (yykind)
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
static bool yy_pact_value_is_default_ (int yyvalue);
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
/// Whether the given \c yytable_ value indicates a syntax error.
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
static const short yypact_ninf_;
static const short yytable_ninf_;
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
/// are valid, yet not members of the token_kind_type enum.
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
@ -4497,14 +4521,14 @@ switch (yykind)
static const short yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
// YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
// state STATE-NUM.
static const unsigned char yystos_[];
// YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
// YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.
static const unsigned char yyr1_[];
// YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
// YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.
static const signed char yyr2_[];
@ -4603,7 +4627,7 @@ switch (yykind)
typedef typename S::size_type size_type;
typedef typename std::ptrdiff_t index_type;
stack (size_type n = 200)
stack (size_type n = 200) YY_NOEXCEPT
: seq_ (n)
{}
@ -4682,7 +4706,7 @@ switch (yykind)
class slice
{
public:
slice (const stack& stack, index_type range)
slice (const stack& stack, index_type range) YY_NOEXCEPT
: stack_ (stack)
, range_ (range)
{}
@ -4741,7 +4765,7 @@ switch (yykind)
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
void yypop_ (int n = 1) YY_NOEXCEPT;
/// Constants.
enum
@ -4760,7 +4784,7 @@ switch (yykind)
inline
parser::symbol_kind_type
parser::yytranslate_ (int t)
parser::yytranslate_ (int t) YY_NOEXCEPT
{
return static_cast<symbol_kind_type> (t);
}
@ -5065,6 +5089,7 @@ switch (yykind)
template <typename Base>
parser::symbol_kind_type
parser::basic_symbol<Base>::type_get () const YY_NOEXCEPT
@ -5072,6 +5097,7 @@ switch (yykind)
return this->kind ();
}
template <typename Base>
bool
parser::basic_symbol<Base>::empty () const YY_NOEXCEPT
@ -5378,13 +5404,13 @@ switch (yykind)
// by_kind.
inline
parser::by_kind::by_kind ()
parser::by_kind::by_kind () YY_NOEXCEPT
: kind_ (symbol_kind::S_YYEMPTY)
{}
#if 201103L <= YY_CPLUSPLUS
inline
parser::by_kind::by_kind (by_kind&& that)
parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
: kind_ (that.kind_)
{
that.clear ();
@ -5392,15 +5418,17 @@ switch (yykind)
#endif
inline
parser::by_kind::by_kind (const by_kind& that)
parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
: kind_ (that.kind_)
{}
inline
parser::by_kind::by_kind (token_kind_type t)
parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
: kind_ (yytranslate_ (t))
{}
inline
void
parser::by_kind::clear () YY_NOEXCEPT
@ -5423,6 +5451,7 @@ switch (yykind)
return kind_;
}
inline
parser::symbol_kind_type
parser::by_kind::type_get () const YY_NOEXCEPT
@ -5430,9 +5459,10 @@ switch (yykind)
return this->kind ();
}
#line 13 "parser.ypp"
} } } // xsk::gsc::iw6
#line 5436 "parser.hpp"
#line 5466 "parser.hpp"

View File

@ -6,6 +6,11 @@
#include "stdafx.hpp"
#include "iw6.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4244)
#endif
namespace xsk::gsc::iw6
{
@ -61,7 +66,7 @@ auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = function_map_rev.find(name);
@ -90,7 +95,7 @@ auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = method_map_rev.find(name);
@ -119,7 +124,7 @@ auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = file_map_rev.find(name);
@ -148,7 +153,7 @@ auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = token_map_rev.find(name);
@ -212,7 +217,7 @@ auto resolver::make_token(std::string_view str) -> std::string
for (std::size_t i = 0; i < data.size(); i++)
{
data[i] = std::tolower(str[i]);
data[i] = static_cast<char>(std::tolower(static_cast<unsigned char>(str[i])));
if (data[i] == '\\') data[i] = '/';
}
@ -16844,3 +16849,7 @@ struct __init__
__init__ _;
} // namespace xsk::gsc::iw6
#ifdef _MSC_VER
#pragma warning(pop)
#endif

View File

@ -5,38 +5,24 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4005)
#pragma warning(disable:4018)
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4389)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <set>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/iw7.hpp"

View File

@ -452,7 +452,7 @@ void assembler::assemble_end_switch(const instruction::ptr& inst)
const auto count = std::stoul(inst->data[0]);
script_->write<std::uint16_t>(count);
script_->write<std::uint16_t>(static_cast<std::uint16_t>(count));
std::uint32_t index = inst->index + 3;
@ -519,15 +519,15 @@ void assembler::assemble_jump(const instruction::ptr& inst, bool expr, bool back
if (expr)
{
script_->write<std::int16_t>(addr - inst->index - 3);
script_->write<std::int16_t>(static_cast<std::int16_t>(addr - inst->index - 3));
}
else if (back)
{
script_->write<std::int16_t>((inst->index + 3) - addr);
script_->write<std::int16_t>(static_cast<std::int16_t>((inst->index + 3) - addr));
}
else
{
script_->write<std::int32_t>(addr - inst->index - 5);
script_->write<std::int32_t>(static_cast<std::int32_t>(addr - inst->index - 5));
}
}
@ -546,11 +546,11 @@ void assembler::assemble_offset(std::int32_t offset)
auto assembler::resolve_function(const std::string& name) -> std::int32_t
{
for (const auto& func : functions_)
for (const auto& entry : functions_)
{
if (func->name == name)
if (entry->name == name)
{
return func->index;
return entry->index;
}
}
@ -559,11 +559,11 @@ auto assembler::resolve_function(const std::string& name) -> std::int32_t
auto assembler::resolve_label(const std::string& name) -> std::int32_t
{
for (const auto& func : labels_)
for (const auto& entry : labels_)
{
if (func.second == name)
if (entry.second == name)
{
return func.first;
return entry.first;
}
}

View File

@ -840,7 +840,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
emit_opcode(opcode::OP_endswitch, data);
auto offset = 7 * stmt->stmt->list.size();
auto offset = static_cast<std::uint32_t>(7 * stmt->stmt->list.size());
function_->instructions.back()->size += offset;
index_ += offset;
@ -2660,7 +2660,7 @@ auto compiler::variable_stack_index(const ast::expr_identifier::ptr& name, const
{
if (blk->local_vars.at(i).init)
{
return blk->local_vars_create_count - 1 - i;
return static_cast<std::uint8_t>(blk->local_vars_create_count - 1 - i);
}
throw comp_error(name->loc(), "local variable '" + name->value + "' not initialized.");

View File

@ -1781,7 +1781,7 @@ void decompiler::decompile_statements(const ast::stmt_list::ptr& stmt)
void decompiler::decompile_infinites(const ast::stmt_list::ptr& stmt)
{
for (int i = stmt->list.size() - 1; i >= 0; i--)
for (auto i = stmt->list.size() - 1; i > 0; i--)
{
if (stmt->list.at(i) == ast::kind::asm_jump_back)
{
@ -1944,7 +1944,7 @@ void decompiler::decompile_aborts(const ast::stmt_list::ptr& block)
}
}
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_end = stmt->list.at(begin).as_cond->value;
@ -1972,7 +1972,7 @@ void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t beg
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.loc_end = stmt->list.at(end).loc().label();
@ -2023,7 +2023,7 @@ void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.is_last = true;
@ -2083,7 +2083,7 @@ void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uin
}
}
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = last_location_index(stmt, end) ? blocks_.back().loc_end : stmt->list.at(end + 1).loc().label();
@ -2113,7 +2113,7 @@ void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t start, std::uint32_t end)
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::size_t start, std::size_t end)
{
auto& last = block->list.at(end - 1);
@ -2178,7 +2178,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
decompile_while(block, start, end);
}
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2208,7 +2208,7 @@ void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2239,7 +2239,7 @@ void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2293,7 +2293,7 @@ void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t be
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2360,7 +2360,7 @@ void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t start)
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t start)
{
block blk;
blk.loc_continue = blocks_.back().loc_continue;
@ -2473,7 +2473,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + start, std::move(new_stmt));
}
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool
{
for (auto i = begin; i < end; i++)
{
@ -2492,7 +2492,7 @@ auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::u
return false;
}
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t
{
auto index = 0u;
@ -2510,7 +2510,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
throw decomp_error("LOCATION NOT FOUND! (" + location + ")");
}
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool
{
if (index == stmt->list.size() - 1)
return true;
@ -3328,7 +3328,7 @@ void decompiler::process_var_access(ast::expr& expr, const block::ptr& blk)
void decompiler::process_var_remove(const ast::asm_remove::ptr& expr, const block::ptr& blk)
{
blk->local_vars_public_count = blk->local_vars.size() - std::stoi(expr->index);
blk->local_vars_public_count = static_cast<std::uint32_t>(blk->local_vars.size() - std::stoi(expr->index));
}
} // namespace xsk::gsc::iw7

View File

@ -34,19 +34,19 @@ private:
void decompile_switches(const ast::stmt_list::ptr& stmt);
void decompile_ifelses(const ast::stmt_list::ptr& stmt);
void decompile_aborts(const ast::stmt_list::ptr& stmt);
void decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool;
void decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool;
void process_stack(const ast::decl_thread::ptr& thread);
void process_parameters(const ast::expr_parameters::ptr& params, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);

View File

@ -96,7 +96,7 @@ void reader::init(const char* data, size_t size)
{
state = reader::ok;
buffer_pos = data;
bytes_remaining = size;
bytes_remaining = static_cast<std::uint32_t>(size);
last_byte = 0;
current_byte = *data;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// A Bison parser, made by GNU Bison 3.7.5.
// A Bison parser, made by GNU Bison 3.8.2.
// Skeleton interface for Bison LALR(1) parsers in C++
@ -15,7 +15,7 @@
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// As a special exception, you may create a larger work that contains
// part or all of the Bison parser skeleton and distribute that work
@ -47,10 +47,14 @@
// "%code requires" blocks.
#line 28 "parser.ypp"
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "iw7.hpp"
namespace xsk::gsc::iw7 { class lexer; }
#line 54 "parser.hpp"
#line 58 "parser.hpp"
# include <cassert>
# include <cstdlib> // std::abort
@ -126,12 +130,18 @@ namespace xsk::gsc::iw7 { class lexer; }
# define YY_USE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
# else
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
@ -193,7 +203,7 @@ namespace xsk::gsc::iw7 { class lexer; }
#line 13 "parser.ypp"
namespace xsk { namespace gsc { namespace iw7 {
#line 197 "parser.hpp"
#line 207 "parser.hpp"
@ -202,27 +212,32 @@ namespace xsk { namespace gsc { namespace iw7 {
class parser
{
public:
#ifndef IW7STYPE
#ifdef IW7STYPE
# ifdef __GNUC__
# pragma GCC message "bison: do not #define IW7STYPE in C++, use %define api.value.type"
# endif
typedef IW7STYPE value_type;
#else
/// A buffer to store and retrieve objects.
///
/// Sort of a variant, but does not keep track of the nature
/// of the stored data, since that knowledge is available
/// via the current parser state.
class semantic_type
class value_type
{
public:
/// Type of *this.
typedef semantic_type self_type;
typedef value_type self_type;
/// Empty construction.
semantic_type () YY_NOEXCEPT
: yybuffer_ ()
value_type () YY_NOEXCEPT
: yyraw_ ()
, yytypeid_ (YY_NULLPTR)
{}
/// Construct and fill.
template <typename T>
semantic_type (YY_RVREF (T) t)
value_type (YY_RVREF (T) t)
: yytypeid_ (&typeid (T))
{
IW7_ASSERT (sizeof (T) <= size);
@ -231,13 +246,13 @@ namespace xsk { namespace gsc { namespace iw7 {
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
semantic_type (const self_type&) = delete;
value_type (const self_type&) = delete;
/// Non copyable.
self_type& operator= (const self_type&) = delete;
#endif
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
~value_type () YY_NOEXCEPT
{
IW7_ASSERT (!yytypeid_);
}
@ -381,7 +396,7 @@ namespace xsk { namespace gsc { namespace iw7 {
private:
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
semantic_type (const self_type&);
value_type (const self_type&);
/// Non copyable.
self_type& operator= (const self_type&);
#endif
@ -391,7 +406,7 @@ namespace xsk { namespace gsc { namespace iw7 {
T*
yyas_ () YY_NOEXCEPT
{
void *yyp = yybuffer_.yyraw;
void *yyp = yyraw_;
return static_cast<T*> (yyp);
}
@ -400,7 +415,7 @@ namespace xsk { namespace gsc { namespace iw7 {
const T*
yyas_ () const YY_NOEXCEPT
{
const void *yyp = yybuffer_.yyraw;
const void *yyp = yyraw_;
return static_cast<const T*> (yyp);
}
@ -632,18 +647,19 @@ namespace xsk { namespace gsc { namespace iw7 {
union
{
/// Strongest alignment constraints.
long double yyalign_me;
long double yyalign_me_;
/// A buffer large enough to store any of the semantic values.
char yyraw[size];
} yybuffer_;
char yyraw_[size];
};
/// Whether the content is built: if defined, the name of the stored type.
const std::type_info *yytypeid_;
};
#else
typedef IW7STYPE semantic_type;
#endif
/// Backward compatibility (Bison 3.8).
typedef value_type semantic_type;
/// Symbol locations.
typedef xsk::gsc::location location_type;
@ -789,7 +805,7 @@ namespace xsk { namespace gsc { namespace iw7 {
};
/// Token kind, as returned by yylex.
typedef token::yytokentype token_kind_type;
typedef token::token_kind_type token_kind_type;
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type token_type;
@ -1017,7 +1033,7 @@ namespace xsk { namespace gsc { namespace iw7 {
typedef Base super_type;
/// Default constructor.
basic_symbol ()
basic_symbol () YY_NOEXCEPT
: value ()
, location ()
{}
@ -2267,6 +2283,8 @@ namespace xsk { namespace gsc { namespace iw7 {
clear ();
}
/// Destroy contents, and record that is empty.
void clear () YY_NOEXCEPT
{
@ -2589,7 +2607,7 @@ switch (yykind)
void move (basic_symbol& s);
/// The semantic value.
semantic_type value;
value_type value;
/// The location.
location_type location;
@ -2604,22 +2622,24 @@ switch (yykind)
/// Type access provider for token (enum) based symbols.
struct by_kind
{
/// Default constructor.
by_kind ();
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that);
#endif
/// Copy constructor.
by_kind (const by_kind& that);
/// The symbol kind as needed by the constructor.
typedef token_kind_type kind_type;
/// Default constructor.
by_kind () YY_NOEXCEPT;
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that) YY_NOEXCEPT;
#endif
/// Copy constructor.
by_kind (const by_kind& that) YY_NOEXCEPT;
/// Constructor from (external) token numbers.
by_kind (kind_type t);
by_kind (kind_type t) YY_NOEXCEPT;
/// Record that this symbol is empty.
void clear () YY_NOEXCEPT;
@ -2649,30 +2669,34 @@ switch (yykind)
typedef basic_symbol<by_kind> super_type;
/// Empty symbol.
symbol_type () {}
symbol_type () YY_NOEXCEPT {}
/// Constructor for valueless symbols, and symbols from each type.
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, location_type l)
: super_type(token_type (tok), std::move (l))
: super_type (token_kind_type (tok), std::move (l))
#else
symbol_type (int tok, const location_type& l)
: super_type(token_type (tok), l)
: super_type (token_kind_type (tok), l)
#endif
{
#if !defined _MSC_VER || defined __clang__
IW7_ASSERT (tok == token::IW7EOF
|| (token::IW7error <= tok && tok <= token::MOD)
|| (token::SIZEOF <= tok && tok <= token::POSTDEC));
#endif
}
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, std::string v, location_type l)
: super_type(token_type (tok), std::move (v), std::move (l))
: super_type (token_kind_type (tok), std::move (v), std::move (l))
#else
symbol_type (int tok, const std::string& v, const location_type& l)
: super_type(token_type (tok), v, l)
: super_type (token_kind_type (tok), v, l)
#endif
{
#if !defined _MSC_VER || defined __clang__
IW7_ASSERT ((token::PATH <= tok && tok <= token::INTEGER));
#endif
}
};
@ -2721,7 +2745,7 @@ switch (yykind)
/// YYSYMBOL. No bounds checking.
static const char *symbol_name (symbol_kind_type yysymbol);
// Implementation of make_symbol for each symbol type.
// Implementation of make_symbol for each token kind.
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4458,19 +4482,19 @@ switch (yykind)
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
static bool yy_pact_value_is_default_ (int yyvalue);
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
/// Whether the given \c yytable_ value indicates a syntax error.
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
static const short yypact_ninf_;
static const short yytable_ninf_;
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
/// are valid, yet not members of the token_kind_type enum.
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
@ -4497,14 +4521,14 @@ switch (yykind)
static const short yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
// YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
// state STATE-NUM.
static const unsigned char yystos_[];
// YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
// YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.
static const unsigned char yyr1_[];
// YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
// YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.
static const signed char yyr2_[];
@ -4603,7 +4627,7 @@ switch (yykind)
typedef typename S::size_type size_type;
typedef typename std::ptrdiff_t index_type;
stack (size_type n = 200)
stack (size_type n = 200) YY_NOEXCEPT
: seq_ (n)
{}
@ -4682,7 +4706,7 @@ switch (yykind)
class slice
{
public:
slice (const stack& stack, index_type range)
slice (const stack& stack, index_type range) YY_NOEXCEPT
: stack_ (stack)
, range_ (range)
{}
@ -4741,7 +4765,7 @@ switch (yykind)
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
void yypop_ (int n = 1) YY_NOEXCEPT;
/// Constants.
enum
@ -4760,7 +4784,7 @@ switch (yykind)
inline
parser::symbol_kind_type
parser::yytranslate_ (int t)
parser::yytranslate_ (int t) YY_NOEXCEPT
{
return static_cast<symbol_kind_type> (t);
}
@ -5065,6 +5089,7 @@ switch (yykind)
template <typename Base>
parser::symbol_kind_type
parser::basic_symbol<Base>::type_get () const YY_NOEXCEPT
@ -5072,6 +5097,7 @@ switch (yykind)
return this->kind ();
}
template <typename Base>
bool
parser::basic_symbol<Base>::empty () const YY_NOEXCEPT
@ -5378,13 +5404,13 @@ switch (yykind)
// by_kind.
inline
parser::by_kind::by_kind ()
parser::by_kind::by_kind () YY_NOEXCEPT
: kind_ (symbol_kind::S_YYEMPTY)
{}
#if 201103L <= YY_CPLUSPLUS
inline
parser::by_kind::by_kind (by_kind&& that)
parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
: kind_ (that.kind_)
{
that.clear ();
@ -5392,15 +5418,17 @@ switch (yykind)
#endif
inline
parser::by_kind::by_kind (const by_kind& that)
parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
: kind_ (that.kind_)
{}
inline
parser::by_kind::by_kind (token_kind_type t)
parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
: kind_ (yytranslate_ (t))
{}
inline
void
parser::by_kind::clear () YY_NOEXCEPT
@ -5423,6 +5451,7 @@ switch (yykind)
return kind_;
}
inline
parser::symbol_kind_type
parser::by_kind::type_get () const YY_NOEXCEPT
@ -5430,9 +5459,10 @@ switch (yykind)
return this->kind ();
}
#line 13 "parser.ypp"
} } } // xsk::gsc::iw7
#line 5436 "parser.hpp"
#line 5466 "parser.hpp"

View File

@ -6,6 +6,11 @@
#include "stdafx.hpp"
#include "iw7.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4244)
#endif
namespace xsk::gsc::iw7
{
@ -61,7 +66,7 @@ auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = function_map_rev.find(name);
@ -90,7 +95,7 @@ auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = method_map_rev.find(name);
@ -119,7 +124,7 @@ auto resolver::file_id(const std::string& name) -> std::uint32_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint32_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = file_map_rev.find(name);
@ -148,7 +153,7 @@ auto resolver::token_id(const std::string& name) -> std::uint32_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint32_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = token_map_rev.find(name);
@ -212,7 +217,7 @@ auto resolver::make_token(std::string_view str) -> std::string
for (std::size_t i = 0; i < data.size(); i++)
{
data[i] = std::tolower(str[i]);
data[i] = static_cast<char>(std::tolower(static_cast<unsigned char>(str[i])));
if (data[i] == '\\') data[i] = '/';
}
@ -2805,3 +2810,7 @@ struct __init__
__init__ _;
} // namespace xsk::gsc::iw7
#ifdef _MSC_VER
#pragma warning(pop)
#endif

View File

@ -5,38 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4005)
#pragma warning(disable:4018)
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4389)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <set>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/iw8.hpp"

View File

@ -507,7 +507,7 @@ void assembler::assemble_end_switch(const instruction::ptr& inst)
const auto count = std::stoul(inst->data[0]);
script_->write<std::uint16_t>(count);
script_->write<std::uint16_t>(static_cast<std::uint16_t>(count));
std::uint32_t index = inst->index + 3;
@ -588,15 +588,15 @@ void assembler::assemble_jump(const instruction::ptr& inst, bool expr, bool back
if (expr)
{
script_->write<std::int16_t>(addr - inst->index - 3);
script_->write<std::int16_t>(static_cast<std::int16_t>(addr - inst->index - 3));
}
else if (back)
{
script_->write<std::int16_t>((inst->index + 3) - addr);
script_->write<std::int16_t>(static_cast<std::int16_t>((inst->index + 3) - addr));
}
else
{
script_->write<std::int32_t>(addr - inst->index - 5);
script_->write<std::int32_t>(static_cast<std::int32_t>(addr - inst->index - 5));
}
}
@ -615,11 +615,11 @@ void assembler::assemble_offset(std::int32_t offset)
auto assembler::resolve_function(const std::string& name) -> std::int32_t
{
for (const auto& func : functions_)
for (const auto& entry : functions_)
{
if (func->name == name)
if (entry->name == name)
{
return func->index;
return entry->index;
}
}
@ -628,11 +628,11 @@ auto assembler::resolve_function(const std::string& name) -> std::int32_t
auto assembler::resolve_label(const std::string& name) -> std::int32_t
{
for (const auto& func : labels_)
for (const auto& entry : labels_)
{
if (func.second == name)
if (entry.second == name)
{
return func.first;
return entry.first;
}
}

View File

@ -848,7 +848,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
emit_opcode(opcode::OP_endswitch, data);
auto offset = 7 * stmt->stmt->list.size();
auto offset = static_cast<std::uint32_t>(7 * stmt->stmt->list.size());
function_->instructions.back()->size += offset;
index_ += offset;
@ -1552,7 +1552,7 @@ void compiler::emit_expr_add_array(const ast::expr_add_array::ptr& expr, const b
void compiler::emit_expr_parameters(const ast::expr_parameters::ptr& expr, const block::ptr& blk)
{
auto num = expr->list.size();
auto num = static_cast<std::uint32_t>(expr->list.size());
if (num)
{
@ -2720,7 +2720,7 @@ auto compiler::variable_stack_index(const ast::expr_identifier::ptr& name, const
{
if (blk->local_vars.at(i).init)
{
return blk->local_vars_create_count - 1 - i;
return static_cast<std::uint8_t>(blk->local_vars_create_count - 1 - i);
}
throw comp_error(name->loc(), "local variable '" + name->value + "' not initialized.");

View File

@ -1818,7 +1818,7 @@ void decompiler::decompile_statements(const ast::stmt_list::ptr& stmt)
void decompiler::decompile_infinites(const ast::stmt_list::ptr& stmt)
{
for (int i = stmt->list.size() - 1; i >= 0; i--)
for (auto i = stmt->list.size() - 1; i > 0; i--)
{
if (stmt->list.at(i) == ast::kind::asm_jump_back)
{
@ -1981,7 +1981,7 @@ void decompiler::decompile_aborts(const ast::stmt_list::ptr& block)
}
}
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_end = stmt->list.at(begin).as_cond->value;
@ -2009,7 +2009,7 @@ void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t beg
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.loc_end = stmt->list.at(end).loc().label();
@ -2060,7 +2060,7 @@ void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.is_last = true;
@ -2120,7 +2120,7 @@ void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uin
}
}
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = last_location_index(stmt, end) ? blocks_.back().loc_end : stmt->list.at(end + 1).loc().label();
@ -2150,7 +2150,7 @@ void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t start, std::uint32_t end)
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::size_t start, std::size_t end)
{
auto& last = block->list.at(end - 1);
@ -2215,7 +2215,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
decompile_while(block, start, end);
}
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2245,7 +2245,7 @@ void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2276,7 +2276,7 @@ void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2330,7 +2330,7 @@ void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t be
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2397,7 +2397,7 @@ void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t start)
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t start)
{
block blk;
blk.loc_continue = blocks_.back().loc_continue;
@ -2510,7 +2510,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + start, std::move(new_stmt));
}
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool
{
for (auto i = begin; i < end; i++)
{
@ -2529,7 +2529,7 @@ auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::u
return false;
}
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t
{
auto index = 0u;
@ -2547,7 +2547,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
throw decomp_error("LOCATION NOT FOUND! (" + location + ")");
}
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool
{
if (index == stmt->list.size() - 1)
return true;
@ -3371,7 +3371,7 @@ void decompiler::process_var_access(ast::expr& expr, const block::ptr& blk)
void decompiler::process_var_remove(const ast::asm_remove::ptr& expr, const block::ptr& blk)
{
blk->local_vars_public_count = blk->local_vars.size() - std::stoi(expr->index);
blk->local_vars_public_count = static_cast<std::uint32_t>(blk->local_vars.size() - std::stoi(expr->index));
}
} // namespace xsk::gsc::iw8

View File

@ -34,19 +34,19 @@ private:
void decompile_switches(const ast::stmt_list::ptr& stmt);
void decompile_ifelses(const ast::stmt_list::ptr& stmt);
void decompile_aborts(const ast::stmt_list::ptr& stmt);
void decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool;
void decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool;
void process_stack(const ast::decl_thread::ptr& thread);
void process_parameters(const ast::expr_parameters::ptr& params, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);

View File

@ -99,7 +99,7 @@ void reader::init(const char* data, size_t size)
{
state = reader::ok;
buffer_pos = data;
bytes_remaining = size;
bytes_remaining = static_cast<std::uint32_t>(size);
last_byte = 0;
current_byte = *data;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// A Bison parser, made by GNU Bison 3.7.5.
// A Bison parser, made by GNU Bison 3.8.2.
// Skeleton interface for Bison LALR(1) parsers in C++
@ -15,7 +15,7 @@
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// As a special exception, you may create a larger work that contains
// part or all of the Bison parser skeleton and distribute that work
@ -47,10 +47,14 @@
// "%code requires" blocks.
#line 28 "parser.ypp"
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "iw8.hpp"
namespace xsk::gsc::iw8 { class lexer; }
#line 54 "parser.hpp"
#line 58 "parser.hpp"
# include <cassert>
# include <cstdlib> // std::abort
@ -126,12 +130,18 @@ namespace xsk::gsc::iw8 { class lexer; }
# define YY_USE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
# else
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
@ -193,7 +203,7 @@ namespace xsk::gsc::iw8 { class lexer; }
#line 13 "parser.ypp"
namespace xsk { namespace gsc { namespace iw8 {
#line 197 "parser.hpp"
#line 207 "parser.hpp"
@ -202,27 +212,32 @@ namespace xsk { namespace gsc { namespace iw8 {
class parser
{
public:
#ifndef IW8STYPE
#ifdef IW8STYPE
# ifdef __GNUC__
# pragma GCC message "bison: do not #define IW8STYPE in C++, use %define api.value.type"
# endif
typedef IW8STYPE value_type;
#else
/// A buffer to store and retrieve objects.
///
/// Sort of a variant, but does not keep track of the nature
/// of the stored data, since that knowledge is available
/// via the current parser state.
class semantic_type
class value_type
{
public:
/// Type of *this.
typedef semantic_type self_type;
typedef value_type self_type;
/// Empty construction.
semantic_type () YY_NOEXCEPT
: yybuffer_ ()
value_type () YY_NOEXCEPT
: yyraw_ ()
, yytypeid_ (YY_NULLPTR)
{}
/// Construct and fill.
template <typename T>
semantic_type (YY_RVREF (T) t)
value_type (YY_RVREF (T) t)
: yytypeid_ (&typeid (T))
{
IW8_ASSERT (sizeof (T) <= size);
@ -231,13 +246,13 @@ namespace xsk { namespace gsc { namespace iw8 {
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
semantic_type (const self_type&) = delete;
value_type (const self_type&) = delete;
/// Non copyable.
self_type& operator= (const self_type&) = delete;
#endif
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
~value_type () YY_NOEXCEPT
{
IW8_ASSERT (!yytypeid_);
}
@ -381,7 +396,7 @@ namespace xsk { namespace gsc { namespace iw8 {
private:
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
semantic_type (const self_type&);
value_type (const self_type&);
/// Non copyable.
self_type& operator= (const self_type&);
#endif
@ -391,7 +406,7 @@ namespace xsk { namespace gsc { namespace iw8 {
T*
yyas_ () YY_NOEXCEPT
{
void *yyp = yybuffer_.yyraw;
void *yyp = yyraw_;
return static_cast<T*> (yyp);
}
@ -400,7 +415,7 @@ namespace xsk { namespace gsc { namespace iw8 {
const T*
yyas_ () const YY_NOEXCEPT
{
const void *yyp = yybuffer_.yyraw;
const void *yyp = yyraw_;
return static_cast<const T*> (yyp);
}
@ -641,18 +656,19 @@ namespace xsk { namespace gsc { namespace iw8 {
union
{
/// Strongest alignment constraints.
long double yyalign_me;
long double yyalign_me_;
/// A buffer large enough to store any of the semantic values.
char yyraw[size];
} yybuffer_;
char yyraw_[size];
};
/// Whether the content is built: if defined, the name of the stored type.
const std::type_info *yytypeid_;
};
#else
typedef IW8STYPE semantic_type;
#endif
/// Backward compatibility (Bison 3.8).
typedef value_type semantic_type;
/// Symbol locations.
typedef xsk::gsc::location location_type;
@ -801,7 +817,7 @@ namespace xsk { namespace gsc { namespace iw8 {
};
/// Token kind, as returned by yylex.
typedef token::yytokentype token_kind_type;
typedef token::token_kind_type token_kind_type;
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type token_type;
@ -1035,7 +1051,7 @@ namespace xsk { namespace gsc { namespace iw8 {
typedef Base super_type;
/// Default constructor.
basic_symbol ()
basic_symbol () YY_NOEXCEPT
: value ()
, location ()
{}
@ -2339,6 +2355,8 @@ namespace xsk { namespace gsc { namespace iw8 {
clear ();
}
/// Destroy contents, and record that is empty.
void clear () YY_NOEXCEPT
{
@ -2673,7 +2691,7 @@ switch (yykind)
void move (basic_symbol& s);
/// The semantic value.
semantic_type value;
value_type value;
/// The location.
location_type location;
@ -2688,22 +2706,24 @@ switch (yykind)
/// Type access provider for token (enum) based symbols.
struct by_kind
{
/// Default constructor.
by_kind ();
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that);
#endif
/// Copy constructor.
by_kind (const by_kind& that);
/// The symbol kind as needed by the constructor.
typedef token_kind_type kind_type;
/// Default constructor.
by_kind () YY_NOEXCEPT;
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that) YY_NOEXCEPT;
#endif
/// Copy constructor.
by_kind (const by_kind& that) YY_NOEXCEPT;
/// Constructor from (external) token numbers.
by_kind (kind_type t);
by_kind (kind_type t) YY_NOEXCEPT;
/// Record that this symbol is empty.
void clear () YY_NOEXCEPT;
@ -2733,30 +2753,34 @@ switch (yykind)
typedef basic_symbol<by_kind> super_type;
/// Empty symbol.
symbol_type () {}
symbol_type () YY_NOEXCEPT {}
/// Constructor for valueless symbols, and symbols from each type.
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, location_type l)
: super_type(token_type (tok), std::move (l))
: super_type (token_kind_type (tok), std::move (l))
#else
symbol_type (int tok, const location_type& l)
: super_type(token_type (tok), l)
: super_type (token_kind_type (tok), l)
#endif
{
#if !defined _MSC_VER || defined __clang__
IW8_ASSERT (tok == token::IW8EOF
|| (token::IW8error <= tok && tok <= token::MOD)
|| (token::SIZEOF <= tok && tok <= token::POSTDEC));
#endif
}
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, std::string v, location_type l)
: super_type(token_type (tok), std::move (v), std::move (l))
: super_type (token_kind_type (tok), std::move (v), std::move (l))
#else
symbol_type (int tok, const std::string& v, const location_type& l)
: super_type(token_type (tok), v, l)
: super_type (token_kind_type (tok), v, l)
#endif
{
#if !defined _MSC_VER || defined __clang__
IW8_ASSERT ((token::PATH <= tok && tok <= token::INTEGER));
#endif
}
};
@ -2805,7 +2829,7 @@ switch (yykind)
/// YYSYMBOL. No bounds checking.
static const char *symbol_name (symbol_kind_type yysymbol);
// Implementation of make_symbol for each symbol type.
// Implementation of make_symbol for each token kind.
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4587,19 +4611,19 @@ switch (yykind)
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
static bool yy_pact_value_is_default_ (int yyvalue);
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
/// Whether the given \c yytable_ value indicates a syntax error.
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
static const short yypact_ninf_;
static const short yytable_ninf_;
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
/// are valid, yet not members of the token_kind_type enum.
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
@ -4626,14 +4650,14 @@ switch (yykind)
static const short yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
// YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
// state STATE-NUM.
static const unsigned char yystos_[];
// YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
// YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.
static const unsigned char yyr1_[];
// YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
// YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.
static const signed char yyr2_[];
@ -4732,7 +4756,7 @@ switch (yykind)
typedef typename S::size_type size_type;
typedef typename std::ptrdiff_t index_type;
stack (size_type n = 200)
stack (size_type n = 200) YY_NOEXCEPT
: seq_ (n)
{}
@ -4811,7 +4835,7 @@ switch (yykind)
class slice
{
public:
slice (const stack& stack, index_type range)
slice (const stack& stack, index_type range) YY_NOEXCEPT
: stack_ (stack)
, range_ (range)
{}
@ -4870,7 +4894,7 @@ switch (yykind)
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
void yypop_ (int n = 1) YY_NOEXCEPT;
/// Constants.
enum
@ -4889,7 +4913,7 @@ switch (yykind)
inline
parser::symbol_kind_type
parser::yytranslate_ (int t)
parser::yytranslate_ (int t) YY_NOEXCEPT
{
return static_cast<symbol_kind_type> (t);
}
@ -5206,6 +5230,7 @@ switch (yykind)
template <typename Base>
parser::symbol_kind_type
parser::basic_symbol<Base>::type_get () const YY_NOEXCEPT
@ -5213,6 +5238,7 @@ switch (yykind)
return this->kind ();
}
template <typename Base>
bool
parser::basic_symbol<Base>::empty () const YY_NOEXCEPT
@ -5531,13 +5557,13 @@ switch (yykind)
// by_kind.
inline
parser::by_kind::by_kind ()
parser::by_kind::by_kind () YY_NOEXCEPT
: kind_ (symbol_kind::S_YYEMPTY)
{}
#if 201103L <= YY_CPLUSPLUS
inline
parser::by_kind::by_kind (by_kind&& that)
parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
: kind_ (that.kind_)
{
that.clear ();
@ -5545,15 +5571,17 @@ switch (yykind)
#endif
inline
parser::by_kind::by_kind (const by_kind& that)
parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
: kind_ (that.kind_)
{}
inline
parser::by_kind::by_kind (token_kind_type t)
parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
: kind_ (yytranslate_ (t))
{}
inline
void
parser::by_kind::clear () YY_NOEXCEPT
@ -5576,6 +5604,7 @@ switch (yykind)
return kind_;
}
inline
parser::symbol_kind_type
parser::by_kind::type_get () const YY_NOEXCEPT
@ -5583,9 +5612,10 @@ switch (yykind)
return this->kind ();
}
#line 13 "parser.ypp"
} } } // xsk::gsc::iw8
#line 5589 "parser.hpp"
#line 5619 "parser.hpp"

View File

@ -6,6 +6,11 @@
#include "stdafx.hpp"
#include "iw8.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4244)
#endif
namespace xsk::gsc::iw8
{
@ -61,7 +66,7 @@ auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = function_map_rev.find(name);
@ -90,7 +95,7 @@ auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = method_map_rev.find(name);
@ -119,7 +124,7 @@ auto resolver::file_id(const std::string& name) -> std::uint32_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint32_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = file_map_rev.find(name);
@ -148,7 +153,7 @@ auto resolver::token_id(const std::string& name) -> std::uint32_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint32_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = token_map_rev.find(name);
@ -212,7 +217,7 @@ auto resolver::make_token(std::string_view str) -> std::string
for (std::size_t i = 0; i < data.size(); i++)
{
data[i] = std::tolower(str[i]);
data[i] = static_cast<char>(std::tolower(static_cast<unsigned char>(str[i])));
if (data[i] == '\\') data[i] = '/';
}
@ -75643,3 +75648,7 @@ struct __init__
__init__ _;
} // namespace xsk::gsc::iw8
#ifdef _MSC_VER
#pragma warning(pop)
#endif

View File

@ -5,38 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4005)
#pragma warning(disable:4018)
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4389)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <set>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/s1.hpp"

View File

@ -143,7 +143,7 @@ void assembler::assemble_function(const function::ptr& func)
func->id = resolver::token_id(func->name);
stack_->write<std::uint32_t>(func->size);
stack_->write<std::uint16_t>(func->id);
stack_->write<std::uint16_t>(static_cast<std::uint16_t>(func->id));
if (func->id == 0)
{
@ -453,7 +453,7 @@ void assembler::assemble_end_switch(const instruction::ptr& inst)
const auto count = std::stoul(inst->data[0]);
script_->write<std::uint16_t>(count);
script_->write<std::uint16_t>(static_cast<std::uint16_t>(count));
std::uint32_t index = inst->index + 3;
@ -520,15 +520,15 @@ void assembler::assemble_jump(const instruction::ptr& inst, bool expr, bool back
if (expr)
{
script_->write<std::int16_t>(addr - inst->index - 3);
script_->write<std::int16_t>(static_cast<std::int16_t>(addr - inst->index - 3));
}
else if (back)
{
script_->write<std::int16_t>((inst->index + 3) - addr);
script_->write<std::int16_t>(static_cast<std::int16_t>((inst->index + 3) - addr));
}
else
{
script_->write<std::int32_t>(addr - inst->index - 5);
script_->write<std::int32_t>(static_cast<std::int32_t>(addr - inst->index - 5));
}
}
@ -547,11 +547,11 @@ void assembler::assemble_offset(std::int32_t offset)
auto assembler::resolve_function(const std::string& name) -> std::int32_t
{
for (const auto& func : functions_)
for (const auto& entry : functions_)
{
if (func->name == name)
if (entry->name == name)
{
return func->index;
return entry->index;
}
}
@ -560,11 +560,11 @@ auto assembler::resolve_function(const std::string& name) -> std::int32_t
auto assembler::resolve_label(const std::string& name) -> std::int32_t
{
for (const auto& func : labels_)
for (const auto& entry : labels_)
{
if (func.second == name)
if (entry.second == name)
{
return func.first;
return entry.first;
}
}

View File

@ -848,7 +848,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
emit_opcode(opcode::OP_endswitch, data);
auto offset = 7 * stmt->stmt->list.size();
auto offset = static_cast<std::uint32_t>(7 * stmt->stmt->list.size());
function_->instructions.back()->size += offset;
index_ += offset;
@ -2669,7 +2669,7 @@ auto compiler::variable_stack_index(const ast::expr_identifier::ptr& name, const
{
if (blk->local_vars.at(i).init)
{
return blk->local_vars_create_count - 1 - i;
return static_cast<std::uint8_t>(blk->local_vars_create_count - 1 - i);
}
throw comp_error(name->loc(), "local variable '" + name->value + "' not initialized.");

View File

@ -1787,7 +1787,7 @@ void decompiler::decompile_statements(const ast::stmt_list::ptr& stmt)
void decompiler::decompile_infinites(const ast::stmt_list::ptr& stmt)
{
for (int i = stmt->list.size() - 1; i >= 0; i--)
for (auto i = stmt->list.size() - 1; i > 0; i--)
{
if (stmt->list.at(i) == ast::kind::asm_jump_back)
{
@ -1950,7 +1950,7 @@ void decompiler::decompile_aborts(const ast::stmt_list::ptr& block)
}
}
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_end = stmt->list.at(begin).as_cond->value;
@ -1978,7 +1978,7 @@ void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t beg
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.loc_end = stmt->list.at(end).loc().label();
@ -2029,7 +2029,7 @@ void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.is_last = true;
@ -2089,7 +2089,7 @@ void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uin
}
}
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = last_location_index(stmt, end) ? blocks_.back().loc_end : stmt->list.at(end + 1).loc().label();
@ -2119,7 +2119,7 @@ void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t start, std::uint32_t end)
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::size_t start, std::size_t end)
{
auto& last = block->list.at(end - 1);
@ -2184,7 +2184,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
decompile_while(block, start, end);
}
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2214,7 +2214,7 @@ void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2245,7 +2245,7 @@ void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2299,7 +2299,7 @@ void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t be
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2366,7 +2366,7 @@ void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t start)
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t start)
{
block blk;
blk.loc_continue = blocks_.back().loc_continue;
@ -2479,7 +2479,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + start, std::move(new_stmt));
}
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool
{
for (auto i = begin; i < end; i++)
{
@ -2498,7 +2498,7 @@ auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::u
return false;
}
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t
{
auto index = 0u;
@ -2516,7 +2516,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
throw decomp_error("LOCATION NOT FOUND! (" + location + ")");
}
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool
{
if (index == stmt->list.size() - 1)
return true;
@ -3334,7 +3334,7 @@ void decompiler::process_var_access(ast::expr& expr, const block::ptr& blk)
void decompiler::process_var_remove(const ast::asm_remove::ptr& expr, const block::ptr& blk)
{
blk->local_vars_public_count = blk->local_vars.size() - std::stoi(expr->index);
blk->local_vars_public_count = static_cast<std::uint32_t>(blk->local_vars.size() - std::stoi(expr->index));
}
} // namespace xsk::gsc::s1

View File

@ -34,19 +34,19 @@ private:
void decompile_switches(const ast::stmt_list::ptr& stmt);
void decompile_ifelses(const ast::stmt_list::ptr& stmt);
void decompile_aborts(const ast::stmt_list::ptr& stmt);
void decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool;
void decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool;
void process_stack(const ast::decl_thread::ptr& thread);
void process_parameters(const ast::expr_parameters::ptr& params, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);

View File

@ -51,7 +51,7 @@ void disassembler::disassemble(const std::string& file, std::vector<std::uint8_t
func->index = static_cast<std::uint32_t>(script_->pos());
func->size = stack_->read<std::uint32_t>();
func->id = stack_->read<std::uint16_t>();
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(func->id);
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(static_cast<std::uint16_t>(func->id));
dissasemble_function(func);

View File

@ -97,7 +97,7 @@ void reader::init(const char* data, size_t size)
{
state = reader::ok;
buffer_pos = data;
bytes_remaining = size;
bytes_remaining = static_cast<std::uint32_t>(size);
last_byte = 0;
current_byte = *data;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// A Bison parser, made by GNU Bison 3.7.5.
// A Bison parser, made by GNU Bison 3.8.2.
// Skeleton interface for Bison LALR(1) parsers in C++
@ -15,7 +15,7 @@
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// As a special exception, you may create a larger work that contains
// part or all of the Bison parser skeleton and distribute that work
@ -47,10 +47,14 @@
// "%code requires" blocks.
#line 28 "parser.ypp"
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "s1.hpp"
namespace xsk::gsc::s1 { class lexer; }
#line 54 "parser.hpp"
#line 58 "parser.hpp"
# include <cassert>
# include <cstdlib> // std::abort
@ -126,12 +130,18 @@ namespace xsk::gsc::s1 { class lexer; }
# define YY_USE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
# else
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
@ -193,7 +203,7 @@ namespace xsk::gsc::s1 { class lexer; }
#line 13 "parser.ypp"
namespace xsk { namespace gsc { namespace s1 {
#line 197 "parser.hpp"
#line 207 "parser.hpp"
@ -202,27 +212,32 @@ namespace xsk { namespace gsc { namespace s1 {
class parser
{
public:
#ifndef S1STYPE
#ifdef S1STYPE
# ifdef __GNUC__
# pragma GCC message "bison: do not #define S1STYPE in C++, use %define api.value.type"
# endif
typedef S1STYPE value_type;
#else
/// A buffer to store and retrieve objects.
///
/// Sort of a variant, but does not keep track of the nature
/// of the stored data, since that knowledge is available
/// via the current parser state.
class semantic_type
class value_type
{
public:
/// Type of *this.
typedef semantic_type self_type;
typedef value_type self_type;
/// Empty construction.
semantic_type () YY_NOEXCEPT
: yybuffer_ ()
value_type () YY_NOEXCEPT
: yyraw_ ()
, yytypeid_ (YY_NULLPTR)
{}
/// Construct and fill.
template <typename T>
semantic_type (YY_RVREF (T) t)
value_type (YY_RVREF (T) t)
: yytypeid_ (&typeid (T))
{
S1_ASSERT (sizeof (T) <= size);
@ -231,13 +246,13 @@ namespace xsk { namespace gsc { namespace s1 {
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
semantic_type (const self_type&) = delete;
value_type (const self_type&) = delete;
/// Non copyable.
self_type& operator= (const self_type&) = delete;
#endif
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
~value_type () YY_NOEXCEPT
{
S1_ASSERT (!yytypeid_);
}
@ -381,7 +396,7 @@ namespace xsk { namespace gsc { namespace s1 {
private:
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
semantic_type (const self_type&);
value_type (const self_type&);
/// Non copyable.
self_type& operator= (const self_type&);
#endif
@ -391,7 +406,7 @@ namespace xsk { namespace gsc { namespace s1 {
T*
yyas_ () YY_NOEXCEPT
{
void *yyp = yybuffer_.yyraw;
void *yyp = yyraw_;
return static_cast<T*> (yyp);
}
@ -400,7 +415,7 @@ namespace xsk { namespace gsc { namespace s1 {
const T*
yyas_ () const YY_NOEXCEPT
{
const void *yyp = yybuffer_.yyraw;
const void *yyp = yyraw_;
return static_cast<const T*> (yyp);
}
@ -635,18 +650,19 @@ namespace xsk { namespace gsc { namespace s1 {
union
{
/// Strongest alignment constraints.
long double yyalign_me;
long double yyalign_me_;
/// A buffer large enough to store any of the semantic values.
char yyraw[size];
} yybuffer_;
char yyraw_[size];
};
/// Whether the content is built: if defined, the name of the stored type.
const std::type_info *yytypeid_;
};
#else
typedef S1STYPE semantic_type;
#endif
/// Backward compatibility (Bison 3.8).
typedef value_type semantic_type;
/// Symbol locations.
typedef xsk::gsc::location location_type;
@ -793,7 +809,7 @@ namespace xsk { namespace gsc { namespace s1 {
};
/// Token kind, as returned by yylex.
typedef token::yytokentype token_kind_type;
typedef token::token_kind_type token_kind_type;
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type token_type;
@ -1023,7 +1039,7 @@ namespace xsk { namespace gsc { namespace s1 {
typedef Base super_type;
/// Default constructor.
basic_symbol ()
basic_symbol () YY_NOEXCEPT
: value ()
, location ()
{}
@ -2291,6 +2307,8 @@ namespace xsk { namespace gsc { namespace s1 {
clear ();
}
/// Destroy contents, and record that is empty.
void clear () YY_NOEXCEPT
{
@ -2617,7 +2635,7 @@ switch (yykind)
void move (basic_symbol& s);
/// The semantic value.
semantic_type value;
value_type value;
/// The location.
location_type location;
@ -2632,22 +2650,24 @@ switch (yykind)
/// Type access provider for token (enum) based symbols.
struct by_kind
{
/// Default constructor.
by_kind ();
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that);
#endif
/// Copy constructor.
by_kind (const by_kind& that);
/// The symbol kind as needed by the constructor.
typedef token_kind_type kind_type;
/// Default constructor.
by_kind () YY_NOEXCEPT;
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that) YY_NOEXCEPT;
#endif
/// Copy constructor.
by_kind (const by_kind& that) YY_NOEXCEPT;
/// Constructor from (external) token numbers.
by_kind (kind_type t);
by_kind (kind_type t) YY_NOEXCEPT;
/// Record that this symbol is empty.
void clear () YY_NOEXCEPT;
@ -2677,30 +2697,34 @@ switch (yykind)
typedef basic_symbol<by_kind> super_type;
/// Empty symbol.
symbol_type () {}
symbol_type () YY_NOEXCEPT {}
/// Constructor for valueless symbols, and symbols from each type.
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, location_type l)
: super_type(token_type (tok), std::move (l))
: super_type (token_kind_type (tok), std::move (l))
#else
symbol_type (int tok, const location_type& l)
: super_type(token_type (tok), l)
: super_type (token_kind_type (tok), l)
#endif
{
#if !defined _MSC_VER || defined __clang__
S1_ASSERT (tok == token::S1EOF
|| (token::S1error <= tok && tok <= token::MOD)
|| (token::SIZEOF <= tok && tok <= token::POSTDEC));
#endif
}
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, std::string v, location_type l)
: super_type(token_type (tok), std::move (v), std::move (l))
: super_type (token_kind_type (tok), std::move (v), std::move (l))
#else
symbol_type (int tok, const std::string& v, const location_type& l)
: super_type(token_type (tok), v, l)
: super_type (token_kind_type (tok), v, l)
#endif
{
#if !defined _MSC_VER || defined __clang__
S1_ASSERT ((token::PATH <= tok && tok <= token::INTEGER));
#endif
}
};
@ -2749,7 +2773,7 @@ switch (yykind)
/// YYSYMBOL. No bounds checking.
static const char *symbol_name (symbol_kind_type yysymbol);
// Implementation of make_symbol for each symbol type.
// Implementation of make_symbol for each token kind.
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4501,19 +4525,19 @@ switch (yykind)
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
static bool yy_pact_value_is_default_ (int yyvalue);
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
/// Whether the given \c yytable_ value indicates a syntax error.
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
static const short yypact_ninf_;
static const short yytable_ninf_;
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
/// are valid, yet not members of the token_kind_type enum.
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
@ -4540,14 +4564,14 @@ switch (yykind)
static const short yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
// YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
// state STATE-NUM.
static const unsigned char yystos_[];
// YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
// YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.
static const unsigned char yyr1_[];
// YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
// YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.
static const signed char yyr2_[];
@ -4646,7 +4670,7 @@ switch (yykind)
typedef typename S::size_type size_type;
typedef typename std::ptrdiff_t index_type;
stack (size_type n = 200)
stack (size_type n = 200) YY_NOEXCEPT
: seq_ (n)
{}
@ -4725,7 +4749,7 @@ switch (yykind)
class slice
{
public:
slice (const stack& stack, index_type range)
slice (const stack& stack, index_type range) YY_NOEXCEPT
: stack_ (stack)
, range_ (range)
{}
@ -4784,7 +4808,7 @@ switch (yykind)
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
void yypop_ (int n = 1) YY_NOEXCEPT;
/// Constants.
enum
@ -4803,7 +4827,7 @@ switch (yykind)
inline
parser::symbol_kind_type
parser::yytranslate_ (int t)
parser::yytranslate_ (int t) YY_NOEXCEPT
{
return static_cast<symbol_kind_type> (t);
}
@ -5112,6 +5136,7 @@ switch (yykind)
template <typename Base>
parser::symbol_kind_type
parser::basic_symbol<Base>::type_get () const YY_NOEXCEPT
@ -5119,6 +5144,7 @@ switch (yykind)
return this->kind ();
}
template <typename Base>
bool
parser::basic_symbol<Base>::empty () const YY_NOEXCEPT
@ -5429,13 +5455,13 @@ switch (yykind)
// by_kind.
inline
parser::by_kind::by_kind ()
parser::by_kind::by_kind () YY_NOEXCEPT
: kind_ (symbol_kind::S_YYEMPTY)
{}
#if 201103L <= YY_CPLUSPLUS
inline
parser::by_kind::by_kind (by_kind&& that)
parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
: kind_ (that.kind_)
{
that.clear ();
@ -5443,15 +5469,17 @@ switch (yykind)
#endif
inline
parser::by_kind::by_kind (const by_kind& that)
parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
: kind_ (that.kind_)
{}
inline
parser::by_kind::by_kind (token_kind_type t)
parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
: kind_ (yytranslate_ (t))
{}
inline
void
parser::by_kind::clear () YY_NOEXCEPT
@ -5474,6 +5502,7 @@ switch (yykind)
return kind_;
}
inline
parser::symbol_kind_type
parser::by_kind::type_get () const YY_NOEXCEPT
@ -5481,9 +5510,10 @@ switch (yykind)
return this->kind ();
}
#line 13 "parser.ypp"
} } } // xsk::gsc::s1
#line 5487 "parser.hpp"
#line 5517 "parser.hpp"

View File

@ -6,6 +6,11 @@
#include "stdafx.hpp"
#include "s1.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4244)
#endif
namespace xsk::gsc::s1
{
@ -61,7 +66,7 @@ auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = function_map_rev.find(name);
@ -90,7 +95,7 @@ auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = method_map_rev.find(name);
@ -119,7 +124,7 @@ auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = file_map_rev.find(name);
@ -148,7 +153,7 @@ auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = token_map_rev.find(name);
@ -212,7 +217,7 @@ auto resolver::make_token(std::string_view str) -> std::string
for (std::size_t i = 0; i < data.size(); i++)
{
data[i] = std::tolower(str[i]);
data[i] = static_cast<char>(std::tolower(static_cast<unsigned char>(str[i])));
if (data[i] == '\\') data[i] = '/';
}
@ -2662,3 +2667,7 @@ struct __init__
__init__ _;
} // namespace xsk::gsc::s1
#ifdef _MSC_VER
#pragma warning(pop)
#endif

View File

@ -5,38 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4005)
#pragma warning(disable:4018)
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4389)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <set>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/s2.hpp"

View File

@ -143,7 +143,7 @@ void assembler::assemble_function(const function::ptr& func)
func->id = resolver::token_id(func->name);
stack_->write<std::uint32_t>(func->size);
stack_->write<std::uint16_t>(func->id);
stack_->write<std::uint16_t>(static_cast<std::uint16_t>(func->id));
if (func->id == 0)
{
@ -454,7 +454,7 @@ void assembler::assemble_end_switch(const instruction::ptr& inst)
const auto count = std::stoul(inst->data[0]);
script_->write<std::uint16_t>(count);
script_->write<std::uint16_t>(static_cast<std::uint16_t>(count));
std::uint32_t index = inst->index + 3;
@ -521,15 +521,15 @@ void assembler::assemble_jump(const instruction::ptr& inst, bool expr, bool back
if (expr)
{
script_->write<std::int16_t>(addr - inst->index - 3);
script_->write<std::int16_t>(static_cast<std::int16_t>(addr - inst->index - 3));
}
else if (back)
{
script_->write<std::int16_t>((inst->index + 3) - addr);
script_->write<std::int16_t>(static_cast<std::int16_t>((inst->index + 3) - addr));
}
else
{
script_->write<std::int32_t>(addr - inst->index - 5);
script_->write<std::int32_t>(static_cast<std::int32_t>(addr - inst->index - 5));
}
}
@ -548,11 +548,11 @@ void assembler::assemble_offset(std::int32_t offset)
auto assembler::resolve_function(const std::string& name) -> std::int32_t
{
for (const auto& func : functions_)
for (const auto& entry : functions_)
{
if (func->name == name)
if (entry->name == name)
{
return func->index;
return entry->index;
}
}
@ -561,11 +561,11 @@ auto assembler::resolve_function(const std::string& name) -> std::int32_t
auto assembler::resolve_label(const std::string& name) -> std::int32_t
{
for (const auto& func : labels_)
for (const auto& entry : labels_)
{
if (func.second == name)
if (entry.second == name)
{
return func.first;
return entry.first;
}
}

View File

@ -848,7 +848,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
emit_opcode(opcode::OP_endswitch, data);
auto offset = 7 * stmt->stmt->list.size();
auto offset = static_cast<std::uint32_t>(7 * stmt->stmt->list.size());
function_->instructions.back()->size += offset;
index_ += offset;
@ -2669,7 +2669,7 @@ auto compiler::variable_stack_index(const ast::expr_identifier::ptr& name, const
{
if (blk->local_vars.at(i).init)
{
return blk->local_vars_create_count - 1 - i;
return static_cast<std::uint8_t>(blk->local_vars_create_count - 1 - i);
}
throw comp_error(name->loc(), "local variable '" + name->value + "' not initialized.");

View File

@ -1794,7 +1794,7 @@ void decompiler::decompile_statements(const ast::stmt_list::ptr& stmt)
void decompiler::decompile_infinites(const ast::stmt_list::ptr& stmt)
{
for (int i = stmt->list.size() - 1; i >= 0; i--)
for (auto i = stmt->list.size() - 1; i > 0; i--)
{
if (stmt->list.at(i) == ast::kind::asm_jump_back)
{
@ -1957,7 +1957,7 @@ void decompiler::decompile_aborts(const ast::stmt_list::ptr& block)
}
}
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_end = stmt->list.at(begin).as_cond->value;
@ -1985,7 +1985,7 @@ void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t beg
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.loc_end = stmt->list.at(end).loc().label();
@ -2036,7 +2036,7 @@ void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.is_last = true;
@ -2096,7 +2096,7 @@ void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uin
}
}
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = last_location_index(stmt, end) ? blocks_.back().loc_end : stmt->list.at(end + 1).loc().label();
@ -2126,7 +2126,7 @@ void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t start, std::uint32_t end)
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::size_t start, std::size_t end)
{
auto& last = block->list.at(end - 1);
@ -2191,7 +2191,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
decompile_while(block, start, end);
}
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2221,7 +2221,7 @@ void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2252,7 +2252,7 @@ void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2306,7 +2306,7 @@ void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t be
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2373,7 +2373,7 @@ void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t start)
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t start)
{
block blk;
blk.loc_continue = blocks_.back().loc_continue;
@ -2486,7 +2486,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + start, std::move(new_stmt));
}
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool
{
for (auto i = begin; i < end; i++)
{
@ -2505,7 +2505,7 @@ auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::u
return false;
}
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t
{
auto index = 0u;
@ -2523,7 +2523,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
throw decomp_error("LOCATION NOT FOUND! (" + location + ")");
}
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool
{
if (index == stmt->list.size() - 1)
return true;
@ -3341,7 +3341,7 @@ void decompiler::process_var_access(ast::expr& expr, const block::ptr& blk)
void decompiler::process_var_remove(const ast::asm_remove::ptr& expr, const block::ptr& blk)
{
blk->local_vars_public_count = blk->local_vars.size() - std::stoi(expr->index);
blk->local_vars_public_count = static_cast<std::uint32_t>(blk->local_vars.size() - std::stoi(expr->index));
}
} // namespace xsk::gsc::s2

View File

@ -34,19 +34,19 @@ private:
void decompile_switches(const ast::stmt_list::ptr& stmt);
void decompile_ifelses(const ast::stmt_list::ptr& stmt);
void decompile_aborts(const ast::stmt_list::ptr& stmt);
void decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool;
void decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool;
void process_stack(const ast::decl_thread::ptr& thread);
void process_parameters(const ast::expr_parameters::ptr& params, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);

View File

@ -51,7 +51,7 @@ void disassembler::disassemble(const std::string& file, std::vector<std::uint8_t
func->index = static_cast<std::uint32_t>(script_->pos());
func->size = stack_->read<std::uint32_t>();
func->id = stack_->read<std::uint16_t>();
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(func->id);
func->name = func->id == 0 ? stack_->read_c_string() : resolver::token_name(static_cast<std::uint16_t>(func->id));
dissasemble_function(func);

View File

@ -97,7 +97,7 @@ void reader::init(const char* data, size_t size)
{
state = reader::ok;
buffer_pos = data;
bytes_remaining = size;
bytes_remaining = static_cast<std::uint32_t>(size);
last_byte = 0;
current_byte = *data;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// A Bison parser, made by GNU Bison 3.7.5.
// A Bison parser, made by GNU Bison 3.8.2.
// Skeleton interface for Bison LALR(1) parsers in C++
@ -15,7 +15,7 @@
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// As a special exception, you may create a larger work that contains
// part or all of the Bison parser skeleton and distribute that work
@ -47,10 +47,14 @@
// "%code requires" blocks.
#line 28 "parser.ypp"
#ifdef _MSC_VER
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#endif
#include "s2.hpp"
namespace xsk::gsc::s2 { class lexer; }
#line 54 "parser.hpp"
#line 58 "parser.hpp"
# include <cassert>
# include <cstdlib> // std::abort
@ -126,12 +130,18 @@ namespace xsk::gsc::s2 { class lexer; }
# define YY_USE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
# else
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
@ -193,7 +203,7 @@ namespace xsk::gsc::s2 { class lexer; }
#line 13 "parser.ypp"
namespace xsk { namespace gsc { namespace s2 {
#line 197 "parser.hpp"
#line 207 "parser.hpp"
@ -202,27 +212,32 @@ namespace xsk { namespace gsc { namespace s2 {
class parser
{
public:
#ifndef S2STYPE
#ifdef S2STYPE
# ifdef __GNUC__
# pragma GCC message "bison: do not #define S2STYPE in C++, use %define api.value.type"
# endif
typedef S2STYPE value_type;
#else
/// A buffer to store and retrieve objects.
///
/// Sort of a variant, but does not keep track of the nature
/// of the stored data, since that knowledge is available
/// via the current parser state.
class semantic_type
class value_type
{
public:
/// Type of *this.
typedef semantic_type self_type;
typedef value_type self_type;
/// Empty construction.
semantic_type () YY_NOEXCEPT
: yybuffer_ ()
value_type () YY_NOEXCEPT
: yyraw_ ()
, yytypeid_ (YY_NULLPTR)
{}
/// Construct and fill.
template <typename T>
semantic_type (YY_RVREF (T) t)
value_type (YY_RVREF (T) t)
: yytypeid_ (&typeid (T))
{
S2_ASSERT (sizeof (T) <= size);
@ -231,13 +246,13 @@ namespace xsk { namespace gsc { namespace s2 {
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
semantic_type (const self_type&) = delete;
value_type (const self_type&) = delete;
/// Non copyable.
self_type& operator= (const self_type&) = delete;
#endif
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
~value_type () YY_NOEXCEPT
{
S2_ASSERT (!yytypeid_);
}
@ -381,7 +396,7 @@ namespace xsk { namespace gsc { namespace s2 {
private:
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
semantic_type (const self_type&);
value_type (const self_type&);
/// Non copyable.
self_type& operator= (const self_type&);
#endif
@ -391,7 +406,7 @@ namespace xsk { namespace gsc { namespace s2 {
T*
yyas_ () YY_NOEXCEPT
{
void *yyp = yybuffer_.yyraw;
void *yyp = yyraw_;
return static_cast<T*> (yyp);
}
@ -400,7 +415,7 @@ namespace xsk { namespace gsc { namespace s2 {
const T*
yyas_ () const YY_NOEXCEPT
{
const void *yyp = yybuffer_.yyraw;
const void *yyp = yyraw_;
return static_cast<const T*> (yyp);
}
@ -635,18 +650,19 @@ namespace xsk { namespace gsc { namespace s2 {
union
{
/// Strongest alignment constraints.
long double yyalign_me;
long double yyalign_me_;
/// A buffer large enough to store any of the semantic values.
char yyraw[size];
} yybuffer_;
char yyraw_[size];
};
/// Whether the content is built: if defined, the name of the stored type.
const std::type_info *yytypeid_;
};
#else
typedef S2STYPE semantic_type;
#endif
/// Backward compatibility (Bison 3.8).
typedef value_type semantic_type;
/// Symbol locations.
typedef xsk::gsc::location location_type;
@ -793,7 +809,7 @@ namespace xsk { namespace gsc { namespace s2 {
};
/// Token kind, as returned by yylex.
typedef token::yytokentype token_kind_type;
typedef token::token_kind_type token_kind_type;
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type token_type;
@ -1023,7 +1039,7 @@ namespace xsk { namespace gsc { namespace s2 {
typedef Base super_type;
/// Default constructor.
basic_symbol ()
basic_symbol () YY_NOEXCEPT
: value ()
, location ()
{}
@ -2291,6 +2307,8 @@ namespace xsk { namespace gsc { namespace s2 {
clear ();
}
/// Destroy contents, and record that is empty.
void clear () YY_NOEXCEPT
{
@ -2617,7 +2635,7 @@ switch (yykind)
void move (basic_symbol& s);
/// The semantic value.
semantic_type value;
value_type value;
/// The location.
location_type location;
@ -2632,22 +2650,24 @@ switch (yykind)
/// Type access provider for token (enum) based symbols.
struct by_kind
{
/// Default constructor.
by_kind ();
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that);
#endif
/// Copy constructor.
by_kind (const by_kind& that);
/// The symbol kind as needed by the constructor.
typedef token_kind_type kind_type;
/// Default constructor.
by_kind () YY_NOEXCEPT;
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that) YY_NOEXCEPT;
#endif
/// Copy constructor.
by_kind (const by_kind& that) YY_NOEXCEPT;
/// Constructor from (external) token numbers.
by_kind (kind_type t);
by_kind (kind_type t) YY_NOEXCEPT;
/// Record that this symbol is empty.
void clear () YY_NOEXCEPT;
@ -2677,30 +2697,34 @@ switch (yykind)
typedef basic_symbol<by_kind> super_type;
/// Empty symbol.
symbol_type () {}
symbol_type () YY_NOEXCEPT {}
/// Constructor for valueless symbols, and symbols from each type.
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, location_type l)
: super_type(token_type (tok), std::move (l))
: super_type (token_kind_type (tok), std::move (l))
#else
symbol_type (int tok, const location_type& l)
: super_type(token_type (tok), l)
: super_type (token_kind_type (tok), l)
#endif
{
#if !defined _MSC_VER || defined __clang__
S2_ASSERT (tok == token::S2EOF
|| (token::S2error <= tok && tok <= token::MOD)
|| (token::SIZEOF <= tok && tok <= token::POSTDEC));
#endif
}
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, std::string v, location_type l)
: super_type(token_type (tok), std::move (v), std::move (l))
: super_type (token_kind_type (tok), std::move (v), std::move (l))
#else
symbol_type (int tok, const std::string& v, const location_type& l)
: super_type(token_type (tok), v, l)
: super_type (token_kind_type (tok), v, l)
#endif
{
#if !defined _MSC_VER || defined __clang__
S2_ASSERT ((token::PATH <= tok && tok <= token::INTEGER));
#endif
}
};
@ -2749,7 +2773,7 @@ switch (yykind)
/// YYSYMBOL. No bounds checking.
static const char *symbol_name (symbol_kind_type yysymbol);
// Implementation of make_symbol for each symbol type.
// Implementation of make_symbol for each token kind.
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4501,19 +4525,19 @@ switch (yykind)
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
static bool yy_pact_value_is_default_ (int yyvalue);
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
/// Whether the given \c yytable_ value indicates a syntax error.
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
static const short yypact_ninf_;
static const short yytable_ninf_;
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
/// are valid, yet not members of the token_kind_type enum.
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
@ -4540,14 +4564,14 @@ switch (yykind)
static const short yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
// YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
// state STATE-NUM.
static const unsigned char yystos_[];
// YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
// YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.
static const unsigned char yyr1_[];
// YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
// YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.
static const signed char yyr2_[];
@ -4646,7 +4670,7 @@ switch (yykind)
typedef typename S::size_type size_type;
typedef typename std::ptrdiff_t index_type;
stack (size_type n = 200)
stack (size_type n = 200) YY_NOEXCEPT
: seq_ (n)
{}
@ -4725,7 +4749,7 @@ switch (yykind)
class slice
{
public:
slice (const stack& stack, index_type range)
slice (const stack& stack, index_type range) YY_NOEXCEPT
: stack_ (stack)
, range_ (range)
{}
@ -4784,7 +4808,7 @@ switch (yykind)
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
void yypop_ (int n = 1) YY_NOEXCEPT;
/// Constants.
enum
@ -4803,7 +4827,7 @@ switch (yykind)
inline
parser::symbol_kind_type
parser::yytranslate_ (int t)
parser::yytranslate_ (int t) YY_NOEXCEPT
{
return static_cast<symbol_kind_type> (t);
}
@ -5112,6 +5136,7 @@ switch (yykind)
template <typename Base>
parser::symbol_kind_type
parser::basic_symbol<Base>::type_get () const YY_NOEXCEPT
@ -5119,6 +5144,7 @@ switch (yykind)
return this->kind ();
}
template <typename Base>
bool
parser::basic_symbol<Base>::empty () const YY_NOEXCEPT
@ -5429,13 +5455,13 @@ switch (yykind)
// by_kind.
inline
parser::by_kind::by_kind ()
parser::by_kind::by_kind () YY_NOEXCEPT
: kind_ (symbol_kind::S_YYEMPTY)
{}
#if 201103L <= YY_CPLUSPLUS
inline
parser::by_kind::by_kind (by_kind&& that)
parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
: kind_ (that.kind_)
{
that.clear ();
@ -5443,15 +5469,17 @@ switch (yykind)
#endif
inline
parser::by_kind::by_kind (const by_kind& that)
parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
: kind_ (that.kind_)
{}
inline
parser::by_kind::by_kind (token_kind_type t)
parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
: kind_ (yytranslate_ (t))
{}
inline
void
parser::by_kind::clear () YY_NOEXCEPT
@ -5474,6 +5502,7 @@ switch (yykind)
return kind_;
}
inline
parser::symbol_kind_type
parser::by_kind::type_get () const YY_NOEXCEPT
@ -5481,9 +5510,10 @@ switch (yykind)
return this->kind ();
}
#line 13 "parser.ypp"
} } } // xsk::gsc::s2
#line 5487 "parser.hpp"
#line 5517 "parser.hpp"

View File

@ -6,6 +6,11 @@
#include "stdafx.hpp"
#include "s2.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4244)
#endif
namespace xsk::gsc::s2
{
@ -61,7 +66,7 @@ auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = function_map_rev.find(name);
@ -90,7 +95,7 @@ auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(6), nullptr, 16));
}
const auto itr = method_map_rev.find(name);
@ -119,7 +124,7 @@ auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = file_map_rev.find(name);
@ -148,7 +153,7 @@ auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
return static_cast<std::uint16_t>(std::stoul(name.substr(4), nullptr, 16));
}
const auto itr = token_map_rev.find(name);
@ -212,7 +217,7 @@ auto resolver::make_token(std::string_view str) -> std::string
for (std::size_t i = 0; i < data.size(); i++)
{
data[i] = std::tolower(str[i]);
data[i] = static_cast<char>(std::tolower(static_cast<unsigned char>(str[i])));
if (data[i] == '\\') data[i] = '/';
}
@ -3200,3 +3205,7 @@ struct __init__
__init__ _;
} // namespace xsk::gsc::s2
#ifdef _MSC_VER
#pragma warning(pop)
#endif

View File

@ -5,38 +5,22 @@
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4005)
#pragma warning(disable:4018)
#pragma warning(disable:4065)
#pragma warning(disable:4127)
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4389)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <set>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <vector>
// Ext
using namespace std::literals;
#include "xsk/s4.hpp"

View File

@ -507,7 +507,7 @@ void assembler::assemble_end_switch(const instruction::ptr& inst)
const auto count = std::stoul(inst->data[0]);
script_->write<std::uint16_t>(count);
script_->write<std::uint16_t>(static_cast<std::uint16_t>(count));
std::uint32_t index = inst->index + 3;
@ -588,15 +588,15 @@ void assembler::assemble_jump(const instruction::ptr& inst, bool expr, bool back
if (expr)
{
script_->write<std::int16_t>(addr - inst->index - 3);
script_->write<std::int16_t>(static_cast<std::int16_t>(addr - inst->index - 3));
}
else if (back)
{
script_->write<std::int16_t>((inst->index + 3) - addr);
script_->write<std::int16_t>(static_cast<std::int16_t>((inst->index + 3) - addr));
}
else
{
script_->write<std::int32_t>(addr - inst->index - 5);
script_->write<std::int32_t>(static_cast<std::int32_t>(addr - inst->index - 5));
}
}
@ -615,11 +615,11 @@ void assembler::assemble_offset(std::int32_t offset)
auto assembler::resolve_function(const std::string& name) -> std::int32_t
{
for (const auto& func : functions_)
for (const auto& entry : functions_)
{
if (func->name == name)
if (entry->name == name)
{
return func->index;
return entry->index;
}
}
@ -628,11 +628,11 @@ auto assembler::resolve_function(const std::string& name) -> std::int32_t
auto assembler::resolve_label(const std::string& name) -> std::int32_t
{
for (const auto& func : labels_)
for (const auto& entry : labels_)
{
if (func.second == name)
if (entry.second == name)
{
return func.first;
return entry.first;
}
}

View File

@ -848,7 +848,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
emit_opcode(opcode::OP_endswitch, data);
auto offset = 7 * stmt->stmt->list.size();
auto offset = static_cast<std::uint32_t>(7 * stmt->stmt->list.size());
function_->instructions.back()->size += offset;
index_ += offset;
@ -1552,7 +1552,7 @@ void compiler::emit_expr_add_array(const ast::expr_add_array::ptr& expr, const b
void compiler::emit_expr_parameters(const ast::expr_parameters::ptr& expr, const block::ptr& blk)
{
auto num = expr->list.size();
auto num = static_cast<std::uint32_t>(expr->list.size());
if (num)
{
@ -2720,7 +2720,7 @@ auto compiler::variable_stack_index(const ast::expr_identifier::ptr& name, const
{
if (blk->local_vars.at(i).init)
{
return blk->local_vars_create_count - 1 - i;
return static_cast<std::uint8_t>(blk->local_vars_create_count - 1 - i);
}
throw comp_error(name->loc(), "local variable '" + name->value + "' not initialized.");

View File

@ -1818,7 +1818,7 @@ void decompiler::decompile_statements(const ast::stmt_list::ptr& stmt)
void decompiler::decompile_infinites(const ast::stmt_list::ptr& stmt)
{
for (int i = stmt->list.size() - 1; i >= 0; i--)
for (auto i = stmt->list.size() - 1; i > 0; i--)
{
if (stmt->list.at(i) == ast::kind::asm_jump_back)
{
@ -1981,7 +1981,7 @@ void decompiler::decompile_aborts(const ast::stmt_list::ptr& block)
}
}
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_end = stmt->list.at(begin).as_cond->value;
@ -2009,7 +2009,7 @@ void decompiler::decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t beg
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.loc_end = stmt->list.at(end).loc().label();
@ -2060,7 +2060,7 @@ void decompiler::decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block if_blk;
if_blk.is_last = true;
@ -2120,7 +2120,7 @@ void decompiler::decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uin
}
}
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = last_location_index(stmt, end) ? blocks_.back().loc_end : stmt->list.at(end + 1).loc().label();
@ -2150,7 +2150,7 @@ void decompiler::decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t start, std::uint32_t end)
void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::size_t start, std::size_t end)
{
auto& last = block->list.at(end - 1);
@ -2215,7 +2215,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
decompile_while(block, start, end);
}
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2245,7 +2245,7 @@ void decompiler::decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2276,7 +2276,7 @@ void decompiler::decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2330,7 +2330,7 @@ void decompiler::decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t be
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end)
void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end)
{
block blk;
blk.loc_break = stmt->list.at(begin).as_cond->value;
@ -2397,7 +2397,7 @@ void decompiler::decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_
stmt->list.insert(stmt->list.begin() + begin, std::move(new_stmt));
}
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t start)
void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t start)
{
block blk;
blk.loc_continue = blocks_.back().loc_continue;
@ -2510,7 +2510,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
stmt->list.insert(stmt->list.begin() + start, std::move(new_stmt));
}
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool
auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool
{
for (auto i = begin; i < end; i++)
{
@ -2529,7 +2529,7 @@ auto decompiler::find_location_reference(const ast::stmt_list::ptr& stmt, std::u
return false;
}
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t
auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t
{
auto index = 0u;
@ -2547,7 +2547,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
throw decomp_error("LOCATION NOT FOUND! (" + location + ")");
}
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool
auto decompiler::last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool
{
if (index == stmt->list.size() - 1)
return true;
@ -3371,7 +3371,7 @@ void decompiler::process_var_access(ast::expr& expr, const block::ptr& blk)
void decompiler::process_var_remove(const ast::asm_remove::ptr& expr, const block::ptr& blk)
{
blk->local_vars_public_count = blk->local_vars.size() - std::stoi(expr->index);
blk->local_vars_public_count = static_cast<std::uint32_t>(blk->local_vars.size() - std::stoi(expr->index));
}
} // namespace xsk::gsc::s4

View File

@ -34,19 +34,19 @@ private:
void decompile_switches(const ast::stmt_list::ptr& stmt);
void decompile_ifelses(const ast::stmt_list::ptr& stmt);
void decompile_aborts(const ast::stmt_list::ptr& stmt);
void decompile_if(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::uint32_t begin, std::uint32_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::uint32_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::uint32_t index) -> bool;
void decompile_if(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_last_ifelse(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_infinite(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_loop(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_while(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_dowhile(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_for(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_foreach(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end);
void decompile_switch(const ast::stmt_list::ptr& stmt, std::size_t begin);
auto find_location_reference(const ast::stmt_list::ptr& stmt, std::size_t begin, std::size_t end, const std::string& location) -> bool;
auto find_location_index(const ast::stmt_list::ptr& stmt, const std::string& location) -> std::size_t;
auto last_location_index(const ast::stmt_list::ptr& stmt, std::size_t index) -> bool;
void process_stack(const ast::decl_thread::ptr& thread);
void process_parameters(const ast::expr_parameters::ptr& params, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);

View File

@ -99,7 +99,7 @@ void reader::init(const char* data, size_t size)
{
state = reader::ok;
buffer_pos = data;
bytes_remaining = size;
bytes_remaining = static_cast<std::uint32_t>(size);
last_byte = 0;
current_byte = *data;
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More