def run_filename(filename, options): if options['interactive']: gobstones = lang.Gobstones( lang.GobstonesOptions(options['lint'], options['liveness'], options['typecheck'], options['jit']), ConsoleInteractiveAPI(options)) else: gobstones = lang.Gobstones( lang.GobstonesOptions(options['lint'], options['liveness'], options['typecheck'], options['jit'])) if filename.lower().endswith('.gbo'): object_file = open(filename) compiled_program = lang.gbs_vm_serializer.load(object_file) object_file.close() gbs_run = gobstones.run_object_code(compiled_program, get_initial_board(options)) elif options['asm']: gbs_run = gobstones.compile(filename, open(filename).read()) elif lang.board.formats.is_board_filename(filename): gbs_run = lang.GobstonesRun() gbs_run.final_board = lang.gbs_board.load_board_from(filename) else: gbs_run = gobstones.run(filename, open(filename).read(), get_initial_board(options)) return gbs_run
def start(self, filename, program_text, initial_board_string, run_mode): board = tools.board_format.from_string(initial_board_string) if run_mode == XGobstonesWorker.RunMode.ONLY_CHECK: options = lang.GobstonesOptions() else: options = lang.GobstonesOptions() self.gobstones = lang.Gobstones(options, self.api) try: if run_mode == XGobstonesWorker.RunMode.FULL: self.success(self.gobstones.run(filename, program_text, board)) else: # Parse gobstones script self.gobstones.api.log(i18n.i18n('Parsing.')) tree = self.gobstones.parse(program_text, filename) assert tree # Explode macros self.gobstones.api.log(i18n.i18n('Exploding program macros.')) self.gobstones.explode_macros(tree) # Check semantics, liveness and types self.gobstones.check(tree) self.success() except Exception as exception: self.failure(exception)
def run(self): api = GUIExecutionAPI(self.communicator) options = lang.GobstonesOptions("lax", False, True) gobstones = lang.Gobstones(options, api) message = self.communicator.receive() assert message.header in ['START', 'EXIT'] if message.header == 'EXIT': return filename, current_text, board_repr = message.body try: self.success(gobstones.run(filename, current_text, tools.board_format.from_string(board_repr))) except SourceException as exception: self.failure(exception)