Lichen

Changeset

884:c34258c62630
2019-02-01 Paul Boddie raw files shortlog changelog graph Fixed instance definitions to use the correct size identifiers, not those for classes. This fixes instance size calculations and instance allocation.
generator.py (file)
     1.1 --- a/generator.py	Sat Jan 26 01:04:18 2019 +0100
     1.2 +++ b/generator.py	Fri Feb 01 00:50:48 2019 +0100
     1.3 @@ -3,7 +3,7 @@
     1.4  """
     1.5  Generate C code from object layouts and other deduced information.
     1.6  
     1.7 -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
     1.8 +Copyright (C) 2015, 2016, 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk>
     1.9  
    1.10  This program is free software; you can redistribute it and/or modify it under
    1.11  the terms of the GNU General Public License as published by the Free Software
    1.12 @@ -246,7 +246,7 @@
    1.13                      self.populate_structure(Reference(kind, path), attrs, kind, structure)
    1.14  
    1.15                      if kind == "<class>":
    1.16 -                        self.write_instance_structure(f_decls, path, structure_size)
    1.17 +                        self.write_instance_structure(f_decls, path)
    1.18  
    1.19                      self.write_structure(f_decls, f_defs, path, table_name, structure,
    1.20                          kind == "<class>" and path)
    1.21 @@ -289,7 +289,6 @@
    1.22  
    1.23                  cls = self.function_type
    1.24                  table_name = encode_tablename("<instance>", cls)
    1.25 -                structure_size = encode_size("<instance>", path)
    1.26  
    1.27                  # Set a special callable attribute on the instance.
    1.28  
    1.29 @@ -302,7 +301,7 @@
    1.30                  # Functions with defaults need to declare instance structures.
    1.31  
    1.32                  if self.importer.function_defaults.get(path):
    1.33 -                    self.write_instance_structure(f_decls, path, structure_size)
    1.34 +                    self.write_instance_structure(f_decls, path)
    1.35                      extra_function_instances.append(path)
    1.36  
    1.37                  # Write function declarations.
    1.38 @@ -809,13 +808,14 @@
    1.39  """ % (table_name, min_parameters, max_parameters, structure_size,
    1.40         ",\n        ".join(members))
    1.41  
    1.42 -    def write_instance_structure(self, f_decls, path, structure_size):
    1.43 +    def write_instance_structure(self, f_decls, path):
    1.44  
    1.45          """
    1.46 -        Write a declaration to 'f_decls' for the object having the given 'path'
    1.47 -        and the given 'structure_size'.
    1.48 +        Write a declaration to 'f_decls' for the object having the given 'path'.
    1.49          """
    1.50  
    1.51 +        structure_size = encode_size("<instance>", path)
    1.52 +
    1.53          # Write an instance-specific type definition for instances of classes.
    1.54          # See: templates/types.h
    1.55