Implemented line indexing for faster jumps/looping.

This required adding the ability to to get and set the
tokenizer's current position pointer from outside of it with
tokenizer_pos and tokenizer_goto (c.f. tokenizer_init).
The index itself is stored as a linked list, which makes it ripe
for further optimization. It is accessed with index_* routines.
The interpreter resorts to running the old, slower jump procedure
when jumping forward (to a line that hasn't been index).

New goto test.
This commit is contained in:
Danyil Bohdan 2013-12-22 16:15:40 +02:00
parent 9c45ed4588
commit f9ea3c6e6b
4 changed files with 123 additions and 4 deletions

View file

@ -69,6 +69,7 @@ enum {
TOKENIZER_CR,
};
void tokenizer_goto(const char *program);
void tokenizer_init(const char *program);
void tokenizer_next(void);
int tokenizer_token(void);
@ -79,4 +80,6 @@ void tokenizer_string(char *dest, int len);
int tokenizer_finished(void);
void tokenizer_error_print(void);
char const *tokenizer_pos(void);
#endif /* __TOKENIZER_H__ */