UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMInt.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if WITH_VERSE_VM || defined(__INTELLISENSE__)
6
8#include "CoreTypes.h"
9#include "HAL/Platform.h"
11#include "Templates/TypeHash.h"
12#include "VVMCell.h"
13#include "VVMContext.h"
14#include "VVMHeapInt.h"
15#include "VVMValue.h"
16#include "VerseVM/VVMFloat.h"
17#include <cstdint>
18
19namespace Verse
20{
21struct VInt : VValue
22{
23 // Be careful using this! Only classes expecting a uninitialized int should use this such as:
24 // TWriteBarrier, VIntType, etc.
25 explicit VInt()
26 : VValue()
27 {
28 }
29 explicit VInt(VValue InValue)
30 : VValue(InValue)
31 {
32 checkSlow(InValue.IsInt());
33 }
34 explicit VInt(int32 InInt32)
35 : VValue(VValue::FromInt32(InInt32))
36 {
37 }
38 VInt(int64) = delete; // nb: use a constructor that takes F*Context explicitly
39 VInt(FAllocationContext Context, int64 Int64)
40 : VValue(Int64 >= INT32_MIN && Int64 <= INT32_MAX
41 ? VValue::FromInt32(static_cast<int32>(Int64))
43 {
44 }
45 VInt(VHeapInt& N)
46 : VValue(N.IsInt32()
47 ? VValue::FromInt32(N.AsInt32())
48 : VValue(N))
49 {
50 }
51
52 bool IsZero() const
53 {
54 if (IsInt32())
55 {
56 return AsInt32() == 0;
57 }
59 return HeapInt.IsZero();
60 }
61
62 bool IsNegative() const
63 {
64 if (IsInt32())
65 {
66 return AsInt32() < 0;
67 }
69 return HeapInt.GetSign();
70 }
71
72 bool IsInt64() const;
73 int64 AsInt64() const;
74
75 bool IsUint32() const;
76 uint32 AsUint32() const;
77
78 VFloat ConvertToFloat() const;
79
80 static VInt Add(FAllocationContext Context, VInt Lhs, VInt Rhs);
81 static VInt Sub(FAllocationContext Context, VInt Lhs, VInt Rhs);
82 static VInt Mul(FAllocationContext Context, VInt Lhs, VInt Rhs);
83 static VInt Div(FAllocationContext Context, VInt Lhs, VInt Rhs, bool* bOutHasNonZeroRemainder = nullptr);
84 static VInt Mod(FAllocationContext Context, VInt Lhs, VInt Rhs);
85 static VInt Neg(FAllocationContext Context, VInt N);
86 static VInt Abs(FAllocationContext Context, VInt N);
87 static bool Eq(FAllocationContext Context, VInt Lhs, VInt Rhs);
88 static bool Eq(FAllocationContext Context, VInt Lhs, VValue Rhs);
89 static bool Gt(FAllocationContext Context, VInt Lhs, VInt Rhs);
90 static bool Lt(FAllocationContext Context, VInt Lhs, VInt Rhs);
91 static bool Gte(FAllocationContext Context, VInt Lhs, VInt Rhs);
92 static bool Lte(FAllocationContext Context, VInt Lhs, VInt Rhs);
93
94 friend uint32 GetTypeHash(VInt Int);
95
96 COREUOBJECT_API void AppendDecimalToString(FUtf8StringBuilderBase& Builder, FAllocationContext Context) const;
98 COREUOBJECT_API TSharedPtr<FJsonValue> ToJSON(FAllocationContext Context, EValueJSONFormat Format) const;
99
100private:
101 VFloat ConvertToFloatSlowPath() const;
102
103 static VInt AddSlowPath(FAllocationContext Context, VInt Lhs, VInt Rhs);
104 static VInt SubSlowPath(FAllocationContext Context, VInt Lhs, VInt Rhs);
105 static VInt MulSlowPath(FAllocationContext Context, VInt Lhs, VInt Rhs);
106 static VInt DivSlowPath(FAllocationContext Context, VInt Lhs, VInt Rhs, bool* bOutHasNonZeroRemainder);
107 static VInt ModSlowPath(FAllocationContext Context, VInt Lhs, VInt Rhs);
108 static VInt NegSlowPath(FAllocationContext Context, VInt N);
109 static VInt AbsSlowPath(FAllocationContext Context, VInt N);
110 static bool EqSlowPath(FAllocationContext Context, VInt Lhs, VInt Rhs);
111 static bool LtSlowPath(FAllocationContext, VInt Lhs, VInt Rhs);
112 static bool GtSlowPath(FAllocationContext, VInt Lhs, VInt Rhs);
113 static bool LteSlowPath(FAllocationContext, VInt Lhs, VInt Rhs);
114 static bool GteSlowPath(FAllocationContext, VInt Lhs, VInt Rhs);
115
116 static VHeapInt& AsHeapInt(FAllocationContext, VInt N);
117};
118
119} // namespace Verse
120#endif // WITH_VERSE_VM
#define checkSlow(expr)
Definition AssertionMacros.h:332
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition SharedPointer.h:692
Definition StringBuilder.h:79
uint32 GetTypeHash(const FKey &Key)
Definition BlackboardKey.h:35
FValue Neg(const FValue &Value)
Definition ShaderValue.cpp:1389
FValue Mul(const FValue &Lhs, const FValue &Rhs)
Definition ShaderValue.cpp:1514
FValue Div(const FValue &Lhs, const FValue &Rhs)
Definition ShaderValue.cpp:1519
Definition Archive.h:36
void AppendDecimalToString(FUtf8StringBuilderBase &Builder, VFloat Float, EFloatStringFormat Format)
Definition VVMFloatPrinting.cpp:25
bool ToJSON(bool Value, JSONValue *JSON, JSONMemoryPoolAllocator &)
Definition JSON.h:211