Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compiler fully compatible with py3 while retaining py2 support #34

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions Compiler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
import compilerLib, program, instructions, types, library, floatingpoint, mpc_math
import Compiler.compilerLib
import Compiler.program
import Compiler.instructions
import Compiler.types
import Compiler.library
import Compiler.floatingpoint
import Compiler.mpc_math
import inspect
from config import *
from compilerLib import run
from Compiler.config import *
from Compiler.compilerLib import run


# add all instructions to the program VARS dictionary
compilerLib.VARS = {}
instr_classes = [t[1] for t in inspect.getmembers(instructions, inspect.isclass)]
instr_classes = [t[1] for t in inspect.getmembers(Compiler.instructions, inspect.isclass)]

instr_classes += [t[1] for t in inspect.getmembers(types, inspect.isclass)\
if t[1].__module__ == types.__name__]
instr_classes += [t[1] for t in inspect.getmembers(Compiler.types, inspect.isclass)\
if t[1].__module__ == Compiler.types.__name__]

#instr_classes += [t[1] for t in inspect.getmembers(fixedpoint, inspect.isclass)\
# if t[1].__module__ == fixedpoint.__name__]
#instr_classes += [t[1] for t in inspect.getmembers(fixedpoint, inspect.isfunction)\
# if t[1].__module__ == fixedpoint.__name__]

instr_classes += [t[1] for t in inspect.getmembers(library, inspect.isfunction)\
if t[1].__module__ == library.__name__]
instr_classes += [t[1] for t in inspect.getmembers(Compiler.library, inspect.isfunction)\
if t[1].__module__ == Compiler.library.__name__]

for op in instr_classes:
compilerLib.VARS[op.__name__] = op
Compiler.compilerLib.VARS[op.__name__] = op

# add open and input separately due to name conflict
compilerLib.VARS['open'] = instructions.asm_open
compilerLib.VARS['vopen'] = instructions.vasm_open
Compiler.compilerLib.VARS['open'] = Compiler.instructions.asm_open
Compiler.compilerLib.VARS['vopen'] = Compiler.instructions.vasm_open

compilerLib.VARS['comparison'] = comparison
compilerLib.VARS['mpc_math'] = mpc_math
compilerLib.VARS['floatingpoint'] = floatingpoint
Compiler.compilerLib.VARS['comparison'] = Compiler.comparison
Compiler.compilerLib.VARS['mpc_math'] = Compiler.mpc_math
Compiler.compilerLib.VARS['floatingpoint'] = Compiler.floatingpoint
Loading