@@ -113,13 +113,8 @@ bool LuauResourceVisitor::visit(LSLUnaryExpression *un_expr)
113113 if (op == OP_PRE_INCR || op == OP_POST_INCR || op == OP_PRE_DECR || op == OP_POST_DECR)
114114 {
115115 auto *lvalue = (LSLLValueExpression *)child_expr;
116- auto itype = lvalue->getIType ();
117- if (itype == LST_INTEGER)
118- _mCurrentFunc->needs_int_one = true ;
119- else if (itype == LST_FLOATINGPOINT)
120- _mCurrentFunc->needs_float_one = true ;
121- else if (itype == LST_VECTOR)
122- _mCurrentFunc->needs_vector_one = true ;
116+ // We will need the type's `one` value as a low-indexed constant to do these ops
117+ _mCurrentFunc->needed_one_types .insert (lvalue->getType ());
123118 }
124119 else if (op == OP_BIT_NOT)
125120 {
@@ -495,14 +490,9 @@ void LuauVisitor::buildFunction(LSLASTNode *func_like)
495490
496491 // Pre-allocate constants that need small indices (detected by LuauResourceVisitor)
497492 // Do this first to ensure they get low constant indices
498- if (sym_data.needs_int_one )
499- addConstantInteger (1 , UINT8_MAX);
500- if (sym_data.needs_float_one )
501- addConstantFloat (1 .0f , UINT8_MAX);
502- if (sym_data.needs_vector_one )
503- {
504- // Vector <1, 1, 1> for vector increment/decrement
505- addConstantUnder (TYPE (LST_VECTOR)->getOneValue (), UINT8_MAX);
493+ for (auto one_type : sym_data.needed_one_types )
494+ {
495+ addConstantUnder (one_type->getOneValue (), UINT8_MAX);
506496 }
507497
508498 // Pre-allocate import strings to ensure they're under index 1024
0 commit comments