@@ -212,6 +212,7 @@ pub const scanner_matcher = new_keywords_matcher_trie[Kind](keywords)
212212
213213// build_keys generates a map with keywords' string values:
214214// Keywords['return'] == .key_return
215+ @[direct_array_access]
215216fn build_keys () map [string ]Kind {
216217 mut res := map [string ]Kind{}
217218 for t in int (Kind.keyword_beg) + 1 .. int (Kind.keyword_end) {
@@ -228,6 +229,7 @@ fn build_keys() map[string]Kind {
228229}
229230
230231// TODO: remove once we have `enum Kind { name('name') if('if') ... }`
232+ @[direct_array_access]
231233fn build_token_str () []string {
232234 mut s := []string {len: int (Kind._end_)}
233235 s[Kind.unknown] = 'unknown'
@@ -381,7 +383,7 @@ pub fn (t Kind) is_assign() bool {
381383}
382384
383385// note: used for some code generation, so no quoting
384- @[inline]
386+ @[direct_array_access; inline]
385387pub fn (t Kind) str () string {
386388 idx := int (t)
387389 if idx < 0 || token_str.len < = idx {
@@ -395,10 +397,12 @@ pub fn (t Token) is_next_to(pre_token Token) bool {
395397 return t.pos - pre_token.pos == pre_token.len
396398}
397399
400+ @[inline]
398401pub fn (t Token) is_key () bool {
399402 return int (t.kind) > int (Kind.keyword_beg) && int (t.kind) < int (Kind.keyword_end)
400403}
401404
405+ @[direct_array_access]
402406pub fn (t Token) str () string {
403407 mut s := t.kind.str ()
404408 if s.len == 0 {
@@ -441,6 +445,7 @@ pub enum Precedence {
441445 highest
442446}
443447
448+ @[direct_array_access]
444449pub fn build_precedences () []Precedence {
445450 mut p := []Precedence{len: int (Kind._end_), init: Precedence.lowest}
446451 p[Kind.lsbr] = .index
0 commit comments