if (!compiler->vars[var].used) {
if (compiler->vars[var].vartype == ORC_VAR_TYPE_TEMP) {
- ORC_COMPILER_ERROR(compiler, "using uninitialized temp var");
+ ORC_COMPILER_ERROR(compiler, "using uninitialized temp var at line %d", insn->line);
compiler->result = ORC_COMPILE_RESULT_UNKNOWN_PARSE;
}
compiler->vars[var].used = TRUE;
continue;
}
if (compiler->vars[var].vartype == ORC_VAR_TYPE_SRC) {
- ORC_COMPILER_ERROR(compiler,"using src var as dest");
+ ORC_COMPILER_ERROR(compiler,"using src var as dest at line %d", insn->line);
compiler->result = ORC_COMPILE_RESULT_UNKNOWN_PARSE;
}
if (compiler->vars[var].vartype == ORC_VAR_TYPE_CONST) {
- ORC_COMPILER_ERROR(compiler,"using const var as dest");
+ ORC_COMPILER_ERROR(compiler,"using const var as dest at line %d", insn->line);
compiler->result = ORC_COMPILE_RESULT_UNKNOWN_PARSE;
}
if (compiler->vars[var].vartype == ORC_VAR_TYPE_PARAM) {
- ORC_COMPILER_ERROR(compiler,"using param var as dest");
+ ORC_COMPILER_ERROR(compiler,"using param var as dest at line %d", insn->line);
compiler->result = ORC_COMPILE_RESULT_UNKNOWN_PARSE;
}
if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) {
if (compiler->vars[var].vartype != ORC_VAR_TYPE_ACCUMULATOR) {
- ORC_COMPILER_ERROR(compiler,"accumulating opcode to non-accumulator dest");
+ ORC_COMPILER_ERROR(compiler,"accumulating opcode to non-accumulator dest at line %d", insn->line);
compiler->result = ORC_COMPILE_RESULT_UNKNOWN_PARSE;
}
} else {
if (compiler->vars[var].vartype == ORC_VAR_TYPE_ACCUMULATOR) {
- ORC_COMPILER_ERROR(compiler,"non-accumulating opcode to accumulator dest");
+ ORC_COMPILER_ERROR(compiler,"non-accumulating opcode to accumulator dest at line %d", insn->line);
compiler->result = ORC_COMPILE_RESULT_UNKNOWN_PARSE;
}
}
} else {
#if 0
if (compiler->vars[var].vartype == ORC_VAR_TYPE_DEST) {
- ORC_COMPILER_ERROR(compiler,"writing dest more than once");
+ ORC_COMPILER_ERROR(compiler,"writing dest more than once at line %d", insn->line);
compiler->result = ORC_COMPILE_RESULT_UNKNOWN_PARSE;
}
#endif
OrcRule *rule;
unsigned int flags;
+ /* Source line number this instruction came from */
+ int line;
};
#define ORC_INSTRUCTION_FLAG_X2 (1<<0)
int n_tokens;
orc_parse_get_line (parser);
+ if (parser->program) orc_program_set_line (parser->program, parser->line_number);
p = parser->line;
end = p + strlen (p);
}
/**
+ * orc_program_set_line:
+ * @program: a pointer to an OrcProgram structure
+ * @name: define where we are in the source
+ *
+ * Sets the current line of the program.
+ */
+void
+orc_program_set_line (OrcProgram *program, unsigned int line)
+{
+ program->current_line = line;
+}
+
+/**
* orc_program_set_2d:
* @program: a pointer to an OrcProgram structure
*
insn = program->insns + program->n_insns;
+ insn->line = program->current_line;
insn->opcode = orc_opcode_find_by_name (name);
if (!insn->opcode) {
- ORC_ERROR ("unknown opcode: %s", name);
+ ORC_ERROR ("unknown opcode: %s at line %d", name, insn->line);
}
args[0] = orc_program_find_var_by_name (program, arg1);
args[1] = orc_program_find_var_by_name (program, arg2);
orc_debug_print(ORC_DEBUG_WARNING, __FILE__, ORC_FUNCTION, __LINE__, __VA_ARGS__); \
} while (0)
-
/**
* OrcProgram:
*
/* Hide this here. Belongs in a Parser object */
char *init_function;
char *error_msg;
+ unsigned int current_line;
};
#define ORC_SRC_ARG(p,i,n) ((p)->vars[(i)->src_args[(n)]].alloc)
const char * orc_program_get_name (OrcProgram *program);
void orc_program_set_name (OrcProgram *program, const char *name);
+void orc_program_set_line (OrcProgram *program, unsigned int line);
void orc_program_set_2d (OrcProgram *program);
void orc_program_set_constant_n (OrcProgram *program, int n);
void orc_program_set_n_multiple (OrcProgram *ex, int n);
if (ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) {
fprintf(output, "%s\n", orc_program_get_asm_code (p));
} else {
- printf("Failed to compile %s\n", p->name);
+ printf("Failed to compile backup code for '%s'\n", p->name);
error = TRUE;
}
}
if (ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) {
fprintf(output, "%s\n", orc_program_get_asm_code (p));
} else {
- printf("Failed to compile %s\n", p->name);
+ printf("Failed to compile no orc for '%s'\n", p->name);
error = TRUE;
}
}
if (ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) {
fprintf(output, "%s\n", orc_program_get_asm_code (p));
} else {
- printf("Failed to compile %s\n", p->name);
+ printf("Failed to compile assembly for '%s'\n", p->name);
error = TRUE;
}
}