diff options
| author | Julgodis <> | 2021-03-31 23:22:32 +0200 |
|---|---|---|
| committer | Julgodis <> | 2021-03-31 23:22:38 +0200 |
| commit | b999714187d934636004d3d93e1ed1da792d6f80 (patch) | |
| tree | b89ce29aafb588cc0d191343c915ae1447d1c7a6 /tools/libdol2asm/data/function/base.py | |
| parent | a868b6ae56e5d586f31a445f47b45f5ac039c74a (diff) | |
.dead section fix
Diffstat (limited to 'tools/libdol2asm/data/function/base.py')
| -rw-r--r-- | tools/libdol2asm/data/function/base.py | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/tools/libdol2asm/data/function/base.py b/tools/libdol2asm/data/function/base.py index cf822e53af..98b0d5b51f 100644 --- a/tools/libdol2asm/data/function/base.py +++ b/tools/libdol2asm/data/function/base.py @@ -25,6 +25,40 @@ class Function(Symbol): asm: bool = False @property + def uses_any_templates(self): + if self.func_name and self.func_name.has_template: + return True + + is_templated = [False] + def callback(tp, depth): + if isinstance(tp, NamedType): + is_templated[0] |= tp.has_template + if is_templated[0]: + return True + + if self.return_type: + self.return_type.traverse(callback, 0) + for arg_type in self.argument_types: + arg_type.traverse(callback, 0) + + return is_templated[0] + + @property + def uses_class_template(self): + return self.func_name and self.func_name.has_template + + @property + def is_static(self): + static = super().is_static + if not static: + return False + + if not self.func_name: + return True + + return not self.uses_any_templates + + @property def label(self): return self.identifier.label @@ -96,13 +130,23 @@ class Function(Symbol): without_template: bool = False, comment_arguments: bool = False, template_args: List[str] = None): - # prints internal references for the function - if False: - if not forward: - refs = self.internal_references(exporter.context, exporter.gst) - await builder.write(f"/* internal references (count {len(refs)})") - for ref in refs: - await builder.write(f"// {ref.addr:08X} {ref.label}") + await builder.write(f"// {self.is_static} {self.uses_any_templates}") + + lines = [] + def callback(tp, depth): + pad = '\t' * depth + template = False + if isinstance(tp, NamedType): + template = tp.has_template + lines.append(f"// {pad} {tp.type()} {template}") + + if self.return_type: + self.return_type.traverse(callback, 0) + for arg_type in self.argument_types: + arg_type.traverse(callback, 0) + + for line in lines: + await builder.write(line) declspec = "extern \"C\" " if not original and self.is_demangled(): |
