Skip to content

Commit

Permalink
AST is generated correctly, apparently, as code is spit out for metho…
Browse files Browse the repository at this point in the history
…ds. Need to do a lot of mangling though. WIP!
  • Loading branch information
kjs committed Jun 11, 2012
1 parent 8f09ce6 commit a1e78f6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/gencode.c
Expand Up @@ -2058,6 +2058,19 @@ gencode_chunk(M1_compiler *comp, m1_chunk *c) {
gencode_chunk_return(comp, c);
}


static void
gencode_pmc(M1_compiler *comp, m1_pmc *pmc) {
/* XXX generate code for initialization, setting up vtables etc.*/

/* generate code for the methods. */
m1_chunk *methoditer = pmc->methods;
while (methoditer != NULL) {
gencode_chunk(comp, methoditer);
methoditer = methoditer->next;
}
}

/*
Top-level function to drive the code generation phase.
Expand All @@ -2067,7 +2080,7 @@ Iterate over the list of chunks, and generate code for each.
void
gencode(M1_compiler *comp, m1_chunk *ast) {
m1_chunk *iter = ast;

m1_decl *decliter;

fprintf(OUT, ".version 0\n");

Expand All @@ -2079,6 +2092,17 @@ gencode(M1_compiler *comp, m1_chunk *ast) {
gencode_chunk(comp, iter);
iter = iter->next;
}

/* after the normal chunks, generate code for PMC methods. */
decliter = comp->declarations;
while (decliter != NULL) {
/* find the PMC definitions. */
if (decliter->decltype == DECL_PMC) {
m1_pmc *pmc = decliter->d.p;
gencode_pmc(comp, pmc);
}
decliter = decliter->next;
}
}


Expand Down
3 changes: 3 additions & 0 deletions t/pmc.m1
@@ -1,7 +1,10 @@
pmc integer {

int value;

vtable method int init() {

}
}

int main() {
Expand Down

0 comments on commit a1e78f6

Please sign in to comment.