def writeout(self, func_writer, temp_gen):
     writer = CmdWriter(func_writer, temp_gen)
     for insn in self.insns:
         insn.apply(writer, self._func)
     if self.needs_success_tracker:
         writer.write(SetConst(Var('success_tracker'), 1))
     return writer.get_output()
 def visit_global(self, name, var):
     if var.proxy_set:
         # Special case for assember - it already allocates
         return name, var
     var.set_proxy(GlobalScoreVariable(var.type, Var('g%d_%s' % (
         self.offset, name))))
     self.offset += 1
     return name, var
Exemple #3
0
 def next(self):
     if not self.temps:
         name = 'temp_%d' % self.counter
         self.writer.write_objective(name, None)
         tmp = Var(name, self.writer.namespace)
         self.counter += 1
     else:
         tmp = self.temps.pop()
     self.in_use.add(tmp)
     return tmp
 def visit_local_var(self, name, var):
     if self.use_scores and var.type.isnumeric:
         var.set_proxy(LocalScoreVariable(var.type,
                                          Var('reg_%d' % self.reg_offset)))
         if self.reg_offset >= 4:
             self.use_scores = False
         self.reg_offset += 1
     else:
         var.set_proxy(LocalStackVariable(var.type, self.nbt_offset))
         self.nbt_offset += 1
     return name, var
 def visit_global(self, name, var):
     if var.proxy_set:
         # Special case for assember - it already allocates
         return name, var
     if var.type.isnumeric:
         real_var = GlobalScoreVariable(
             var.type, Var('g%d_%s' % (self.score_offset, name)))
         self.score_offset += 1
     else:
         real_var = GlobalNbtVariable(var.type, self.nbt_offset)
         self.nbt_offset += 1
     var.set_proxy(real_var)
     return name, var