diff --git a/README.md b/README.md index 91cc72d..5bdedd6 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,16 @@ Python, C, C++ Compiler for Roblox. Python 3.13 (dev), C23, C++20 -> Lua(u) +## Changelog: +- Added C, C++ AST (abstract syntax tree), use the cli and it will output AST +- Added automatic variable checking, check which builtin variables are needed +- Added automatic function checking, check which builtin functions are needed +- Reorganized code +- Added more tests +- Cleaned up code +- Did this changelog + + ## Why did the name get changed to roblox.pyc? 2 reasons: - It's a python compiler, so it should be named .py**c** diff --git a/setup.cfg b/setup.cfg index fc50fbf..159a6db 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = roblox-pyc -version = 1.5.6.3 +version = 1.6.6.3 [options] packages = src @@ -8,6 +8,6 @@ packages = src [options.entry_points] console_scripts = - roblox-py = src.robloxpy:typerapp - roblox-c = src.robloxpy:typerapp2 - roblox-cpp = src.robloxpy:typerapp3 + roblox-py = src.robloxpy:w + roblox-c = src.robloxpy:cw + roblox-cpp = src.robloxpy:cpw diff --git a/src/__init__.py b/src/compiler/__init__.py similarity index 100% rename from src/__init__.py rename to src/compiler/__init__.py diff --git a/src/compiler/__pycache__/__init__.cpython-311.pyc b/src/compiler/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..7e18f33 Binary files /dev/null and b/src/compiler/__pycache__/__init__.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/binopdesc.cpython-311.pyc b/src/compiler/__pycache__/binopdesc.cpython-311.pyc new file mode 100644 index 0000000..c91f815 Binary files /dev/null and b/src/compiler/__pycache__/binopdesc.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/boolopdesc.cpython-311.pyc b/src/compiler/__pycache__/boolopdesc.cpython-311.pyc new file mode 100644 index 0000000..fce560f Binary files /dev/null and b/src/compiler/__pycache__/boolopdesc.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/cmpopdesc.cpython-311.pyc b/src/compiler/__pycache__/cmpopdesc.cpython-311.pyc new file mode 100644 index 0000000..e566263 Binary files /dev/null and b/src/compiler/__pycache__/cmpopdesc.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/colortext.cpython-311.pyc b/src/compiler/__pycache__/colortext.cpython-311.pyc new file mode 100644 index 0000000..a9cf5b3 Binary files /dev/null and b/src/compiler/__pycache__/colortext.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/config.cpython-311.pyc b/src/compiler/__pycache__/config.cpython-311.pyc new file mode 100644 index 0000000..61e7e76 Binary files /dev/null and b/src/compiler/__pycache__/config.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/context.cpython-311.pyc b/src/compiler/__pycache__/context.cpython-311.pyc new file mode 100644 index 0000000..91cd902 Binary files /dev/null and b/src/compiler/__pycache__/context.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/cpAST.cpython-311.pyc b/src/compiler/__pycache__/cpAST.cpython-311.pyc new file mode 100644 index 0000000..55eb2a7 Binary files /dev/null and b/src/compiler/__pycache__/cpAST.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/ctranslator.cpython-311.pyc b/src/compiler/__pycache__/ctranslator.cpython-311.pyc new file mode 100644 index 0000000..1dcbda9 Binary files /dev/null and b/src/compiler/__pycache__/ctranslator.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/header.cpython-311.pyc b/src/compiler/__pycache__/header.cpython-311.pyc new file mode 100644 index 0000000..caf73c6 Binary files /dev/null and b/src/compiler/__pycache__/header.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/loopcounter.cpython-311.pyc b/src/compiler/__pycache__/loopcounter.cpython-311.pyc new file mode 100644 index 0000000..f23d8e9 Binary files /dev/null and b/src/compiler/__pycache__/loopcounter.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/luainit.cpython-311.pyc b/src/compiler/__pycache__/luainit.cpython-311.pyc new file mode 100644 index 0000000..e6c6cad Binary files /dev/null and b/src/compiler/__pycache__/luainit.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/nameconstdesc.cpython-311.pyc b/src/compiler/__pycache__/nameconstdesc.cpython-311.pyc new file mode 100644 index 0000000..05d51ef Binary files /dev/null and b/src/compiler/__pycache__/nameconstdesc.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/nodevisitor.cpython-311.pyc b/src/compiler/__pycache__/nodevisitor.cpython-311.pyc new file mode 100644 index 0000000..6a8845f Binary files /dev/null and b/src/compiler/__pycache__/nodevisitor.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/pytranslator.cpython-311.pyc b/src/compiler/__pycache__/pytranslator.cpython-311.pyc new file mode 100644 index 0000000..62664b1 Binary files /dev/null and b/src/compiler/__pycache__/pytranslator.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/symbolsstack.cpython-311.pyc b/src/compiler/__pycache__/symbolsstack.cpython-311.pyc new file mode 100644 index 0000000..904feca Binary files /dev/null and b/src/compiler/__pycache__/symbolsstack.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/tokenendmode.cpython-311.pyc b/src/compiler/__pycache__/tokenendmode.cpython-311.pyc new file mode 100644 index 0000000..7c26ab9 Binary files /dev/null and b/src/compiler/__pycache__/tokenendmode.cpython-311.pyc differ diff --git a/src/compiler/__pycache__/unaryopdesc.cpython-311.pyc b/src/compiler/__pycache__/unaryopdesc.cpython-311.pyc new file mode 100644 index 0000000..0eed197 Binary files /dev/null and b/src/compiler/__pycache__/unaryopdesc.cpython-311.pyc differ diff --git a/src/binopdesc.py b/src/compiler/binopdesc.py similarity index 100% rename from src/binopdesc.py rename to src/compiler/binopdesc.py diff --git a/src/boolopdesc.py b/src/compiler/boolopdesc.py similarity index 100% rename from src/boolopdesc.py rename to src/compiler/boolopdesc.py diff --git a/src/cmpopdesc.py b/src/compiler/cmpopdesc.py similarity index 100% rename from src/cmpopdesc.py rename to src/compiler/cmpopdesc.py diff --git a/src/colortext.py b/src/compiler/colortext.py similarity index 100% rename from src/colortext.py rename to src/compiler/colortext.py diff --git a/src/config.py b/src/compiler/config.py similarity index 100% rename from src/config.py rename to src/compiler/config.py diff --git a/src/context.py b/src/compiler/context.py similarity index 100% rename from src/context.py rename to src/compiler/context.py diff --git a/src/cpAST.py b/src/compiler/cpAST.py similarity index 100% rename from src/cpAST.py rename to src/compiler/cpAST.py diff --git a/src/ctranslator.py b/src/compiler/ctranslator.py similarity index 100% rename from src/ctranslator.py rename to src/compiler/ctranslator.py diff --git a/src/compiler/header.py b/src/compiler/header.py new file mode 100644 index 0000000..675a88b --- /dev/null +++ b/src/compiler/header.py @@ -0,0 +1,18 @@ +headertemplate = """ +--// Compiled using roblox-pyc \\-- + + +------------------------------------ BUILT IN ------------------------------- +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +{} +----------------------------------------------------------------------------- +""" + +def header(functions): + code = "" + for i in functions: + code += "local "+i+" = builtin."+i+"\n" + + #print(code) + return headertemplate.format(code) \ No newline at end of file diff --git a/src/loopcounter.py b/src/compiler/loopcounter.py similarity index 100% rename from src/loopcounter.py rename to src/compiler/loopcounter.py diff --git a/src/luainit.py b/src/compiler/luainit.py similarity index 82% rename from src/luainit.py rename to src/compiler/luainit.py index 96b85ee..54fade8 100644 --- a/src/luainit.py +++ b/src/compiler/luainit.py @@ -1,6 +1,6 @@ initcode = """ - --// AsynchronousAI @Dev98799 \\-- + --// AsynchronousAI @Dev98799 \\-- ------------------------------------------------------------------------------- -- this script was added by roblox-pyc plugin to give you the full experience.-- -- below you will find lua equivelents of built in python functions, it is -- @@ -371,24 +371,29 @@ local module = function(self) - return { - string_meta, list, dict, -- class meta + return { + py = { + { -- python library + + }, + { -- built in + string_meta = string_meta, list = list, dict = dict, -- class meta - function(old_fun) -- staticmethod + staticmethod = function(old_fun) -- staticmethod local wrapper = function(first, ...) return old_fun(...) end return wrapper end, - function(old_fun) -- classmethod + classmethod = function(old_fun) -- classmethod local wrapper = function(first, ...) return old_fun(first, ...) end return wrapper end, - function(class_init, bases) -- class + class = function(class_init, bases) -- class bases = bases or {} local c = {} @@ -431,7 +436,7 @@ return c end, - function(s, e) -- range() + range = function(s, e) -- range() local tb = {} local a = 0 local b = 0 @@ -442,13 +447,13 @@ end return tb end, - self.Name:sub(1,#self.Name-3), -- __name__ - function(x) return #x end, -- len() - math.abs, -- abs() - tostring, -- str() - tonumber, -- int() + __name__ = self.Name:sub(1,#self.Name-3), -- __name__ + len = function(x) return #x end, -- len() + abs = math.abs, -- abs() + str = tostring, -- str() + int = tonumber, -- int() - function(tbl) --sum() + sum = function(tbl) --sum() local total = 0 for _, v in ipairs(tbl) do total = total + v @@ -457,7 +462,7 @@ end, -- Maximum value in a table - function(tbl) --max() + max = function(tbl) --max() local maxValue = -math.huge for _, v in ipairs(tbl) do if v > maxValue then @@ -468,7 +473,7 @@ end, -- Minimum value in a table - function(tbl) --min() + min = function(tbl) --min() local minValue = math.huge for _, v in ipairs(tbl) do if v < minValue then @@ -479,7 +484,7 @@ end, -- Reversed version of a table or string - function(seq) -- reversed() + reversed = function(seq) -- reversed() local reversedSeq = {} local length = #seq for i = length, 1, -1 do @@ -489,7 +494,7 @@ end, -- Splitting a string into a table of substrings - function(str, sep) -- split + split = function(str, sep) -- split local substrings = {} local pattern = string.format("([^%s]+)",sep or "%s") for substring in string.gmatch(str, pattern) do @@ -498,32 +503,31 @@ return substrings end, - math.round, -- round() + round = math.round, -- round() - function (iter) -- all() + all = function (iter) -- all() for i, v in iter do if not v then return false end end return true end, - function (iter) -- any() + any = function (iter) -- any() for i, v in iter do if v then return true end end return false end, - string.byte, -- ord - string.char, -- chr + ord = string.byte, -- ord + chr = string.char, -- chr - function(fun) -- callable() + callable = function(fun) -- callable() if rawget(fun) ~= fun then warn("At the momement Roblox.py's function callable() does not fully support metatables.") end return typeof(rawget(fun)) == "function" end, - - tonumber, + float = tonumber, -- float() - function(format, ...) -- format + format = function(format, ...) -- format local args = {...} local num_args = select("#", ...) @@ -539,14 +543,14 @@ return formatted_string end, - function (value) -- hex + hex = function (value) -- hex return string.format("%x", value) end, - function (obj) -- id + id = function (obj) -- id return print(tostring({obj}):gsub("table: ", ""):split(" ")[1]) end, - function (func, ...) --map + map = function (func, ...) --map local args = {...} local result = {} local num_args = select("#", ...) @@ -571,7 +575,7 @@ return result end, - function(x) -- bool + bool = function(x) -- bool if x == false or x == nil or x == 0 then return false end @@ -584,12 +588,12 @@ return true end, - function(a, b) -- divmod + divmod = function(a, b) -- divmod local res = { math.floor(a / b), math.fmod(a, b) } return unpack(res) end, - slicefun, - function (item, items) -- operator_in() + slice = slicefun, + operator_in = function (item, items) -- operator_in() if type(items) == "table" then for v in items do if v == item then @@ -602,7 +606,7 @@ return false end, - function(func) -- asynchronousfunction + asynchronousfunction = function(func) -- asynchronousfunction return function(...) local all = {...} coroutine.wrap(function() @@ -610,7 +614,7 @@ end)() end end, - function(value, values) -- match + match = function(value, values) -- match if values[value] then return values[value]() elseif values["default"] then @@ -618,45 +622,45 @@ end end, - function (iterator) -- anext + anext = function (iterator) -- anext local status, value = pcall(iterator) if status then return value end end, - function (obj) -- ascii + ascii = function (obj) -- ascii return string.format("%q", tostring(obj)) end, - function (obj) -- dir + dir = function (obj) -- dir local result = {} for key, _ in pairs(obj) do table.insert(result, key) end return result end, - function (obj, name, default) -- getattr + getattr = function (obj, name, default) -- getattr local value = obj[name] if value == nil then return default end return value end, - function () -- globals + globals = function () -- globals return _G end, - function (obj, name) --hasattr + hasattr = function (obj, name) --hasattr return obj[name] ~= nil end, - function (prompt) -- input + input = function (prompt) -- input if not io then error("io is not enabled") end io.write(prompt) return io.read() end, - function (obj, class) -- isinstance + isinstance = function (obj, class) -- isinstance return type(obj) == class end, - function (cls, classinfo) -- issubclass + issubclass = function (cls, classinfo) -- issubclass local mt = getmetatable(cls) while mt do if mt.__index == classinfo then @@ -666,33 +670,33 @@ end return false end, - function (obj) -- iter + iter = function (obj) -- iter if type(obj) == "table" and obj.__iter__ ~= nil then return obj.__iter__ end return nil end, - function () -- locals + locals = function () -- locals return _G end, -- oct() - function (num) --oct + oct = function (num) --oct return string.format("%o", num) end, -- open() - function (filename, mode) --open + open = function (filename, mode) --open if not io then error("io is not enabled") end return io.open(filename, mode) end, -- ord() - function (c) --ord + ord = function (c) --ord return string.byte(c) end, -- pow() - function (base, exponent, modulo) --pow + pow = function (base, exponent, modulo) --pow if modulo ~= nil then return math.pow(base, exponent) % modulo else @@ -701,17 +705,17 @@ end, -- eval() - function (expr, env) + eval = function (expr, env) return loadstring(expr)() end, -- exec() - function (code, env) + exec = function (code, env) return loadstring(expr)() end, -- filter() - function (predicate, iterable) + filter = function (predicate, iterable) local result = {} for _, value in ipairs(iterable) do if predicate(value) then @@ -722,7 +726,7 @@ end, -- frozenset() - function (...) + frozenset = function (...) local elements = {...} local frozenSet = {} for _, element in ipairs(elements) do @@ -731,26 +735,26 @@ return frozenSet end, -- aiter() - function (iterable) -- aiter + aiter = function (iterable) -- aiter return pairs(iterable) end, -- bin() - function (number) -- bin + bin = function (number) -- bin return string.format("%b", number) end, -- complex() - function (real, imag) -- complex + complex = function (real, imag) -- complex return { real = real, imag = imag } end, -- delattr() - function (object, attribute) -- delattr + deltaattr = function (object, attribute) -- delattr object[attribute] = nil end, -- enumerate() - function (iterable) -- enumerate + enumerate = function (iterable) -- enumerate local i = 0 return function() i = i + 1 @@ -762,17 +766,17 @@ end, -- breakpoint() - function () -- breakpoint + breakpoint = function () -- breakpoint -- This function can be left empty or you can add a debug hook to pause execution. -- Here's an example using the debug library to pause execution: debug.sethook(function() - io.write("Breakpoint hit! Press Enter to continue...") - io.read() -- Wait for user input to continue + print("Breakpoint hit!") + --io.read() -- Wait for user input to continue end, "c") end, -- bytearray() - function (arg) -- bytearray + bytearray = function (arg) -- bytearray if type(arg) == "string" then local bytes = {} for i = 1, #arg do @@ -794,7 +798,7 @@ end, -- bytes() - function (arg) -- bytes + bytes = function (arg) -- bytes if type(arg) == "string" then local bytes = {} for i = 1, #arg do @@ -809,7 +813,7 @@ end, -- compile() - function (source, filename, mode) -- compile + compile = function (source, filename, mode) -- compile -- This is a placeholder implementation and might not cover all possible use cases. -- You would need to provide your own implementation based on your specific requirements. -- Here's an example of a simple compilation to execute Lua code directly: @@ -819,7 +823,7 @@ -- help() - function (object) -- help + help = function (object) -- help -- This is a placeholder implementation and might not cover all possible use cases. -- You would need to provide your own implementation based on your specific requirements. -- Here's an example of displaying a help message for an object: @@ -829,7 +833,7 @@ end, -- memoryview() - function (object) -- memoryview + memoryview = function (object) -- memoryview -- This is a placeholder implementation and might not cover all possible use cases. -- You would need to provide your own implementation based on your specific requirements. -- Here's an example of creating a memory view object: @@ -841,7 +845,7 @@ end end, -- repr() - function (object) -- repr + repr = function (object) -- repr -- This is a placeholder implementation and might not cover all possible use cases. -- You would need to provide your own implementation based on your specific requirements. -- Here's an example of generating a representation of an object: @@ -849,7 +853,7 @@ end, -- sorted() - function (iterable, cmp, key, reverse) -- sorted + sorted = function (iterable, cmp, key, reverse) -- sorted -- This is a placeholder implementation and might not cover all possible use cases. -- You would need to provide your own implementation based on your specific requirements. -- Here's an example of sorting an iterable table: @@ -872,7 +876,7 @@ end, -- vars() - function (object) -- vars + vars = function (object) -- vars -- This is a placeholder implementation and might not cover all possible use cases. -- You would need to provide your own implementation based on your specific requirements. -- Here's an example of getting the attributes of an object: @@ -883,124 +887,18 @@ return attributes end, - require, + __import__ = require, + } - ([[object - type - int - float - complex - bool - str - bytes - bytearray - memoryview - list - tuple - range - set - frozenset - dict - slice - property - bool - ellipsis - NotImplemented - super - file - IOError - OSError - EnvironmentError - EOFError - ImportError - IndexError - KeyError - StopIteration - GeneratorExit - KeyboardInterrupt - SystemExit - Exception - BaseException - ArithmeticError - AssertionError - AttributeError - BufferError - EOFError - ImportError - LookupError - MemoryError - NameError - OSError - OverflowError - ReferenceError - RuntimeError - SyntaxError - IndentationError - TabError - SystemError - TypeError - ValueError - UnicodeError - UnicodeDecodeError - UnicodeEncodeError - UnicodeTranslateError - Warning - UserWarning - DeprecationWarning - PendingDeprecationWarning - SyntaxWarning - RuntimeWarning - FutureWarning - ImportWarning - UnicodeWarning - BytesWarning - ResourceWarning - Generator - AsyncGenerator - Iterator - Coroutine - AsyncIterator - ContextManager - AsyncContextManager - CallableIterator - CallableGenerator - Reversible - Sized - Container - Collection - MutableSequence - Sequence - MutableSet - Set - MutableMapping - Mapping - MutableSequence - ByteString - MutableByteString - SupportsAbs - SupportsFloat - SupportsInt - SupportsRound - SupportsComplex - SupportsBytes - SupportsComplex - SupportsBytes - SupportsComplex - SupportsRound - CoroutineWrapperType - ContextManagerWrapperType - AbstractEventLoop - GeneratorWrapperType - AsyncGeneratorWrapperType - AsyncContextManagerWrapperType]]):split("\t"), - - { -- PY library, built in - services = game, - } + } } end return module -""" \ No newline at end of file +""" + +allfunctions = "stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__" + +allfunctions = allfunctions.split(", ") \ No newline at end of file diff --git a/src/nameconstdesc.py b/src/compiler/nameconstdesc.py similarity index 100% rename from src/nameconstdesc.py rename to src/compiler/nameconstdesc.py diff --git a/src/nodevisitor.py b/src/compiler/nodevisitor.py similarity index 100% rename from src/nodevisitor.py rename to src/compiler/nodevisitor.py diff --git a/src/pytranslator.py b/src/compiler/pytranslator.py similarity index 72% rename from src/pytranslator.py rename to src/compiler/pytranslator.py index 66f3c39..a02c769 100644 --- a/src/pytranslator.py +++ b/src/compiler/pytranslator.py @@ -6,7 +6,7 @@ from .nodevisitor import NodeVisitor from .header import header -from .luainit import initcode +from .luainit import initcode, allfunctions class Translator: """Python to lua main class translator""" @@ -28,8 +28,20 @@ def translate(self, pycode): visitor.visit(py_ast_tree) self.output = visitor.output - - return self.to_code() + # check every single line for function calls + functions = [] + for i in range(len(self.to_code().split("\n"))): + # check if a function is being called, like print() + + for function in allfunctions: + if function in self.to_code().split("\n")[i] and function not in functions: + functions.append(function) + + + # create header for function calls + newheader = header(functions) + + return newheader+self.to_code() def to_code(self, code=None, indent=0): """Create a lua code from the compiler output""" @@ -58,8 +70,3 @@ def add_indentation(line): def get_luainit(filename="luainit.lua"): return initcode - - @staticmethod - def get_luahead(filename="header.txt"): - - return header diff --git a/src/symbolsstack.py b/src/compiler/symbolsstack.py similarity index 100% rename from src/symbolsstack.py rename to src/compiler/symbolsstack.py diff --git a/src/tokenendmode.py b/src/compiler/tokenendmode.py similarity index 100% rename from src/tokenendmode.py rename to src/compiler/tokenendmode.py diff --git a/src/unaryopdesc.py b/src/compiler/unaryopdesc.py similarity index 100% rename from src/unaryopdesc.py rename to src/compiler/unaryopdesc.py diff --git a/src/header.py b/src/header.py deleted file mode 100644 index 1491334..0000000 --- a/src/header.py +++ /dev/null @@ -1,8 +0,0 @@ -header = """ ---// Compiled using roblox-pyc \\-- - - ------------------------------------- BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) ------------------------------------------------------------------------------ -""" diff --git a/src/robloxpy.py b/src/robloxpy.py index ad2e1a0..a166380 100644 --- a/src/robloxpy.py +++ b/src/robloxpy.py @@ -6,7 +6,9 @@ import typer -from . import colortext, pytranslator, ctranslator +import compiler.colortext as colortext +import compiler.pytranslator as pytranslator +import compiler.ctranslator as ctranslator class Reporter: """ @@ -85,21 +87,13 @@ def backwordreplace(s, old, new, occurrence): li = s.rsplit(old, occurrence) return new.join(li) -@typerapp.command("p", help="Starts a server on port 5555 for the plugin (decreapted).") def p(): print("The plugin is decreapted. Please use the CLI alongside a Studio+VSCode sync plugin.") @app.route('/', methods=["GET", "POST"]) def base_page(): code = (request.data).decode() - script_name = os.path.realpath(__file__) - folder = os.path.dirname(script_name) - luainit_path = os.path.join(folder, "src/header.lua") - header = "" - with open(luainit_path) as file: - header = file.read() - try: - lua_code = header+translator.translate(code) + lua_code = translator.translate(code) except Exception as e: return "CompileError!:"+str(e) @@ -121,7 +115,6 @@ def library(): port=5555 ) -@typerapp.command("w", help="Whenever enter is clicked in the terminal, compile all files, if exit is typed, exit the program.") def w(): print(colortext.magenta("roblox-py: Ready to compile ", os.path.join(os.path.dirname(os.path.realpath(__file__)), "test")+" ...\n Type 'exit' to exit, Press enter to compile.")) def incli(): @@ -135,7 +128,6 @@ def incli(): if '.py' in file: # compile the file to a file with the same name and path but .lua contents = "" - header = translator.get_luahead() try: with open(os.path.join(r, file)) as rf: @@ -146,7 +138,7 @@ def incli(): continue try: - lua_code = header+translator.translate(contents) + lua_code = translator.translate(contents) print(colortext.green("roblox-py: Compiled "+os.path.join(r, file))) # get the relative path of the file and replace .py with .lua relative_path = backwordreplace(os.path.join(r, file),".py", ".lua", 1) @@ -165,7 +157,6 @@ def incli(): incli() incli() -@typerapp2.command("cw", help="Whenever enter is clicked in the terminal, compile all files, if exit is typed, exit the program.") def cw(): print(colortext.magenta("roblox-c: Ready to compile ", os.path.join(os.path.dirname(os.path.realpath(__file__)), "test")+" ...\n Type 'exit' to exit, Press enter to compile.")) def incli(): @@ -192,7 +183,6 @@ def incli(): incli() incli() -@typerapp3.command("cpw", help="Whenever enter is clicked in the terminal, compile all files, if exit is typed, exit the program.") def cpw(): print(colortext.magenta("roblox-cpp: Ready to compile ", os.path.join(os.path.dirname(os.path.realpath(__file__)), "test")+" ...\n Type 'exit' to exit, Press enter to compile.")) def incli(): @@ -225,8 +215,8 @@ def incli(): mode = input("Select which app to run (1, 2, 3): ") if mode == "1": - typerapp() + w() elif mode == "2": - typerapp2() + cw() elif mode == "3": - typerapp3() \ No newline at end of file + cpw() \ No newline at end of file diff --git a/test/python/ann.lua b/test/python/ann.lua index fcf0d43..95f2216 100644 --- a/test/python/ann.lua +++ b/test/python/ann.lua @@ -1,9 +1,12 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local int = builtin.int + ----------------------------------------------------------------------------- local x: int = 10 local y: int = 20 \ No newline at end of file diff --git a/test/python/asyncdef.lua b/test/python/asyncdef.lua index f5563b3..4d3ef48 100644 --- a/test/python/asyncdef.lua +++ b/test/python/asyncdef.lua @@ -1,9 +1,15 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local asynchronousfunction = builtin.asynchronousfunction +local stringmeta = builtin.stringmeta +local str = builtin.str +local int = builtin.int + ----------------------------------------------------------------------------- local hello = asynchronousfunction(function() print(stringmeta "Hello, world!") diff --git a/test/python/asyncdef.py b/test/python/asyncdef.py index 94cbea1..3d4533f 100644 --- a/test/python/asyncdef.py +++ b/test/python/asyncdef.py @@ -1,2 +1,3 @@ async def hello(): - print("Hello, world!") \ No newline at end of file + print("Hello, world!") + diff --git a/test/python/asyncwith.lua b/test/python/asyncwith.lua index fc03d15..c2e6933 100644 --- a/test/python/asyncwith.lua +++ b/test/python/asyncwith.lua @@ -1,9 +1,16 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local asynchronousfunction = builtin.asynchronousfunction +local stringmeta = builtin.stringmeta +local str = builtin.str +local open = builtin.open +local int = builtin.int + ----------------------------------------------------------------------------- local async_with = asynchronousfunction(function() do diff --git a/test/python/bytes.lua b/test/python/bytes.lua index 02b57f2..412f0c4 100644 --- a/test/python/bytes.lua +++ b/test/python/bytes.lua @@ -1,9 +1,12 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local int = builtin.int + ----------------------------------------------------------------------------- local byte = 'Hello World' print(byte) \ No newline at end of file diff --git a/test/python/class.lua b/test/python/class.lua index 37fea3d..5259e75 100644 --- a/test/python/class.lua +++ b/test/python/class.lua @@ -1,9 +1,15 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local class = builtin.class +local int = builtin.int +local stringmeta = builtin.stringmeta +local str = builtin.str + ----------------------------------------------------------------------------- local Example = class(function(Example) function Example.__init__(self, name) diff --git a/test/python/continue.lua b/test/python/continue.lua index 4be3e5a..bd49744 100644 --- a/test/python/continue.lua +++ b/test/python/continue.lua @@ -1,12 +1,15 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local range = builtin.range + ----------------------------------------------------------------------------- for i in range(10) do if (i == 5) then - continue 17 + continue 8 end end \ No newline at end of file diff --git a/test/python/dict.lua b/test/python/dict.lua index 9f897bd..79872ae 100644 --- a/test/python/dict.lua +++ b/test/python/dict.lua @@ -1,9 +1,15 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local dict = builtin.dict +local stringmeta = builtin.stringmeta +local str = builtin.str +local int = builtin.int + ----------------------------------------------------------------------------- local newdict = dict {} newdict[stringmeta "one"] = 1 diff --git a/test/python/helloworld.lua b/test/python/helloworld.lua index 5802b67..11ad542 100644 --- a/test/python/helloworld.lua +++ b/test/python/helloworld.lua @@ -1,8 +1,13 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local stringmeta = builtin.stringmeta +local str = builtin.str +local int = builtin.int + ----------------------------------------------------------------------------- print(stringmeta "Hello World!") \ No newline at end of file diff --git a/test/python/import.lua b/test/python/import.lua index 24bf798..e11d157 100644 --- a/test/python/import.lua +++ b/test/python/import.lua @@ -1,9 +1,11 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + + ----------------------------------------------------------------------------- local examplelib = require "examplelib" local submodule = require "examplelib.submodule" diff --git a/test/python/in.lua b/test/python/in.lua index ce3586e..24654a6 100644 --- a/test/python/in.lua +++ b/test/python/in.lua @@ -1,9 +1,16 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local stringmeta = builtin.stringmeta +local dict = builtin.dict +local str = builtin.str +local operator_in = builtin.operator_in +local int = builtin.int + ----------------------------------------------------------------------------- local table = dict {[stringmeta "a"] = stringmeta "b", [stringmeta "c"] = stringmeta "d"} if (operator_in(stringmeta "a", table)) then diff --git a/test/python/lambda.lua b/test/python/lambda.lua index 756327e..306a4f4 100644 --- a/test/python/lambda.lua +++ b/test/python/lambda.lua @@ -1,9 +1,12 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local int = builtin.int + ----------------------------------------------------------------------------- local x = function(a) return (bit32.bxor((bit32.bxor((a + 10), 2)), a)) end print(x(5)) \ No newline at end of file diff --git a/test/python/list.lua b/test/python/list.lua index aec159e..0e5a2ff 100644 --- a/test/python/list.lua +++ b/test/python/list.lua @@ -1,9 +1,13 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local list = builtin.list +local int = builtin.int + ----------------------------------------------------------------------------- local newlist = list {1, 2, 3, 4, 5} newlist.append(6) diff --git a/test/python/luaxpy.lua b/test/python/luaxpy.lua index 98ee1b5..4c24fb5 100644 --- a/test/python/luaxpy.lua +++ b/test/python/luaxpy.lua @@ -1,9 +1,14 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local stringmeta = builtin.stringmeta +local str = builtin.str +local int = builtin.int + ----------------------------------------------------------------------------- print(stringmeta "This is from python!") diff --git a/test/python/match.lua b/test/python/match.lua index 1c563e2..0b84a3e 100644 --- a/test/python/match.lua +++ b/test/python/match.lua @@ -1,9 +1,15 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local stringmeta = builtin.stringmeta +local str = builtin.str +local match = builtin.match +local int = builtin.int + ----------------------------------------------------------------------------- local x = stringmeta "10" match(x, { diff --git a/test/python/matrix.lua b/test/python/matrix.lua index bd6e9ba..69f22a0 100644 --- a/test/python/matrix.lua +++ b/test/python/matrix.lua @@ -1,9 +1,15 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local list = builtin.list +local range = builtin.range +local len = builtin.len +local int = builtin.int + ----------------------------------------------------------------------------- local X = list {list {12, 7}, list {4, 5}, list {3, 8}} local result = list {list {0, 0, 0}, list {0, 0, 0}} diff --git a/test/python/memoryaddress.lua b/test/python/memoryaddress.lua index 8356ffb..640dd97 100644 --- a/test/python/memoryaddress.lua +++ b/test/python/memoryaddress.lua @@ -1,9 +1,15 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local stringmeta = builtin.stringmeta +local str = builtin.str +local id = builtin.id +local int = builtin.int + ----------------------------------------------------------------------------- local item = stringmeta "Hello!" local location = id(item) diff --git a/test/python/multiassign.lua b/test/python/multiassign.lua index 9df2077..d577234 100644 --- a/test/python/multiassign.lua +++ b/test/python/multiassign.lua @@ -1,9 +1,12 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local int = builtin.int + ----------------------------------------------------------------------------- local a, b, c = 1, 2, 3 print(a, b, c) \ No newline at end of file diff --git a/test/python/slice.lua b/test/python/slice.lua index b165160..80bc325 100644 --- a/test/python/slice.lua +++ b/test/python/slice.lua @@ -1,9 +1,14 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local stringmeta = builtin.stringmeta +local str = builtin.str +local int = builtin.int + ----------------------------------------------------------------------------- local string = stringmeta "Hello World" print(string["SLICE!(0, 5)"]) \ No newline at end of file diff --git a/test/python/staticmethod.lua b/test/python/staticmethod.lua index 23b15bf..b1dc89d 100644 --- a/test/python/staticmethod.lua +++ b/test/python/staticmethod.lua @@ -1,9 +1,17 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local stringmeta = builtin.stringmeta +local str = builtin.str +local int = builtin.int +local exec = builtin.exec +local staticmethod = builtin.staticmethod +local class = builtin.class + ----------------------------------------------------------------------------- local function foo(x) print((math.fmod(stringmeta "executing foo(%s)", x))) diff --git a/test/python/string.lua b/test/python/string.lua index 762d7c4..a608bea 100644 --- a/test/python/string.lua +++ b/test/python/string.lua @@ -1,9 +1,14 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local stringmeta = builtin.stringmeta +local str = builtin.str +local int = builtin.int + ----------------------------------------------------------------------------- local newstring = stringmeta "Hello World" print(newstring) \ No newline at end of file diff --git a/test/python/try.lua b/test/python/try.lua index 05daa1d..56af3e6 100644 --- a/test/python/try.lua +++ b/test/python/try.lua @@ -1,9 +1,14 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local all = builtin.all +local stringmeta = builtin.stringmeta +local str = builtin.str + ----------------------------------------------------------------------------- local success, result = pcall(function() error(stringmeta "Some error") diff --git a/test/python/typehints.lua b/test/python/typehints.lua index 7149363..56fac82 100644 --- a/test/python/typehints.lua +++ b/test/python/typehints.lua @@ -1,9 +1,15 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local sum = builtin.sum +local int = builtin.int +local stringmeta = builtin.stringmeta +local str = builtin.str + ----------------------------------------------------------------------------- local function sum_numbers(a, b) return (a + b) diff --git a/test/python/with.lua b/test/python/with.lua index 10d1295..4bd5f5b 100644 --- a/test/python/with.lua +++ b/test/python/with.lua @@ -1,9 +1,15 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local stringmeta = builtin.stringmeta +local str = builtin.str +local id = builtin.id +local int = builtin.int + ----------------------------------------------------------------------------- do local id = id(stringmeta "Text") diff --git a/test/python/xl.lua b/test/python/xl.lua index 9eb2ec9..bd6eaa5 100644 --- a/test/python/xl.lua +++ b/test/python/xl.lua @@ -1,14 +1,29 @@ ---// Compiled using Roblox.py \-- +--// Compiled using roblox-pyc \-- ------------------------------------ BUILT IN ------------------------------- -local stringmeta, list, dict, staticmethod, classsmethod, class, range, __name__, len, abs, str, int, sum, max, min, reversed, split, round, all, any, ord, char, callable, zip, float, format, hex, id, map, bool, divmod, slice, operator_in, asynchronousfunction, match, anext, ascii, dir, getattr, globals, hasattr, input, isinstance, issubclass, iter, locals, oct, open, ord, pow, eval, exec, filter, frozenset, aiter, bin, complex, delattr, enumerate, breakpoint, bytearray, bytes, compile, help, memoryview, repr, sorted, vars, __import__, classlist, py = unpack(require(game.ReplicatedStorage["Roblox.py"])(script)) +local py, builtin = unpack(require(game.ReplicatedStorage["roblox.pyc"])(script).py) + +local all = builtin.all +local compile = builtin.compile +local range = builtin.range +local int = builtin.int +local stringmeta = builtin.stringmeta +local str = builtin.str +local open = builtin.open +local id = builtin.id +local asynchronousfunction = builtin.asynchronousfunction +local dict = builtin.dict +local class = builtin.class +local staticmethod = builtin.staticmethod +local operator_in = builtin.operator_in + ----------------------------------------------------------------------------- --[[ XL.py (Stands for Extralarge) -A test script for the Roblox.py compiler that uses all of the python 3.13 features. +A test script for the roblox-pyc compiler that uses all of the python 3.13 features. ]] local y = require "x" local SSS = py.services.ServerScriptService