29 lines
601 B
Python
29 lines
601 B
Python
"""
|
|
Utility functions
|
|
"""
|
|
|
|
import ast
|
|
|
|
from .ourlang import OurVisitor, Module
|
|
from .python import Visitor
|
|
|
|
def process(source: str, input_name: str) -> str:
|
|
"""
|
|
Processes the python code into web assembly code
|
|
"""
|
|
res = ast.parse(source, input_name)
|
|
|
|
visitor = Visitor()
|
|
module = visitor.visit_Module(res)
|
|
|
|
return module.generate()
|
|
|
|
def our_process(source: str, input_name: str) -> Module:
|
|
"""
|
|
Processes the python code into web assembly code
|
|
"""
|
|
res = ast.parse(source, input_name)
|
|
|
|
our_visitor = OurVisitor()
|
|
return our_visitor.visit_Module(res)
|