comparison lwasm/lwasm.h @ 344:0215a0fbf61b

Added assembly error system and additional checks for symbol syntax
author lost@starbug
date Thu, 25 Mar 2010 22:06:50 -0600
parents 7b4123dce741
children 7416c3f9c321
comparison
equal deleted inserted replaced
343:b4157778d354 344:0215a0fbf61b
61 PRAGMA_UNDEFEXTERN = 0x0004, // undefined symbols are considered to be external 61 PRAGMA_UNDEFEXTERN = 0x0004, // undefined symbols are considered to be external
62 PRAGMA_CESCAPES = 0x0008, // allow C style escapes in fcc, fcs, fcn, etc. 62 PRAGMA_CESCAPES = 0x0008, // allow C style escapes in fcc, fcs, fcn, etc.
63 PRAGMA_IMPORTUNDEFEXPORT = 0x0010 // imports symbol if undefined upon export 63 PRAGMA_IMPORTUNDEFEXPORT = 0x0010 // imports symbol if undefined upon export
64 }; 64 };
65 65
66 typedef struct lwasm_error_s lwasm_error_t;
67 struct lwasm_error_s
68 {
69 char *mess; // actual error message
70 lwasm_error_t *next; // ptr to next error
71 };
72
66 typedef struct line_s line_t; 73 typedef struct line_s line_t;
67 struct line_s 74 struct line_s
68 { 75 {
69 lw_expr_t addr; // assembly address of the line 76 lw_expr_t addr; // assembly address of the line
70 int len; // the "size" this line occupies (address space wise) (-1 if unknown) 77 int len; // the "size" this line occupies (address space wise) (-1 if unknown)
71 int insn; // number of insn in insn table 78 int insn; // number of insn in insn table
72 int symset; // set if the line symbol was consumed by the instruction 79 int symset; // set if the line symbol was consumed by the instruction
73 char *sym; // symbol, if any, on the line 80 char *sym; // symbol, if any, on the line
74 line_t *prev; 81 lwasm_error_t *err; // list of errors
75 line_t *next; 82 line_t *prev; // previous line
83 line_t *next; // next line
76 }; 84 };
77 85
78 enum 86 enum
79 { 87 {
80 symbol_flag_set = 1, // symbol was used with "set" 88 symbol_flag_set = 1, // symbol was used with "set"
101 int output_format; // output format 109 int output_format; // output format
102 int target; // assembly target 110 int target; // assembly target
103 int debug_level; // level of debugging requested 111 int debug_level; // level of debugging requested
104 int flags; // assembly flags 112 int flags; // assembly flags
105 int pragmas; // pragmas currently in effect 113 int pragmas; // pragmas currently in effect
114 int errorcount; // number of errors encountered
106 115
107 line_t *line_head; // start of lines list 116 line_t *line_head; // start of lines list
108 line_t *line_tail; // tail of lines list 117 line_t *line_tail; // tail of lines list
109 118
110 int context; // the current "context" 119 int context; // the current "context"
119 lw_stack_t file_dir; // stack of the "current file" dir 128 lw_stack_t file_dir; // stack of the "current file" dir
120 } asmstate_t; 129 } asmstate_t;
121 130
122 #ifndef ___symbol_c_seen___ 131 #ifndef ___symbol_c_seen___
123 132
124 extern struct symtabe *register_symbol(asmstate_t *as, char *sym, lw_expr_t value, int flags); 133 extern struct symtabe *register_symbol(asmstate_t *as, line_t *cl, char *sym, lw_expr_t value, int flags);
125 extern struct symtabe *lookup_symbol(asmstate_t *as, char *sym, int context, int version); 134 extern struct symtabe *lookup_symbol(asmstate_t *as, line_t *cl, char *sym, int context, int version);
126 135
127 #endif 136 #endif
128 137
138 #ifndef ___lwasm_c_seen___
139
140 extern void lwasm_register_error(asmstate_t *as, line_t *cl, const char *msg, ...);
141
142 #endif
143
144
129 #endif /* ___lwasm_h_seen___ */ 145 #endif /* ___lwasm_h_seen___ */