diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-08-25 11:18:13 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | 4d8283e14b0365038b01df4fab5dee75035007ed (patch) | |
tree | 758545eeeb9b7eae3b04fdc6a863fd06f3039f6d /src | |
parent | d9f652919961a2947452ad3c4af4659f3d2fb330 (diff) |
Remove number of branches in executor
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler.c | 10 | ||||
-rw-r--r-- | src/tokenizer.c | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/compiler.c b/src/compiler.c index 3ccb86a..dbc1498 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -482,3 +482,13 @@ int amal_compiler_internal_load_file(amal_compiler *self, const char *filepath, return 0; } + +Tokenizer* amal_compiler_find_tokenizer_by_code_reference(amal_compiler *self, const char *code_ref) { + Parser **parser = buffer_begin(&self->parsers); + Parser **parser_end = buffer_end(&self->parsers); + for(; parser != parser_end; ++parser) { + if(tokenizer_contains_code_reference(&(*parser)->tokenizer, code_ref)) + return &(*parser)->tokenizer; + } + return NULL; +} diff --git a/src/tokenizer.c b/src/tokenizer.c index 82ea0f6..fd516f6 100644 --- a/src/tokenizer.c +++ b/src/tokenizer.c @@ -768,3 +768,7 @@ int tokenizer_get_code_reference_index(Tokenizer *self, const char *ref) { return -1; return ref - self->code.data; } + +bool tokenizer_contains_code_reference(Tokenizer *self, const char *code_ref) { + return code_ref >= self->code.data && code_ref < self->code.data + self->code.size; +} |