Permalink
Browse files

object node now also has a line number for more precise error handling.

  • Loading branch information...
1 parent 11e86f0 commit 18c025ca189372ddebcc364175a0e7e45ab875fd @kjs kjs committed Jun 25, 2012
Showing with 4 additions and 3 deletions.
  1. +1 −1 src/ast.c
  2. +2 −1 src/ast.h
  3. +1 −1 src/gencode.c
View
@@ -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;
}
View
@@ -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. */
@@ -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;
View
@@ -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);
}

0 comments on commit 18c025c

Please sign in to comment.