- report = ''.join(map(str, reg))
- return hex(int('0b%s' % report, 2))
-
-
-gsc = GardenSnakeCompiler()
-class GPR(dict):
- def __init__(self, sd, regfile):
- dict.__init__(self)
- self.sd = sd
- self.regfile = regfile
- for i in range(32):
- self[i] = [0] * 64
-
- def set_form(self, form):
- self.form = form
-
- def ___getitem__(self, attr):
- print ("GPR getitem", attr)
- getform = self.sd.sigforms[self.form]
- rnum = getattr(getform, attr)
- print ("GPR get", rnum, rnum, dir(rnum))
- l = list(rnum)
- print (l[0]._as_const())
- #for x in rnum:
- #print (x, x.value, dir(x))
- #print (x.value, dir(x.value))
- print (list(rnum))
- return self.regfile[rnum]
-
-
-gsc.regfile = {}
-for i in range(32):
- gsc.regfile[i] = 0
-gsc.gpr = GPR(gsc.parser.sd, gsc.regfile)
-
-_compile = gsc.compile
+ return hex(reg.value)
+
+
+def convert_to_python(pcode, form, incl_carry):
+
+ print("form", form)
+ gsc = GardenSnakeCompiler(form=form, incl_carry=incl_carry)
+
+ tree = gsc.compile(pcode, mode="exec", filename="string")
+ tree = ast.fix_missing_locations(tree)
+ regsused = {'read_regs': gsc.parser.read_regs,
+ 'write_regs': gsc.parser.write_regs,
+ 'uninit_regs': gsc.parser.uninit_regs,
+ 'special_regs': gsc.parser.special_regs,
+ 'op_fields': gsc.parser.op_fields}
+ return astor.to_source(tree), regsused
+