phasm/py2wasm/utils.py
Johan B.W. de Vries e7b72b6a6b Started on our own AST
This will help with optimizing code and generating
WASM code
2022-05-28 12:29:24 +02:00

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)