Commit 56c8a9e1 authored by Guillaume Charifi's avatar Guillaume Charifi

compiler/parser: Introduce compare_class_path().

parent 983003c6
......@@ -386,6 +386,28 @@ int clone_class_path(struct bm_ast_class_path *class_path, struct bm_ast_class_p
return buffer_clone(&class_path->seqs, &out->seqs);
}
int compare_class_path(struct bm_ast_class_path *a, struct bm_ast_class_path *b)
{
unsigned long a_len = buffer_get_line_count(&a->seqs);
unsigned long b_len = buffer_get_line_count(&b->seqs);
if (a_len != b_len)
return a_len - b_len;
for (unsigned long i = 0; i < a_len; i++)
{
int result;
const wchar_t *a_str = buffer_get_line(&a->seqs, i);
const wchar_t *b_str = buffer_get_line(&b->seqs, i);
result = wcscmp(a_str, b_str);
if (result != 0)
return result;
}
return 0;
}
int destroy_type(struct bm_ast_type *type)
{
destroy_class_path(&type->class_path);
......
......@@ -42,6 +42,7 @@ extern int destroy_class_path(struct bm_ast_class_path *class_path);
extern int debug_class_path(const struct bm_ast_class_path *class_path);
extern int parse_class_path(struct parser_ctx *ctx, unsigned long *cur_tok_id, struct bm_ast_class_path *out);
extern int clone_class_path(struct bm_ast_class_path *class_path, struct bm_ast_class_path *out);
extern int compare_class_path(struct bm_ast_class_path *a, struct bm_ast_class_path *b);
extern int destroy_type(struct bm_ast_type *type);
extern int debug_type(const struct bm_ast_type *type);
extern int parse_type(struct parser_ctx *ctx, unsigned long *cur_tok_id, struct bm_ast_type *out);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment