-- lparser.cpp's builtinoperators local Pluto_operator_new = function(mt, ...) if not mt then error("attempt to construct a nil value") end if mt.new then return mt.new(...) end local t = {} setmetatable(t, mt) if not rawget(mt, "__index") then mt.__index = mt end if mt.__construct then mt.__construct(t, ...) end return t end local Pluto_operator_extends = function(c, p) if (p_type := type(p)) != "table" then error("expected a class or class-like table to extend, got " .. p_type) end for { -- luaT_eventname "__index", "__mindex", "__newindex", "__gc", "__mode", "__len", "__eq", "__add", "__sub", "__mul", "__mod", "__pow", "__div", "__idiv", "__band", "__bor", "__bxor", "__shl", "__shr", "__unm", "__bnot", "__lt", "__le", "__concat", "__call", "__close", -- misc "__tostring", "__pairs" } as mm do if p[mm] and not c[mm] then c[mm] = p[mm] end end setmetatable(c, { __index = p }) c.__parent = p end local Pluto_operator_instanceof = function(t, mt) t = getmetatable(t) while t do if t == mt then return true end t = t.__parent end return false end local Pluto_operator_spaceship = function(a, b) return a ~= b ? a < b ? -1 : +1 : 0 end local Pluto_operator_ipow = function(x, p) local res = 1 while p > 0 do if p & 1 ~= 0 then res *= x end p >>= 1 x *= x end return res end