mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Dump vector constants when outputting bytecode as text
This commit is contained in:
parent
b3b0e10282
commit
27c4ecaab8
3 changed files with 6 additions and 3 deletions
|
@ -70,7 +70,7 @@ enum LuauOpcode
|
||||||
// D: value (-32768..32767)
|
// D: value (-32768..32767)
|
||||||
LOP_LOADN,
|
LOP_LOADN,
|
||||||
|
|
||||||
// LOADK: sets register to an entry from the constant table from the proto (number/string)
|
// LOADK: sets register to an entry from the constant table from the proto (number/vector/string)
|
||||||
// A: target register
|
// A: target register
|
||||||
// D: constant table index (0..32767)
|
// D: constant table index (0..32767)
|
||||||
LOP_LOADK,
|
LOP_LOADK,
|
||||||
|
|
|
@ -1681,6 +1681,9 @@ void BytecodeBuilder::dumpConstant(std::string& result, int k) const
|
||||||
case Constant::Type_Number:
|
case Constant::Type_Number:
|
||||||
formatAppend(result, "%.17g", data.valueNumber);
|
formatAppend(result, "%.17g", data.valueNumber);
|
||||||
break;
|
break;
|
||||||
|
case Constant::Type_Vector:
|
||||||
|
formatAppend(result, "%.17g, %.17g, %.17g", data.valueVector[0], data.valueVector[1], data.valueVector[2]);
|
||||||
|
break;
|
||||||
case Constant::Type_String:
|
case Constant::Type_String:
|
||||||
{
|
{
|
||||||
const StringRef& str = debugStrings[data.valueString - 1];
|
const StringRef& str = debugStrings[data.valueString - 1];
|
||||||
|
|
|
@ -4497,13 +4497,13 @@ L0: RETURN R0 -1
|
||||||
TEST_CASE("VectorLiterals")
|
TEST_CASE("VectorLiterals")
|
||||||
{
|
{
|
||||||
CHECK_EQ("\n" + compileFunction("return Vector3.new(1, 2, 3)", 0, 2, true), R"(
|
CHECK_EQ("\n" + compileFunction("return Vector3.new(1, 2, 3)", 0, 2, true), R"(
|
||||||
LOADK R0 K0 []
|
LOADK R0 K0 [1, 2, 3]
|
||||||
RETURN R0 1
|
RETURN R0 1
|
||||||
)");
|
)");
|
||||||
|
|
||||||
CHECK_EQ("\n" + compileFunction("print(Vector3.new(1, 2, 3))", 0, 2, true), R"(
|
CHECK_EQ("\n" + compileFunction("print(Vector3.new(1, 2, 3))", 0, 2, true), R"(
|
||||||
GETIMPORT R0 1 [print]
|
GETIMPORT R0 1 [print]
|
||||||
LOADK R1 K2 []
|
LOADK R1 K2 [1, 2, 3]
|
||||||
CALL R0 1 0
|
CALL R0 1 0
|
||||||
RETURN R0 0
|
RETURN R0 0
|
||||||
)");
|
)");
|
||||||
|
|
Loading…
Add table
Reference in a new issue