Exemple #1
0
def vm_compiler_runner(code, ostream):
    codeobject = compile_code(code)

    # Run the code through (de+)serialization to test how that works
    # too
    #
    ser = Serializer().serialize_bytecode(codeobject)
    codeobject = Deserializer().deserialize_bytecode(ser)
    vm = BobVM(output_stream=ostream)
    vm.run(codeobject)
def vm_compiler_runner(code, ostream):
    codeobject = compile_code(code)

    # Run the code through (de+)serialization to test how that works 
    # too
    #
    ser = Serializer().serialize_bytecode(codeobject)
    codeobject = Deserializer().deserialize_bytecode(ser)
    vm = BobVM(output_stream=ostream)
    vm.run(codeobject)
Exemple #3
0
    def barevm_runner(code, ostream):
        codeobject = compile_code(code)
        serialized = Serializer().serialize_bytecode(codeobject)

        # Get a temporary filename and write the serialized codeobject
        # into it
        fileobj, filename = tempfile.mkstemp()
        os.write(fileobj, serialized)
        os.close(fileobj)

        vm_proc = Popen([barevm_path, filename], stdout=PIPE)
        vm_output = vm_proc.stdout.read()

        ostream.write(bytes2str(vm_output))
        os.remove(filename)
Exemple #4
0
def compile_file(filename):
    """ Given the name of a .scm file, compile it with the Bob compiler
        to produce a corresponding .bobc file.
    """
    code_str = open(filename).read()
    codeobject = compile_code(code_str)
    serialized = Serializer().serialize_bytecode(codeobject)

    # Create the output file
    filename_without_ext = os.path.splitext(filename)[0]
    out_filename = filename_without_ext + '.bobc'

    with open(out_filename, 'wb') as out_file:
        out_file.write(serialized)
        print("Output file created: %s" % out_filename)
Exemple #5
0
    def barevm_runner(code, ostream):
        codeobject = compile_code(code)
        serialized = Serializer().serialize_bytecode(codeobject)

        # Get a temporary filename and write the serialized codeobject
        # into it
        fileobj, filename = tempfile.mkstemp()
        os.write(fileobj, serialized)
        os.close(fileobj)

        vm_proc = Popen([barevm_path, filename], stdout=PIPE)
        vm_output = vm_proc.stdout.read()

        ostream.write(bytes2str(vm_output))
        os.remove(filename)
Exemple #6
0
def compile_file(filename=None, out_filename=None, disassemble=False):
    """ Given the name of a .scm file, compile it with the Bob compiler
        to produce a corresponding .bobc file.
    """
    if not filename:
        filename = sys.argv[1]
    code_str = open(filename).read()
    codeobject = compile_code(code_str)
    if disassemble:
        print(codeobject)
        return

    serialized = Serializer().serialize_bytecode(codeobject)

    # Create the output file
    if not out_filename:
        filename_without_ext = os.path.splitext(filename)[0]
        out_filename = filename_without_ext + '.bobc'

    with open(out_filename, 'wb') as out_file:
        out_file.write(serialized)
        print("Output file created: %s" % out_filename)
Exemple #7
0
def compile_file(filename=None, out_filename=None, disassemble=False):
    """ Given the name of a .scm file, compile it with the Bob compiler
        to produce a corresponding .bobc file.
    """
    if not filename:
        filename = sys.argv[1]
    code_str = open(filename).read()
    codeobject = compile_code(code_str)
    if disassemble:
        print(codeobject)
        return

    serialized = Serializer().serialize_bytecode(codeobject)

    # Create the output file
    if not out_filename:
        filename_without_ext = os.path.splitext(filename)[0]
        out_filename = filename_without_ext + '.bobc'

    with open(out_filename, 'wb') as out_file:
        out_file.write(serialized)
        print("Output file created: %s" % out_filename)
Exemple #8
0
def vm_compiler_runner(code, ostream):
    codeobject = compile_code(code)
    vm = BobVM(output_stream=ostream)
    vm.run(codeobject)