1.1 --- a/micropython/__init__.py Sun May 31 18:44:40 2009 +0200
1.2 +++ b/micropython/__init__.py Mon Jun 01 02:41:57 2009 +0200
1.3 @@ -259,10 +259,15 @@
1.4 if not with_builtins and item.module.name == "__builtins__":
1.5 item.code_location = item.full_name()
1.6
1.7 - # Skip any defaults.
1.8 + # Skip any defaults for named functions.
1.9 +
1.10 + elif item.name is not None:
1.11 + item.code_location = pos + len(item.defaults)
1.12 +
1.13 + # Skip any defaults for lambda functions.
1.14
1.15 else:
1.16 - item.code_location = pos + len(item.defaults)
1.17 + item.code_location = pos
1.18
1.19 current_function = item
1.20
1.21 @@ -307,7 +312,8 @@
1.22 # Check the code location only where the code has been generated.
1.23
1.24 assert (not with_builtins and item.module.name == "__builtins__") or \
1.25 - item.code_location == len(self.raw_code) + len(item.defaults)
1.26 + item.name is not None and item.code_location == len(self.raw_code) + len(item.defaults) or \
1.27 + item.name is None and item.code_location == len(self.raw_code)
1.28
1.29 elif isinstance(item, micropython.data.Module):
1.30 assert item.location == len(self.raw_code)
1.31 @@ -743,23 +749,4 @@
1.32 continue
1.33 module.set_module(submodule, self.add_module(module.name + "." + submodule))
1.34
1.35 -# Convenience functions.
1.36 -
1.37 -def program(filename, path, requested_optimisations, verbose=0):
1.38 -
1.39 - """
1.40 - Return the program object for the program specified by the given 'filename',
1.41 - module search 'path' and 'requested_optimisations'.
1.42 - """
1.43 -
1.44 - i = micropython.Importer(path, verbose, requested_optimisations)
1.45 - p = micropython.Program(i, requested_optimisations)
1.46 -
1.47 - i.load_from_file("lib/builtins.py", "__builtins__")
1.48 -
1.49 - if filename is not None:
1.50 - i.load_from_file(filename)
1.51 -
1.52 - return p
1.53 -
1.54 # vim: tabstop=4 expandtab shiftwidth=4