micropython

Annotated test.py

66:f5dff4743a77
2008-04-07 Paul Boddie Added support for default parameter value initialisation, tidying up some related invocation issues along the way.
paul@0 1
#!/usr/bin/env python
paul@0 2
paul@0 3
import micropython
paul@0 4
import sys
paul@4 5
paul@62 6
def show(importer, with_builtins=0, optimisations=None):
paul@62 7
    optimisations = optimisations or requested_optimisations
paul@62 8
    for i, x in enumerate(importer.get_image(with_builtins, optimisations)):
paul@22 9
        print i, x
paul@22 10
paul@52 11
def attrs(obj):
paul@52 12
    for name, attr in obj.items():
paul@52 13
        print name, attr
paul@52 14
paul@62 15
if __name__ == "__main__":
paul@63 16
    args = sys.argv[2:]
paul@63 17
    i = micropython.Importer(sys.path, "-v" in args)
paul@62 18
paul@63 19
    if "-omax" in args:
paul@63 20
        requested_optimisations = i.supported_optimisations
paul@63 21
    else:
paul@63 22
        requested_optimisations = []
paul@63 23
        for arg in args:
paul@63 24
            if arg.startswith("-o"):
paul@63 25
                requested_optimisations.append(arg[2:])
paul@63 26
paul@62 27
    try:
paul@62 28
        builtins = i.load_from_file("lib/builtins.py", "__builtins__")
paul@62 29
        if len(sys.argv) < 2:
paul@62 30
            m = i.load("micropython")
paul@62 31
            #m = i.load_from_file("micropython/__init__.py")
paul@62 32
        else:
paul@62 33
            m = i.load_from_file(sys.argv[1])
paul@62 34
    except micropython.ProcessingError, exc:
paul@62 35
        print repr(exc)
paul@37 36
    else:
paul@62 37
        i.vacuum()
paul@62 38
        ot = i.get_object_table()
paul@62 39
        pt = i.get_parameter_table()
paul@0 40
paul@0 41
# vim: tabstop=4 expandtab shiftwidth=4