1.1 --- a/test.py Mon Mar 24 23:53:18 2008 +0100
1.2 +++ b/test.py Mon Mar 31 00:54:03 2008 +0200
1.3 @@ -3,27 +3,34 @@
1.4 import micropython
1.5 import sys
1.6
1.7 -def show(importer, with_builtins=0):
1.8 - for i, x in enumerate(importer.get_image(with_builtins=with_builtins)):
1.9 +def show(importer, with_builtins=0, optimisations=None):
1.10 + optimisations = optimisations or requested_optimisations
1.11 + for i, x in enumerate(importer.get_image(with_builtins, optimisations)):
1.12 print i, x
1.13
1.14 def attrs(obj):
1.15 for name, attr in obj.items():
1.16 print name, attr
1.17
1.18 -i = micropython.Importer(sys.path, "-v" in sys.argv)
1.19 -try:
1.20 - builtins = i.load_from_file("lib/builtins.py", "__builtins__")
1.21 - if len(sys.argv) < 2:
1.22 - m = i.load("micropython")
1.23 - #m = i.load_from_file("micropython/__init__.py")
1.24 +if __name__ == "__main__":
1.25 + requested_optimisations = []
1.26 + for arg in sys.argv[2:]:
1.27 + if arg.startswith("-o"):
1.28 + requested_optimisations.append(arg[2:])
1.29 +
1.30 + i = micropython.Importer(sys.path, "-v" in sys.argv)
1.31 + try:
1.32 + builtins = i.load_from_file("lib/builtins.py", "__builtins__")
1.33 + if len(sys.argv) < 2:
1.34 + m = i.load("micropython")
1.35 + #m = i.load_from_file("micropython/__init__.py")
1.36 + else:
1.37 + m = i.load_from_file(sys.argv[1])
1.38 + except micropython.ProcessingError, exc:
1.39 + print repr(exc)
1.40 else:
1.41 - m = i.load_from_file(sys.argv[1])
1.42 -except micropython.ProcessingError, exc:
1.43 - print repr(exc)
1.44 -else:
1.45 - i.vacuum()
1.46 - ot = i.get_object_table()
1.47 - pt = i.get_parameter_table()
1.48 + i.vacuum()
1.49 + ot = i.get_object_table()
1.50 + pt = i.get_parameter_table()
1.51
1.52 # vim: tabstop=4 expandtab shiftwidth=4