Skip to content

Commit c33bb44

Browse files
committed
Simplify op to string
1 parent f290be1 commit c33bb44

File tree

1 file changed

+2
-43
lines changed

1 file changed

+2
-43
lines changed

luau/src/luau.cpp

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -334,53 +334,12 @@ struct AstSerialize : public Luau::AstVisitor
334334
lua_setfield(L, -2, "location");
335335
}
336336

337-
static std::string toString(Luau::AstExprBinary::Op& op)
338-
{
339-
switch (op)
340-
{
341-
case Luau::AstExprBinary::Op::Add:
342-
return "+";
343-
case Luau::AstExprBinary::Op::Sub:
344-
return "-";
345-
case Luau::AstExprBinary::Op::Mul:
346-
return "*";
347-
case Luau::AstExprBinary::Op::Div:
348-
return "/";
349-
case Luau::AstExprBinary::Op::FloorDiv:
350-
return "//";
351-
case Luau::AstExprBinary::Op::Mod:
352-
return "%";
353-
case Luau::AstExprBinary::Op::Pow:
354-
return "^";
355-
case Luau::AstExprBinary::Op::Concat:
356-
return "..";
357-
case Luau::AstExprBinary::Op::CompareNe:
358-
return "~=";
359-
case Luau::AstExprBinary::Op::CompareEq:
360-
return "==";
361-
case Luau::AstExprBinary::Op::CompareLt:
362-
return "<";
363-
case Luau::AstExprBinary::Op::CompareLe:
364-
return "<=";
365-
case Luau::AstExprBinary::Op::CompareGt:
366-
return ">";
367-
case Luau::AstExprBinary::Op::CompareGe:
368-
return ">=";
369-
case Luau::AstExprBinary::Op::And:
370-
return "and";
371-
case Luau::AstExprBinary::Op::Or:
372-
return "or";
373-
case Luau::AstExprBinary::Op::Op__Count:
374-
return "N/A";
375-
}
376-
}
377-
378337
void serialize(Luau::AstExprBinary::Op& op)
379338
{
380339
if (op == Luau::AstExprBinary::Op::Op__Count)
381340
luaL_error(L, "encountered illegal operator: Op__Count");
382341

383-
lua_pushstring(L, toString(op).data());
342+
lua_pushstring(L, Luau::toString(op).data());
384343
}
385344

386345
// preambleSize should encode the size of the fields we're setting up for _all_ nodes.
@@ -805,7 +764,7 @@ struct AstSerialize : public Luau::AstVisitor
805764
lua_setfield(L, -2, "lhsoperand");
806765

807766
if (const auto cstNode = lookupCstNode<Luau::CstExprOp>(node))
808-
serializeToken(cstNode->opPosition, toString(node->op).data());
767+
serializeToken(cstNode->opPosition, Luau::toString(node->op).data());
809768
else
810769
serialize(node->op);
811770
lua_setfield(L, -2, "operator");

0 commit comments

Comments
 (0)