Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define MAX_TOKEN_LEN 256
#define MAX_ID_LEN 64
#define MAX_LINE_LEN 256
#define MAX_VAR_LEN 32
#define MAX_VAR_LEN 128
#define MAX_TYPE_LEN 32
#define MAX_PARAMS 8
#define MAX_LOCALS 1600
Expand Down Expand Up @@ -410,6 +410,11 @@ struct var {
* the variable is based on the top of the local stack.
*/
bool ofs_based_on_stack_top;

/* True when this variable was synthesized to hold a compound literal
* (e.g., array or struct literal temporaries).
*/
bool is_compound_literal;
};

typedef struct {
Expand Down
15 changes: 10 additions & 5 deletions src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -1448,11 +1448,16 @@ void error(char *msg)

strcpy(diagnostic + i, "^ Error occurs here");

/* TODO: Implement line/column tracking for precise error location
* reporting. Current implementation only shows source position offset.
*/
printf("[Error]: %s\nOccurs at source location %d.\n%s\n", msg,
SOURCE->size, diagnostic);
/* Backtrack SOURCE to find line of position */
int line = 1;
for (i = 0; i < start_idx; i++) {
if (SOURCE->elements[i] == '\n')
line++;
}
int column = SOURCE->size - start_idx + 1;

printf("[Error]: %s\nOccurs at source location %d:%d.\n%s\n", msg, line,
column, diagnostic);
abort();
}

Expand Down
Loading