#define SYMERROR ((unsigned) ~0)
-typedef struct io_env
+typedef struct io_env_t
{
FILE *file;
set *idset; /**< id_entry set, which maps from file ids to new Firm elements */
ir_type **fixedtypes;
} io_env_t;
+typedef struct lex_state_t
+{
+ long offs;
+ int line, col;
+} lex_state_t;
+
typedef enum typetag_t
{
tt_align,
fclose(env.file);
}
+static void save_lex_state(io_env_t *env, lex_state_t *state)
+{
+ state->offs = ftell(env->file);
+ state->line = env->line;
+ state->col = env->col;
+}
+
+static void restore_lex_state(io_env_t *env, lex_state_t *state)
+{
+ fseek(env->file, state->offs, SEEK_SET);
+ env->line = state->line;
+ env->col = state->col;
+}
+
static int read_c(io_env_t *env)
{
int ch = fgetc(env->file);
static int parse_typegraph(io_env_t *env)
{
const char *kind;
- long curfpos;
+ lex_state_t oldstate;
EXPECT('{');
- curfpos = ftell(env->file);
+ save_lex_state(env, &oldstate);
current_ir_graph = get_const_code_irg();
}
// now parse rest
- fseek(env->file, curfpos, SEEK_SET);
+ restore_lex_state(env, &oldstate);
+
while(1)
{
kind = read_str(env);