shithub: scc

Download patch

ref: a95148537302c8fe01bef6538943d4313068f988
parent: 65ab399458b19e47f7c8ef723eb8710159bb6e23
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Apr 17 09:48:20 EDT 2014

Add out of function expressions

This funtcionality is needed for boxer.

--- a/cc.h
+++ b/cc.h
@@ -222,4 +222,7 @@
 #define ISNODEBIN(n) ((n)->code == emitbin)
 #define ISNODELOG(n) (ISNODEBIN(n) && (n)->u.op & 0x40)
 
+extern Node *expr(void);
+extern void extdecl(void), decl(void), compound(void);
+
 #endif
--- a/decl.c
+++ b/decl.c
@@ -470,7 +470,6 @@
 	int8_t sclass;
 	Symbol *sym;
 	char *err;
-	extern void compound(void);
 
 	forbid_eof = 0; /* TODO: Fix when find EOF */
 
@@ -481,6 +480,10 @@
 			goto bad_storage;
 	case ';':
 		break;
+	case '@':
+		next();
+		emitexp(expr());
+		return;
 	default:
 		goto dcl_expected;
 	}
--- a/main.c
+++ b/main.c
@@ -4,7 +4,7 @@
 
 #include "cc.h"
 
-extern void extdecl(void), init_keywords(void),
+extern void init_keywords(void),
 	open_file(const char *file),  init_expr(void);
 
 struct user_opt options;
--- a/stmt.c
+++ b/stmt.c
@@ -6,8 +6,6 @@
 
 Symbol *curfun;
 
-extern void decl(void);
-extern Node *expr(void);
 extern Node *convert(Node *np, Type *tp1, char iscast);
 
 static void