strongly connected components
[ccc.git] / type.c
diff --git a/type.c b/type.c
index 3325de8..0cf22e1 100644 (file)
--- a/type.c
+++ b/type.c
@@ -1,3 +1,8 @@
+#include <stdlib.h>
+#include <string.h>
+
+#include "list.h"
+#include "scc.h"
 #include "ast.h"
 
 void type_error(const char *msg, ...)
@@ -37,7 +42,7 @@ struct vardecl *type_vardecl(struct vardecl *vardecl)
 struct decl *type_decl(struct decl *decl)
 {
        switch (decl->type) {
-       case dcomponent:
+       case dcomp:
                fprintf(stderr, "type_decl:component unsupported\n");
                break;
        case dfundecl:
@@ -52,6 +57,8 @@ struct decl *type_decl(struct decl *decl)
 
 struct ast *type(struct ast *ast)
 {
+       ast = ast_scc(ast);
+
        for (int i = 0; i<ast->ndecls; i++) {
                if (ast->decls[i]->type == dvardecl) {
                        //Check globals
@@ -61,4 +68,3 @@ struct ast *type(struct ast *ast)
        }
        return ast;
 }
-