Skip to content

Commit

Permalink
py3 interface
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Apr 7, 2024
1 parent e796751 commit ca81c6e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions aheui/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import os
import aheui.const as c
from aheui._compat import unichr, _unicode
from aheui._compat import unichr, _unicode, PY3


OP_NAMES = [None, None, u'DIV', u'ADD', u'MUL', u'MOD', u'POP', u'PUSH', u'DUP', u'SEL', u'MOV', None, u'CMP', None, u'BRZ', None, u'SUB', u'SWAP', u'HALT', u'POPNUM', u'POPCHAR', u'PUSHNUM', u'PUSHCHAR', u'BRPOP2', u'BRPOP1', u'JMP']
Expand Down Expand Up @@ -815,10 +815,15 @@ def write_bytecode(self):
assert len(p) == 4
codes.append(p)
codes.append('\xff\xff\xff\xff')
return ''.join(codes)
code = ''.join(codes)
if PY3:
code = code.encode('utf-8')
return code

def read_bytecode(self, text):
"""Read bytecodes from data text."""
if PY3:
text = text.decode('utf-8')
self.debug = None
self.lines = []
self.label_map = {}
Expand Down

0 comments on commit ca81c6e

Please sign in to comment.