-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDecompiler.h
62 lines (48 loc) · 2.42 KB
/
Decompiler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include "CompiledScript.h"
#include "Decompiler.h"
#include "Compile\scii.h"
// fwd decl
class sci::FunctionBase;
class sci::SyntaxNode;
std::string GetBinaryOperatorForInstruction(BYTE b);
std::string GetUnaryOperatorForInstruction(BYTE b);
class IDecompileLookups : public ICompiledScriptLookups
{
public:
IDecompileLookups(WORD wScript, ICompiledScriptLookups *pLookups, IObjectFileScriptLookups *pOFLookups, ICompiledScriptSpecificLookups *pScriptThings, ILookupNames *pTextResource, IPrivateSpeciesLookups *pPrivateSpecies) :
_wScript(wScript), _pLookups(pLookups), _pOFLookups(pOFLookups), _pScriptThings(pScriptThings), _pTextResource(pTextResource), _pPrivateSpecies(pPrivateSpecies)
{
}
// ICompiledScriptLookups
std::string LookupSelectorName(WORD wIndex);
std::string LookupKernelName(WORD wIndex);
std::string LookupClassName(WORD wIndex);
bool LookupSpeciesPropertyList(WORD wIndex, std::vector<WORD> &props);
bool LookupSpeciesPropertyListAndValues(WORD wIndex, std::vector<WORD> &props, std::vector<WORD> &values);
// IObjectFileScriptLookups
std::string ReverseLookupGlobalVariableName(WORD wIndex);
std::string ReverseLookupPublicExportName(WORD wScript, WORD wIndex);
// ILookupPropertyName
std::string LookupPropertyName(WORD wPropertyIndex);
std::string LookupScriptThing(WORD wName, ICompiledScriptSpecificLookups::ObjectType &type) const;
std::string LookupParameterName(WORD wIndex); // 1-based
WORD GetScriptNumber() const { return _wScript; }
std::string LookupTextResource(WORD wIndex) const;
void SetPosition(sci::SyntaxNode *pNode);
void EndowWithProperties(ILookupPropertyName *pPropertyNames) { _pPropertyNames = pPropertyNames; }
void EndowWithFunction(sci::FunctionBase *pFunc) { _pFunc = pFunc; }
private:
WORD _wScript;
ICompiledScriptLookups *_pLookups;
IObjectFileScriptLookups *_pOFLookups;
ICompiledScriptSpecificLookups *_pScriptThings;
ILookupNames *_pTextResource;
ILookupPropertyName *_pPropertyNames;
IPrivateSpeciesLookups *_pPrivateSpecies;
sci::FunctionBase *_pFunc;
LineCol _fakePosition;
};
void DecompileRaw(sci::FunctionBase &func, IDecompileLookups &lookups, const BYTE *pBegin, const BYTE *pEnd, WORD wBaseOffset);
std::string _GetProcNameFromScriptOffset(WORD wOffset);
sci::ValueType _ScriptObjectTypeToPropertyValueType(ICompiledScriptSpecificLookups::ObjectType type);