Skip to content

Commit

Permalink
object node now also has a line number for more precise error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
kjs committed Jun 25, 2012
1 parent 11e86f0 commit 18c025c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ m1_object *
object(M1_compiler *comp, m1_object_type type) {
m1_object *obj = (m1_object *)m1_malloc(sizeof(m1_object));
obj->type = type;

obj->line = yyget_lineno(comp->yyscanner);
assert(comp != NULL);
return obj;
}
Expand Down
3 changes: 2 additions & 1 deletion src/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ typedef enum m1_object_type {
*/
typedef struct m1_object {
unsigned line;

union {
char *name; /* for name, field or deref access, in a.b.c for instance. */
Expand All @@ -220,7 +221,7 @@ typedef struct m1_object {

enum m1_object_type type; /* selector for union */
struct m1_symbol *sym; /* pointer to this object's declaration. */

struct m1_object *parent; /* pointer to its parent (in a.b.c, a is b's parent) */

} m1_object;
Expand Down
2 changes: 1 addition & 1 deletion src/gencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ OBJECT_LINK------> L3
initialized yet. Emit a warning.
*/
if (!is_target) {
warning(comp, obj->sym->line, "use of uninitialized variable '%s'\n",
warning(comp, obj->line, "use of uninitialized variable '%s'\n",
obj->sym->name);
}

Expand Down

0 comments on commit 18c025c

Please sign in to comment.