MCPcopy Create free account
hub / github.com/data61/MP-SPDZ / write_bytes

Method write_bytes

Compiler/program.py:1500–1518  ·  view source on GitHub ↗

Write the program's byte encoding to a file.

(self, filename=None)

Source from the content-addressed store, hash-verified

1498
1499 @unpurged
1500 def write_bytes(self, filename=None):
1501 """Write the program's byte encoding to a file."""
1502 if filename is None:
1503 filename = self.outfile
1504 if not filename.endswith(".bc"):
1505 filename += ".bc"
1506 if "Bytecode" not in filename:
1507 filename = self.program.programs_dir + "/Bytecode/" + filename
1508 print("Writing to", filename)
1509 sys.stdout.flush()
1510 f = open(filename, "wb")
1511 h = hashlib.sha256()
1512 for i in self._get_instructions():
1513 if i is not None:
1514 b = i.get_bytes()
1515 f.write(b)
1516 h.update(b)
1517 f.close()
1518 self.hash = h.digest()
1519
1520 def new_reg(self, reg_type, size=None):
1521 return self.Register(reg_type, self, size=size)

Callers 2

write_bytesMethod · 0.45
finalize_tapeMethod · 0.45

Calls 7

_get_instructionsMethod · 0.95
printFunction · 0.85
closeMethod · 0.80
digestMethod · 0.80
get_bytesMethod · 0.45
writeMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected