summaryrefslogtreecommitdiffstats
path: root/assembler.py
blob: 1dce7c2f61e9155f2bd9a6f0f1410e2fb2f8d317 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys, zlib

z = zlib.decompressobj()
mainmod = sys.modules[__name__]
while 1:
    name = sys.stdin.readline().strip()
    if name:
        nbytes = int(sys.stdin.readline())
        if verbosity >= 2:
            sys.stderr.write('remote assembling %r (%d bytes)\n'
                             % (name, nbytes))
        content = z.decompress(sys.stdin.read(nbytes))
        exec compile(content, name, "exec")

        # FIXME: this crushes everything into a single module namespace,
        # then makes each of the module names point at this one. Gross.
        assert(name.endswith('.py'))
        modname = name[:-3]
        mainmod.__dict__[modname] = mainmod
    else:
        break

verbose = verbosity
sys.stderr.flush()
sys.stdout.flush()
main()