mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-16 06:45:44 +08:00
557e77a676
- Add SUBRK and DIVRK bytecode instructions - Enables future performance optimizations Miscellaneous - Small performance improvements to new non-strict mode - Introduce more scripts for fuzzing - Improcements to dataflow analysis
53 lines
1.0 KiB
C++
53 lines
1.0 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
#include "Luau/Common.h"
|
|
|
|
#include <string.h>
|
|
|
|
template<typename T>
|
|
struct ScopedFValue
|
|
{
|
|
private:
|
|
Luau::FValue<T>* value = nullptr;
|
|
T oldValue = T();
|
|
|
|
public:
|
|
ScopedFValue(Luau::FValue<T>& fvalue, T newValue)
|
|
{
|
|
value = &fvalue;
|
|
oldValue = fvalue.value;
|
|
fvalue.value = newValue;
|
|
}
|
|
|
|
ScopedFValue(const ScopedFValue&) = delete;
|
|
ScopedFValue& operator=(const ScopedFValue&) = delete;
|
|
|
|
ScopedFValue(ScopedFValue&& rhs)
|
|
{
|
|
value = rhs.value;
|
|
oldValue = rhs.oldValue;
|
|
|
|
rhs.value = nullptr;
|
|
}
|
|
|
|
ScopedFValue& operator=(ScopedFValue&& rhs)
|
|
{
|
|
value = rhs.value;
|
|
oldValue = rhs.oldValue;
|
|
|
|
rhs.value = nullptr;
|
|
|
|
return *this;
|
|
}
|
|
|
|
~ScopedFValue()
|
|
{
|
|
if (value)
|
|
value->value = oldValue;
|
|
}
|
|
};
|
|
|
|
using ScopedFastFlag = ScopedFValue<bool>;
|
|
using ScopedFastInt = ScopedFValue<int>;
|