From 4d8283e14b0365038b01df4fab5dee75035007ed Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 25 Aug 2019 11:18:13 +0200 Subject: Remove number of branches in executor --- include/compiler.h | 6 ++++++ include/defs.h | 1 + include/tokenizer.h | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/compiler.h b/include/compiler.h index ac50d28..3e3cc92 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -67,4 +67,10 @@ void amal_compiler_options_init(amal_compiler_options *self); CHECK_RESULT int amal_compiler_load_file(amal_compiler_options *options, amal_program *program, const char *filepath); CHECK_RESULT int amal_compiler_internal_load_file(amal_compiler *self, const char *filepath, FileScopeReference **file_scope); +/* + Returns a reference to the parsers tokenizer that contains the code reference, or NULL. + Note: The lifetime of the tokenizer returned is the same as the lifetime of the parser that owns it. +*/ +Tokenizer* amal_compiler_find_tokenizer_by_code_reference(amal_compiler *self, const char *code_ref); + #endif diff --git a/include/defs.h b/include/defs.h index c8db820..669d9c9 100644 --- a/include/defs.h +++ b/include/defs.h @@ -7,5 +7,6 @@ typedef struct Scope Scope; typedef struct FileScopeReference FileScopeReference; typedef struct FunctionDecl FunctionDecl; typedef struct FunctionSignature FunctionSignature; +typedef struct Tokenizer Tokenizer; #endif diff --git a/include/tokenizer.h b/include/tokenizer.h index 57ed9de..b6b401b 100644 --- a/include/tokenizer.h +++ b/include/tokenizer.h @@ -4,6 +4,7 @@ #include "std/buffer_view.h" #include "std/misc.h" #include "std/defs.h" +#include "defs.h" #include "binop_type.h" #include "compiler_options.h" #include @@ -42,7 +43,7 @@ typedef enum { TOK_RETURN } Token; -typedef struct { +struct Tokenizer { BufferView code; int index; int prev_index; @@ -64,7 +65,7 @@ typedef struct { bool number_is_integer; ArenaAllocator *allocator; /* borrowed */ const amal_compiler_options *compiler_options; /* borrowed */ -} Tokenizer; +}; typedef struct { int index; @@ -84,5 +85,6 @@ void tokenizer_print_error_object(Tokenizer *self, TokenizerError *error); TokenizerError tokenizer_create_error(Tokenizer *self, int index, const char *fmt, ...); int tokenizer_get_error_index(Tokenizer *self); int tokenizer_get_code_reference_index(Tokenizer *self, const char *ref); +bool tokenizer_contains_code_reference(Tokenizer *self, const char *code_ref); #endif -- cgit v1.2.3