Files

173 lines
6.4 KiB
C++
Raw Permalink Normal View History

2015-02-15 18:53:04 +03:00
/**
*
* Copyright (c) 2005-2009 Anchorite (TeamX), <anchorite2001@yandex.ru>
2015-02-15 21:33:27 +03:00
* Copyright (c) 2014-2015 Nirran, phobos2077
* Copyright (c) 2015 alexeevdv <mail@alexeevdv.ru>
2015-02-15 18:53:04 +03:00
* Distributed under the GNU GPL v3. For full terms see the file license.txt
*
*/
// C++ standard includes
2015-02-16 00:30:55 +03:00
#include <iostream>
#include <fstream>
2015-02-15 18:53:04 +03:00
// int2ssl includes
2015-02-13 16:59:11 +03:00
#include "FalloutScript.h"
2015-02-15 16:16:45 +03:00
#include "Utility.h"
2015-02-13 16:59:11 +03:00
2015-02-15 18:53:04 +03:00
// Third party includes
2015-02-16 00:30:55 +03:00
extern std::ifstream g_ifstream;
extern std::ofstream g_ofstream;
void CFalloutScript::Dump()
2015-02-13 16:59:11 +03:00
{
2015-02-16 00:30:55 +03:00
g_ofstream << "============== Procedures table ==================" << std::endl
<< std::endl;
m_ProcTable.Dump();
g_ofstream << std::endl;
g_ofstream << std::endl;
2015-02-13 16:59:11 +03:00
2015-02-16 00:30:55 +03:00
g_ofstream << "============== Namespace ==================" << std::endl;
m_Namespace.Dump();
g_ofstream << std::endl;
g_ofstream << std::endl;
2015-02-13 16:59:11 +03:00
2015-02-16 00:30:55 +03:00
g_ofstream << "============== Stringspace ==================" << std::endl;
m_Stringspace.Dump();
g_ofstream << std::endl;
g_ofstream << std::endl;
2015-02-13 16:59:11 +03:00
2015-02-15 16:16:45 +03:00
std::string strOutLine;
2015-02-15 18:10:01 +03:00
uint16_t wOperator;
2015-02-15 18:28:27 +03:00
uint32_t ulArgument = 0;
2015-02-13 16:59:11 +03:00
2015-02-16 00:30:55 +03:00
g_ofstream << "============== Global variables values ==================" << std::endl;
2015-02-13 16:59:11 +03:00
2015-02-15 21:30:47 +03:00
if (m_GlobalVar.empty())
2015-02-13 23:09:21 +03:00
{
2015-02-16 00:30:55 +03:00
g_ofstream << "Not found" << std::endl;
2015-02-14 13:39:47 +03:00
}
2015-02-13 23:09:21 +03:00
else
{
2015-02-15 21:30:47 +03:00
for(unsigned int i = 0; i < m_GlobalVar.size(); i++)
2015-02-13 23:09:21 +03:00
{
2015-02-14 23:18:15 +03:00
wOperator = m_GlobalVar[i].GetOperator();
ulArgument = m_GlobalVar[i].GetArgument();
2015-02-13 16:59:11 +03:00
2015-02-13 23:09:21 +03:00
switch(wOperator)
{
2015-02-14 13:39:47 +03:00
case COpcode::O_STRINGOP:
case COpcode::O_INTOP:
2015-02-16 00:30:55 +03:00
g_ofstream << format("%d: %s(0x%08x) // %u (%d)",
2015-02-14 13:39:47 +03:00
i,
2015-02-14 23:18:15 +03:00
m_GlobalVar[i].GetAttributes().m_strMnemonic.c_str(),
2015-02-13 16:59:11 +03:00
ulArgument,
ulArgument,
2015-02-16 00:30:55 +03:00
ulArgument) << std::endl;
2015-02-14 13:39:47 +03:00
break;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
case COpcode::O_FLOATOP:
2015-02-16 00:30:55 +03:00
g_ofstream << format("%d: %s(0x%08x) // %05f",
2015-02-14 13:39:47 +03:00
i,
2015-02-14 23:18:15 +03:00
m_GlobalVar[i].GetAttributes().m_strMnemonic.c_str(),
2015-02-14 13:39:47 +03:00
ulArgument,
2023-07-02 02:20:03 +02:00
int2ssl::bit_cast<float>(ulArgument)) << std::endl;
2015-02-14 13:39:47 +03:00
}
}
}
2015-02-13 16:59:11 +03:00
2015-02-16 00:30:55 +03:00
g_ofstream << std::endl;
g_ofstream << std::endl;
2015-02-13 16:59:11 +03:00
2015-02-16 00:30:55 +03:00
g_ofstream << "============== Exported variables ==================" << std::endl;
2015-02-13 16:59:11 +03:00
2015-02-15 21:30:47 +03:00
if (m_ExportedVarValue.empty())
2015-02-14 14:38:14 +03:00
{
2015-02-16 00:30:55 +03:00
g_ofstream << "Not found" << std::endl;
2015-02-14 13:39:47 +03:00
}
2015-02-14 14:38:14 +03:00
else
{
2015-02-15 22:27:31 +03:00
for(uint32_t i = 0; i < m_ExportedVarValue.size(); i += 2)
2015-02-14 14:38:14 +03:00
{
2015-02-14 23:18:15 +03:00
wOperator = m_ExportedVarValue[i].GetOperator();
ulArgument = m_ExportedVarValue[i].GetArgument();
2015-02-15 18:28:27 +03:00
uint32_t ulNameArgument = m_ExportedVarValue[i + 1].GetArgument();
2015-02-13 16:59:11 +03:00
2015-02-14 14:38:14 +03:00
switch(wOperator)
{
2015-02-14 13:39:47 +03:00
case COpcode::O_STRINGOP:
2015-02-16 00:30:55 +03:00
g_ofstream << format("%s := \"%s\"",
2015-02-13 16:59:11 +03:00
m_Namespace[ulNameArgument].c_str(),
2015-02-16 00:30:55 +03:00
m_Stringspace[ulArgument].c_str()) << std::endl;
2015-02-14 13:39:47 +03:00
break;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
case COpcode::O_INTOP:
2015-02-16 00:30:55 +03:00
g_ofstream << format("%s := %u (%d)",
2015-02-13 16:59:11 +03:00
m_Namespace[ulNameArgument].c_str(),
2015-02-14 13:39:47 +03:00
ulArgument,
2015-02-16 00:30:55 +03:00
ulArgument) << std::endl;
2015-02-14 13:39:47 +03:00
break;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
case COpcode::O_FLOATOP:
2015-02-16 00:30:55 +03:00
g_ofstream << format("%s := %05f",
2015-02-13 16:59:11 +03:00
m_Namespace[ulNameArgument].c_str(),
2023-07-02 02:20:03 +02:00
int2ssl::bit_cast<float>(ulArgument)) << std::endl;
2015-02-14 13:39:47 +03:00
}
}
}
2015-02-13 16:59:11 +03:00
2015-02-16 00:30:55 +03:00
g_ofstream << std::endl;
g_ofstream << std::endl;
2015-02-13 16:59:11 +03:00
2015-02-16 00:30:55 +03:00
g_ofstream << "============== Procedures ==================" << std::endl;
g_ofstream << std::endl;
2015-02-13 16:59:11 +03:00
2015-02-15 22:27:31 +03:00
for(uint32_t nIndexOfProc = 0; nIndexOfProc < m_ProcTable.GetSize(); nIndexOfProc++)
2015-02-14 14:38:14 +03:00
{
2015-02-16 00:30:55 +03:00
g_ofstream << format("%d: %s (0x%08x)", nIndexOfProc,
2015-02-13 16:59:11 +03:00
m_Namespace[m_ProcTable[nIndexOfProc].m_ulNameOffset].c_str(),
2015-02-16 00:30:55 +03:00
m_ProcTable[nIndexOfProc].m_ulBodyOffset) << std::endl;
g_ofstream << "===============================" << std::endl;
2015-02-13 16:59:11 +03:00
2015-02-15 22:27:31 +03:00
for(uint32_t i = 0; i < m_ProcBodies[nIndexOfProc].size(); i++)
2015-02-14 14:38:14 +03:00
{
2015-02-14 23:18:15 +03:00
wOperator = m_ProcBodies[nIndexOfProc][i].m_Opcode.GetOperator();
ulArgument = m_ProcBodies[nIndexOfProc][i].m_Opcode.GetArgument();
2015-02-13 16:59:11 +03:00
2015-02-14 14:38:14 +03:00
switch(wOperator)
{
2015-02-14 13:39:47 +03:00
case COpcode::O_STRINGOP:
case COpcode::O_INTOP:
2015-02-16 00:30:55 +03:00
g_ofstream << format("0x%08X: 0x%04X 0x%08x - %s(0x%08x) // %u (%d)",
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_ulOffset,
2015-02-14 13:39:47 +03:00
wOperator,
ulArgument,
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_Opcode.GetAttributes().m_strMnemonic.c_str(),
2015-02-14 13:39:47 +03:00
ulArgument,
ulArgument,
2015-02-16 00:30:55 +03:00
ulArgument) << std::endl;
2015-02-14 13:39:47 +03:00
break;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
case COpcode::O_FLOATOP:
2015-02-16 00:30:55 +03:00
g_ofstream << format("0x%08X: 0x%04X 0x%08X - %s // %05f",
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_ulOffset,
2015-02-14 13:39:47 +03:00
wOperator,
ulArgument,
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_Opcode.GetAttributes().m_strMnemonic.c_str(),
2023-07-02 02:20:03 +02:00
int2ssl::bit_cast<float>(ulArgument)) << std::endl;
2015-02-14 13:39:47 +03:00
break;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
default:
2015-02-16 00:30:55 +03:00
g_ofstream << format("0x%08X: 0x%04X - %s",
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_ulOffset,
2015-02-14 13:39:47 +03:00
wOperator,
2015-02-16 00:30:55 +03:00
m_ProcBodies[nIndexOfProc][i].m_Opcode.GetAttributes().m_strMnemonic.c_str()) << std::endl;
2015-02-14 13:39:47 +03:00
}
}
2015-02-13 16:59:11 +03:00
2015-02-16 00:30:55 +03:00
g_ofstream << std::endl;
2015-02-14 13:39:47 +03:00
}
2015-02-13 16:59:11 +03:00
}