Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/GStreamer/orc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@efl.so>2012-04-28 22:15:39 +0400
committerDavid Schleef <ds@schleef.org>2012-04-28 22:19:53 +0400
commit49ce0d56385c23f071ef720267a88fc6edece4f7 (patch)
tree2c6786d98fedcffb7bca3066219f27e7c63d97c8
parentfb5e8c5d30a06b149b22d7b33f398b826a47e7f0 (diff)
Add line numbers to errors
-rw-r--r--orc/orccompiler.c14
-rw-r--r--orc/orcinstruction.h2
-rw-r--r--orc/orcparse.c1
-rw-r--r--orc/orcprogram.c16
-rw-r--r--orc/orcprogram.h3
-rw-r--r--tools/orcc.c6
6 files changed, 30 insertions, 12 deletions
diff --git a/orc/orccompiler.c b/orc/orccompiler.c
index dc09916..68eb01e 100644
--- a/orc/orccompiler.c
+++ b/orc/orccompiler.c
@@ -726,7 +726,7 @@ orc_compiler_rewrite_vars (OrcCompiler *compiler)
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;
@@ -744,25 +744,25 @@ orc_compiler_rewrite_vars (OrcCompiler *compiler)
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;
}
}
@@ -779,7 +779,7 @@ orc_compiler_rewrite_vars (OrcCompiler *compiler)
} 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
diff --git a/orc/orcinstruction.h b/orc/orcinstruction.h
index fe8bef5..5af4ea6 100644
--- a/orc/orcinstruction.h
+++ b/orc/orcinstruction.h
@@ -24,6 +24,8 @@ struct _OrcInstruction {
OrcRule *rule;
unsigned int flags;
+ /* Source line number this instruction came from */
+ int line;
};
#define ORC_INSTRUCTION_FLAG_X2 (1<<0)
diff --git a/orc/orcparse.c b/orc/orcparse.c
index ea17c13..16fdaf4 100644
--- a/orc/orcparse.c
+++ b/orc/orcparse.c
@@ -80,6 +80,7 @@ orc_parse_full (const char *code, OrcProgram ***programs, char **log)
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);
diff --git a/orc/orcprogram.c b/orc/orcprogram.c
index 05a0baa..13c219c 100644
--- a/orc/orcprogram.c
+++ b/orc/orcprogram.c
@@ -195,6 +195,19 @@ orc_program_set_name (OrcProgram *program, const char *name)
}
/**
+ * 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
*
@@ -838,9 +851,10 @@ orc_program_append_str_2 (OrcProgram *program, const char *name,
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);
diff --git a/orc/orcprogram.h b/orc/orcprogram.h
index 9d1935f..6c442e1 100644
--- a/orc/orcprogram.h
+++ b/orc/orcprogram.h
@@ -19,7 +19,6 @@ ORC_BEGIN_DECLS
orc_debug_print(ORC_DEBUG_WARNING, __FILE__, ORC_FUNCTION, __LINE__, __VA_ARGS__); \
} while (0)
-
/**
* OrcProgram:
*
@@ -94,6 +93,7 @@ struct _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)
@@ -115,6 +115,7 @@ OrcProgram * orc_program_new_from_static_bytecode (const orc_uint8 *bytecode);
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);
diff --git a/tools/orcc.c b/tools/orcc.c
index 028b72d..ad4968a 100644
--- a/tools/orcc.c
+++ b/tools/orcc.c
@@ -643,7 +643,7 @@ output_code_backup (OrcProgram *p, FILE *output)
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;
}
}
@@ -667,7 +667,7 @@ output_code_no_orc (OrcProgram *p, FILE *output)
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;
}
}
@@ -1336,7 +1336,7 @@ output_code_assembly (OrcProgram *p, FILE *output)
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;
}
}