Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirdEyeSqueegee committed Oct 25, 2023
1 parent 943b51d commit c0886fb
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 114 deletions.
171 changes: 84 additions & 87 deletions CommonLibSF/include/RE/S/Stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,104 +4,101 @@
#include "RE/B/BSTSmartPointer.h"
#include "RE/V/Variable.h"

namespace RE
namespace RE::BSScript
{
namespace BSScript
class IProfilePolicy;
class IStackCallbackFunctor;
class MemoryPage; // stub
class Object;
class StackFrame;

struct IMemoryPagePolicy;

namespace Internal
{
class IProfilePolicy;
class IStackCallbackFunctor;
class MemoryPage; // stub
class Object;
class StackFrame;
class CodeTasklet;
}

struct IMemoryPagePolicy;
namespace UnlinkedTypes
{
struct Object; // stub
}

namespace Internal
class Stack :
public BSIntrusiveRefCounted // 00
{
public:
enum class StackType
{
class CodeTasklet;
}
kNormal,
kPropInit,
kInitEvent
};

namespace UnlinkedTypes
enum class FreezeState
{
struct Object; // stub
}
kUnfrozen,
kFreezing,
kFrozen
};

class Stack :
public BSIntrusiveRefCounted // 00
enum class State
{
public:
enum class StackType
{
kNormal,
kPropInit,
kInitEvent
};

enum class FreezeState
{
kUnfrozen,
kFreezing,
kFrozen
};

enum class State
{
kRunning,
kFinished,
kWaitingOnMemory,
kWaitingOnLatentFunction,
kWaitingInOtherStackForCall,
kWaitingInOtherStackForReturn,
kWaitingInOtherStackForReturnNoPop,
kRetryReturnNoPop,
kRetryCall,
kWaitingOnGuard,
kWaitingOnOtherStackForGuard,
};
kRunning,
kFinished,
kWaitingOnMemory,
kWaitingOnLatentFunction,
kWaitingInOtherStackForCall,
kWaitingInOtherStackForReturn,
kWaitingInOtherStackForReturnNoPop,
kRetryReturnNoPop,
kRetryCall,
kWaitingOnGuard,
kWaitingOnOtherStackForGuard,
};

struct MemoryPageData
{
public:
// members
BSTAutoPointer<MemoryPage> page; // 00
std::uint32_t availableMemoryInBytes; // 08
};
static_assert(sizeof(MemoryPageData) == 0x10);
struct MemoryPageData
{
public:
// members
BSTAutoPointer<MemoryPage> page; // 00
std::uint32_t availableMemoryInBytes; // 08
};
static_assert(sizeof(MemoryPageData) == 0x10);

[[nodiscard]] std::uint32_t GetPageForFrame(const StackFrame* a_frame) const
{
using func_t = decltype(&Stack::GetPageForFrame);
REL::Relocation<func_t> func{ ID::BSScript::Stack::GetPageForFrame };
return func(this, a_frame);
}
[[nodiscard]] std::uint32_t GetPageForFrame(const StackFrame* a_frame) const
{
using func_t = decltype(&Stack::GetPageForFrame);
REL::Relocation<func_t> func{ ID::BSScript::Stack::GetPageForFrame };
return func(this, a_frame);
}

[[nodiscard]] Variable& GetStackFrameVariable(const StackFrame* a_frame, std::uint32_t a_index, std::uint32_t a_pageHint)
{
using func_t = decltype(&Stack::GetStackFrameVariable);
REL::Relocation<func_t> func{ ID::BSScript::Stack::GetStackFrameVariable };
return func(this, a_frame, a_index, a_pageHint);
}
[[nodiscard]] Variable& GetStackFrameVariable(const StackFrame* a_frame, std::uint32_t a_index, std::uint32_t a_pageHint)
{
using func_t = decltype(&Stack::GetStackFrameVariable);
REL::Relocation<func_t> func{ ID::BSScript::Stack::GetStackFrameVariable };
return func(this, a_frame, a_index, a_pageHint);
}

// members
IMemoryPagePolicy* policy; // 08
void* unk10; // 10 -- something to do with guards, guardPolicy maybe?
IProfilePolicy* profilePolicy; // 18
void* unk20; // 20
/*BSTSmallArray<MemoryPageData, 3>*/ char pages[0x40]; // 28
StackFrame* top; // 68
BSTSmartPointer<Internal::CodeTasklet> owningTasklet; // 70
BSTSmartPointer<IStackCallbackFunctor> callback; // 78
BSTSmartPointer<Object> objToUnbind; // 80
BSTSmartPointer<Stack> nextStack; // 88
Variable returnValue; // 90
std::uint64_t unk98; // A0
std::uint64_t unkA0; // A8
std::uint32_t frames; // B0
std::uint32_t stackID; // B4
stl::enumeration<State, std::int32_t> state; // B8
stl::enumeration<FreezeState, std::int32_t> freezeState; // BC
stl::enumeration<StackType, std::int32_t> stackType; // C0
};
static_assert(sizeof(Stack) == 0xC8);
}
// members
IMemoryPagePolicy* policy; // 08
void* unk10; // 10 -- something to do with guards, guardPolicy maybe?
IProfilePolicy* profilePolicy; // 18
void* unk20; // 20
/*BSTSmallArray<MemoryPageData, 3>*/ char pages[0x40]; // 28
StackFrame* top; // 68
BSTSmartPointer<Internal::CodeTasklet> owningTasklet; // 70
BSTSmartPointer<IStackCallbackFunctor> callback; // 78
BSTSmartPointer<Object> objToUnbind; // 80
BSTSmartPointer<Stack> nextStack; // 88
Variable returnValue; // 90
std::uint64_t unk98; // A0
std::uint64_t unkA0; // A8
std::uint32_t frames; // B0
std::uint32_t stackID; // B4
stl::enumeration<State, std::int32_t> state; // B8
stl::enumeration<FreezeState, std::int32_t> freezeState; // BC
stl::enumeration<StackType, std::int32_t> stackType; // C0
};
static_assert(sizeof(Stack) == 0xC8);
}
48 changes: 22 additions & 26 deletions CommonLibSF/include/RE/S/StackFrame.h
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
#pragma once

#include "RE/B/BSFixedString.h"
#include "RE/B/BSTSmartPointer.h"
#include "RE/V/Variable.h"

namespace RE
namespace RE::BSScript
{
namespace BSScript
{
class IFunction;
class ObjectTypeInfo;
class Stack;
class Variable;
class IFunction;
class ObjectTypeInfo;
class Stack;
class Variable;

class StackFrame
{
public:
[[nodiscard]] std::uint32_t GetPageForFrame() const;
[[nodiscard]] Variable& GetStackFrameVariable(std::uint32_t a_index, std::uint32_t a_pageHint) const;
class StackFrame
{
public:
[[nodiscard]] std::uint32_t GetPageForFrame() const;
[[nodiscard]] Variable& GetStackFrameVariable(std::uint32_t a_index, std::uint32_t a_pageHint) const;

// members
Stack* parent; // 00
StackFrame* previousFrame; // 08
BSTSmartPointer<IFunction> owningFunction; // 10
BSTSmartPointer<ObjectTypeInfo> owningObjectType; // 18
Variable self; // 20
std::uint32_t index; // 30
std::uint32_t ip; // 34
std::uint32_t size; // 38
bool instructionsValid; // 3C
};
static_assert(sizeof(StackFrame) == 0x40);
}
// members
Stack* parent; // 00
StackFrame* previousFrame; // 08
BSTSmartPointer<IFunction> owningFunction; // 10
BSTSmartPointer<ObjectTypeInfo> owningObjectType; // 18
Variable self; // 20
std::uint32_t index; // 30
std::uint32_t ip; // 34
std::uint32_t size; // 38
bool instructionsValid; // 3C
};
static_assert(sizeof(StackFrame) == 0x40);
}
1 change: 1 addition & 0 deletions CommonLibSF/src/RE/S/StackFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace RE::BSScript
{
return parent->GetPageForFrame(this);
}

Variable& StackFrame::GetStackFrameVariable(std::uint32_t a_index, std::uint32_t a_pageHint) const
{
return parent->GetStackFrameVariable(this, a_index, a_pageHint);
Expand Down
2 changes: 1 addition & 1 deletion CommonLibSF/test/test.cpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include "RE/Starfield.h"
#include "RE/Starfield.h"

0 comments on commit c0886fb

Please sign in to comment.