summaryrefslogtreecommitdiff
path: root/parse/specialize.c
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 /parse/specialize.c
parent16a7bb8f8cc86b22ce157e0944f66f60a556590f (diff)
downloadmc-02201160614e5f25a7a73d86ed26a1f90fa4f5bb.tar.gz
Add support for `__fini__` functions.
Diffstat (limited to 'parse/specialize.c')
-rw-r--r--parse/specialize.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/parse/specialize.c b/parse/specialize.c
index becf273..a6f2d27 100644
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -639,24 +639,24 @@ callinit(Node *block, Node *init, Type *tyvoid, Type *tyvoidfn)
}
void
-geninit(void)
+genautocall(Node **call, size_t ncall, Node *local, char *fn)
{
Node *name, *decl, *func, *block, *init;
Type *tyvoid, *tyvoidfn;
size_t i;
- name = mkname(Zloc, "__init__");
+ name = mkname(Zloc, fn);
decl = mkdecl(Zloc, name, mktyvar(Zloc));
block = mkblock(Zloc, mkstab(0));
tyvoid = mktype(Zloc, Tyvoid);
tyvoidfn = mktyfunc(Zloc, NULL, 0, tyvoid);
- for (i = 0; i < file->file.ninit; i++) {
- init = initdecl(file, file->file.init[i], tyvoidfn);
+ for (i = 0; i < ncall; i++) {
+ init = initdecl(file, call[i], tyvoidfn);
callinit(block, init, tyvoid, tyvoidfn);
}
- if (file->file.localinit)
- callinit(block, file->file.localinit, tyvoid, tyvoidfn);
+ if (local)
+ callinit(block, local, tyvoid, tyvoidfn);
func = mkfunc(Zloc, NULL, 0, mktype(Zloc, Tyvoid), block);
init = mkexpr(Zloc, Olit, func, NULL);