summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2019-02-26 13:03:14 -0800
committerOri Bernstein <ori@markovcorp.com>2019-02-26 13:03:14 -0800
commit02201160614e5f25a7a73d86ed26a1f90fa4f5bb (patch)
treece958c6982673794612cf2ea91ab8b353bf4c243 /6
parent16a7bb8f8cc86b22ce157e0944f66f60a556590f (diff)
downloadmc-02201160614e5f25a7a73d86ed26a1f90fa4f5bb.tar.gz
Add support for `__fini__` functions.
Diffstat (limited to '6')
-rw-r--r--6/main.c8
-rw-r--r--6/simp.c2
2 files changed, 7 insertions, 3 deletions
diff --git a/6/main.c b/6/main.c
index 5e3d6da..c980887 100644
--- a/6/main.c
+++ b/6/main.c
@@ -293,8 +293,12 @@ main(int argc, char **argv)
if (debugopt['T'])
dump(file, stdout);
loaduses();
- if (hasmain(file))
- geninit();
+ if (hasmain(file)) {
+ genautocall(file->file.init, file->file.ninit,
+ file->file.localinit, "__init__");
+ genautocall(file->file.fini, file->file.nfini,
+ file->file.localfini, "__fini__");
+ }
infer();
tagexports(0);
/* after all type inference */
diff --git a/6/simp.c b/6/simp.c
index 415f49d..cff77ba 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -1403,7 +1403,7 @@ isexport(Node *dcl)
n = dcl->decl.name;
if (!n->name.ns && streq(n->name.name, "main"))
return 1;
- if (streq(n->name.name, "__init__"))
+ if (streq(n->name.name, "__init__") || streq(n->name.name, "__fini__"))
return 1;
return 0;
}