print_statement(statement->final_statement);
}
+/**
+ * Print a microsoft __leave statement.
+ *
+ * @param statement the statement
+ */
+static void print_leave_statement(const leave_statement_t *statement)
+{
+ (void) statement;
+ fputs("__leave;\n", out);
+}
+
/**
* Print a statement.
*
case STATEMENT_MS_TRY:
print_ms_try_statement(&statement->ms_try);
break;
+ case STATEMENT_LEAVE:
+ print_leave_statement(&statement->leave);
+ break;
case STATEMENT_INVALID:
fprintf(out, "$invalid statement$");
break;
warningf(&statement->base.source_position, "structured exception handling ignored");
}
+static void leave_statement_to_firm(leave_statement_t *statement) {
+ errorf(&statement->base.source_position, "__leave not supported yet");
+}
+
static void statement_to_firm(statement_t *statement)
{
switch(statement->kind) {
case STATEMENT_MS_TRY:
ms_try_statement_to_firm(&statement->ms_try);
return;
+ case STATEMENT_LEAVE:
+ leave_statement_to_firm(&statement->leave);
+ return;
}
panic("Statement not implemented\n");
}
}
case STATEMENT_GOTO:
+ case STATEMENT_LEAVE:
case STATEMENT_INVALID:
break;
static declaration_t *current_function = NULL;
static switch_statement_t *current_switch = NULL;
static statement_t *current_loop = NULL;
+static ms_try_statement_t *current_try = NULL;
static goto_statement_t *goto_first = NULL;
static goto_statement_t *goto_last = NULL;
static label_statement_t *label_first = NULL;
[STATEMENT_DO_WHILE] = sizeof(do_while_statement_t),
[STATEMENT_FOR] = sizeof(for_statement_t),
[STATEMENT_ASM] = sizeof(asm_statement_t),
- [STATEMENT_MS_TRY] = sizeof(ms_try_statement_t)
+ [STATEMENT_MS_TRY] = sizeof(ms_try_statement_t),
+ [STATEMENT_LEAVE] = sizeof(leave_statement_t)
};
assert(kind <= sizeof(sizes) / sizeof(sizes[0]));
assert(sizes[kind] != 0);
statement_t *statement;
if (current_loop == NULL) {
errorf(HERE, "continue statement not within loop");
- statement = NULL;
+ statement = create_invalid_statement();
} else {
statement = allocate_statement_zero(STATEMENT_CONTINUE);
statement_t *statement;
if (current_switch == NULL && current_loop == NULL) {
errorf(HERE, "break statement not within loop or switch");
- statement = NULL;
+ statement = create_invalid_statement();
} else {
statement = allocate_statement_zero(STATEMENT_BREAK);
return create_invalid_statement();
}
+/**
+ * Parse a __leave statement.
+ */
+static statement_t *parse_leave(void)
+{
+ statement_t *statement;
+ if (current_try == NULL) {
+ errorf(HERE, "__leave statement not within __try");
+ statement = create_invalid_statement();
+ } else {
+ statement = allocate_statement_zero(STATEMENT_LEAVE);
+
+ statement->base.source_position = token.source_position;
+ }
+
+ eat(T___leave);
+ expect(';');
+
+ return statement;
+end_error:
+ return create_invalid_statement();
+}
+
/**
* Check if a given declaration represents a local variable.
*/
statement->base.source_position = token.source_position;
eat(T___try);
+ ms_try_statement_t *rem = current_try;
+ current_try = &statement->ms_try;
statement->ms_try.try_statement = parse_compound_statement();
+ current_try = rem;
if(token.type == T___except) {
eat(T___except);
statement = parse_break();
break;
+ case T___leave:
+ statement = parse_leave();
+ break;
+
case T_return:
statement = parse_return();
break;