Skip to content

Commit

Permalink
Remove the lazy common.h for better partial compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
jonpovey committed May 10, 2012
1 parent d2e91c2 commit 016d405
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 41 deletions.
19 changes: 0 additions & 19 deletions src/common.h

This file was deleted.

6 changes: 5 additions & 1 deletion src/das.c
Expand Up @@ -10,7 +10,11 @@
#include <stdlib.h>
#include <string.h>

#include "common.h"
#include "das.h"
#include "dasdefs.h"
#include "output.h"
#include "statement.h"
#include "symbol.h"

int yyparse(void);
extern FILE *yyin;
Expand Down
12 changes: 0 additions & 12 deletions src/das.h
Expand Up @@ -8,8 +8,6 @@
#define VERSION "0.13"
#define VERSTRING "BlueDAS DCPU-16 Assembler, version " VERSION

extern int das_error;

extern struct options {
int asm_print_pc;
int asm_main_col;
Expand All @@ -21,14 +19,4 @@ extern struct options {
int big_endian;
} options;

/* fixme: better errors and warnings, with line numbers and such */
#define error(fmt, args...) do { \
fprintf(stderr, "error: " fmt "\n", ##args); \
das_error = 1; \
} while (0)

#define warn(fmt, args...) do { \
fprintf(stderr, "warning: " fmt "\n", ##args); \
} while (0)

#endif // DAS_H
2 changes: 1 addition & 1 deletion src/das.l
Expand Up @@ -6,7 +6,7 @@
void yyerror(char *);
#include "y.tab.h"
#include "dasdefs.h"
#include "das.h"
#include "output.h"
static int get_constant(void);
%}

Expand Down
7 changes: 6 additions & 1 deletion src/das.y
Expand Up @@ -5,7 +5,12 @@
*/
#include <stdio.h>

#include "common.h"
#include "expression.h"
#include "dasdefs.h"
#include "dat.h"
#include "instruction.h"
#include "output.h"
#include "symbol.h"

int yylex();

Expand Down
3 changes: 2 additions & 1 deletion src/dasdefs.c
Expand Up @@ -8,7 +8,8 @@
#include <stdlib.h>
#include <string.h>

#include "common.h"
#include "dasdefs.h"
#include "output.h"

/*
* macro magic. use GCC designated initialisers to build a sparse array
Expand Down
10 changes: 9 additions & 1 deletion src/dat.c
@@ -1,4 +1,12 @@
#include "common.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>

#include "das.h"
#include "dasdefs.h"
#include "expression.h"
#include "output.h"
#include "statement.h"

enum dat_types {
DATTYPE_STRING,
Expand Down
7 changes: 6 additions & 1 deletion src/expression.c
Expand Up @@ -5,7 +5,12 @@
* Released under the GPL v2
*
*/
#include "common.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>

#include "symbol.h"
#include "output.h"
#include "y.tab.h"

enum expr_type {
Expand Down
10 changes: 9 additions & 1 deletion src/instruction.c
Expand Up @@ -8,7 +8,15 @@
#undef DEBUG
#endif

#include "common.h"
#include <assert.h>
#include <error.h>
#include <stdio.h>
#include <stdlib.h>

#include "dasdefs.h"
#include "instruction.h"
#include "output.h"
#include "statement.h"

struct operand {
enum opstyle style;
Expand Down
14 changes: 14 additions & 0 deletions src/output.h
@@ -1,6 +1,10 @@
#ifndef OUTPUT_H
#define OUTPUT_H

#include <stdio.h>

extern int das_error;

/* wrap fprintf as print() so extra things may be added if wanted */
#define print(to, fmt, args...) fprintf(to, fmt, ##args)

Expand All @@ -10,6 +14,16 @@
printf(fmt, ##args); \
} while (0)

/* fixme: better errors and warnings, with line numbers and such */
#define error(fmt, args...) do { \
fprintf(stderr, "error: " fmt "\n", ##args); \
das_error = 1; \
} while (0)

#define warn(fmt, args...) do { \
fprintf(stderr, "warning: " fmt "\n", ##args); \
} while (0)

/* report internal bugs */
#define BUG_ON(x) ({ int r = !!(x); \
if (r) { \
Expand Down
9 changes: 8 additions & 1 deletion src/statement.c
Expand Up @@ -4,7 +4,14 @@
* Copyright 2012 Jon Povey <jon@leetfighter.com>
* Released under the GPL v2
*/
#include "common.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>

#include "das.h"
#include "list.h"
#include "output.h"
#include "statement.h"

#define MAX_BINARY_WORDS (1 << 16) /* 16-bit (word) address space */
#define MAX_BINARY_BYTES (MAX_BINARY_WORDS * 2)
Expand Down
2 changes: 2 additions & 0 deletions src/statement.h
Expand Up @@ -8,6 +8,8 @@
*/
#include <stdio.h>

#include "dasdefs.h"

enum stmt_type {
STMT_NONE,
STMT_INSTRUCTION,
Expand Down
10 changes: 9 additions & 1 deletion src/symbol.c
Expand Up @@ -4,7 +4,15 @@
* Copyright 2012 Jon Povey <jon@leetfighter.com>
* Released under the GPL v2
*/
#include "common.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>

#include "das.h"
#include "expression.h"
#include "list.h"
#include "output.h"
#include "statement.h"

enum sym_flags {
SYM_LABEL = 0x1, /* definition label found */
Expand Down
1 change: 0 additions & 1 deletion src/symbol.h
Expand Up @@ -11,7 +11,6 @@ struct symbol;

#include "expression.h"
#include "instruction.h"
#include "list.h"

/* Parse */
struct symbol* symbol_parse(char *name);
Expand Down

0 comments on commit 016d405

Please sign in to comment.