shithub: scc

Download patch

ref: e1ea759cef4ef3331b24d5fb90f28438a1df3070
parent: 610912d2b4ceea59e7b760d8362f30460ff2b53a
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Jun 29 18:03:19 EDT 2012

Reorder functions in type.c

This new order avoid some calls to non declared functions

--- a/symbol.h
+++ b/symbol.h
@@ -88,7 +88,6 @@
 extern struct type tfloat, tdouble, tldouble, tlong;
 
 
-extern struct type *mktype(register struct type *base, unsigned  char op);
 extern struct type *decl_type(struct type *t);
 extern void pushtype(unsigned char mod);
 extern struct type *btype(struct type *tp, unsigned char tok);
--- a/types.c
+++ b/types.c
@@ -21,6 +21,58 @@
 static unsigned char stack[NR_DECLARATORS];
 static unsigned char *stackp = stack;
 
+
+static struct type *
+mktype(register struct type *base, unsigned  char op)
+{
+	register struct type **ptr, *nt;
+	assert(op == PTR      || op == ARY	  || op == FTN ||
+	       op == VOLATILE || op == RESTRICT   || op == CONST);
+
+	switch (op) {
+	case PTR:
+		ptr = &base->ptr;
+		break;
+	case ARY:
+		ptr = &base->ary;
+		break;
+	case FTN:
+		ptr = &base->ftn;
+		break;
+	case VOLATILE:
+		ptr = &base->vltl;
+		break;
+	case RESTRICT:
+		ptr = &base->rstr;
+		break;
+	case CONST:
+		ptr = &base->cnst;
+		break;
+	}
+	if (*ptr)  return *ptr;
+
+	nt = xcalloc(sizeof(*base), 1);
+	*ptr = nt;
+	nt->op = op;
+	nt->base = base;
+	return nt;
+}
+
+void pushtype(unsigned char mod)
+{
+	if (stackp == stack + NR_DECLARATORS)
+		error("Too much type declarators");
+	*stackp++ = mod;
+}
+
+struct type *decl_type(struct type *t)
+{
+	while (stackp != stack)
+		t = mktype(t, *--stackp);
+	ptype(t);
+	return t;
+}
+
 struct type *btype(struct type *tp, unsigned char tok)
 {
 	switch (tok) {
@@ -76,56 +128,6 @@
 	error("two or more basic types");
 }
 
-void pushtype(unsigned char mod)
-{
-	if (stackp == stack + NR_DECLARATORS)
-		error("Too much type declarators");
-	*stackp++ = mod;
-}
-
-struct type *decl_type(struct type *t)
-{
-	while (stackp != stack)
-		t = mktype(t, *--stackp);
-	ptype(t);
-	return t;
-}
-
-struct type *mktype(register struct type *base, unsigned  char op)
-{
-	register struct type **ptr, *nt;
-	assert(op == PTR      || op == ARY	  || op == FTN ||
-	       op == VOLATILE || op == RESTRICT   || op == CONST);
-
-	switch (op) {
-	case PTR:
-		ptr = &base->ptr;
-		break;
-	case ARY:
-		ptr = &base->ary;
-		break;
-	case FTN:
-		ptr = &base->ftn;
-		break;
-	case VOLATILE:
-		ptr = &base->vltl;
-		break;
-	case RESTRICT:
-		ptr = &base->rstr;
-		break;
-	case CONST:
-		ptr = &base->cnst;
-		break;
-	}
-	if (*ptr)  return *ptr;
-
-	nt = xcalloc(sizeof(*base), 1);
-	*ptr = nt;
-	nt->op = op;
-	nt->base = base;
-	return nt;
-}
-
 void ctype(struct ctype *cp, unsigned char mod)
 {
 	extern unsigned char nested_level;
@@ -234,7 +236,7 @@
 				default:
 					abort();
 				}
-				/* printf("%s %s", sign, type); */
+				printf("%s", type);
 		}
 		}
 	}