92
92
pos token.Position
93
93
return_type_pos token.Position
94
94
pub mut :
95
- return_type Type
96
- name string
97
- params []Param
98
- source_fn voidptr // set in the checker, while processing fn declarations
99
- usages int
100
- //
95
+ return_type Type
96
+ name string
97
+ params []Param
98
+ source_fn voidptr // set in the checker, while processing fn declarations
99
+ usages int
101
100
generic_names []string
102
101
attrs []Attr // all fn attributes
103
102
is_conditional bool // true for `[if abc]fn(){}`
@@ -168,16 +167,6 @@ fn (p []Param) equals(o []Param) bool {
168
167
return true
169
168
}
170
169
171
- /*
172
- pub struct Var {
173
- pub:
174
- name string
175
- is_mut bool
176
- mut:
177
- typ Type
178
- }
179
- */
180
-
181
170
pub fn new_table () & Table {
182
171
mut t := & Table{
183
172
type_symbols: []TypeSymbol{cap: 64000 }
@@ -301,7 +290,6 @@ pub fn (t &Table) known_fn(name string) bool {
301
290
}
302
291
303
292
pub fn (mut t Table) register_fn (new_fn Fn) {
304
- // println('reg fn $new_fn.name nr_args=$new_fn.args.len')
305
293
t.fns[new_fn.name] = new_fn
306
294
}
307
295
@@ -312,7 +300,6 @@ pub fn (mut t Table) register_interface(idecl InterfaceDecl) {
312
300
pub fn (mut t TypeSymbol) register_method (new_fn Fn) int {
313
301
// returns a method index, stored in the ast.FnDecl
314
302
// for faster lookup in the checker's fn_decl method
315
- // println('reg me $new_fn.name nr_args=$new_fn.args.len')
316
303
t.methods << new_fn
317
304
return t.methods.len - 1
318
305
}
@@ -344,16 +331,12 @@ pub fn (t &Table) register_aggregate_method(mut sym TypeSymbol, name string) ?Fn
344
331
}
345
332
346
333
pub fn (t &Table) type_has_method (s & TypeSymbol, name string ) bool {
347
- // println('type_has_method($s.name, $name) types.len=$t.types.len s.parent_idx=$s.parent_idx')
348
- if _ := t.type_find_method (s, name) {
349
- return true
350
- }
351
- return false
334
+ t.type_find_method (s, name) or { return false }
335
+ return true
352
336
}
353
337
354
338
// type_find_method searches from current type up through each parent looking for method
355
339
pub fn (t &Table) type_find_method (s & TypeSymbol, name string ) ? Fn {
356
- // println('type_find_method($s.name, $name) types.len=$t.types.len s.parent_idx=$s.parent_idx')
357
340
mut ts := unsafe { s }
358
341
for {
359
342
if method := ts.find_method (name) {
@@ -454,11 +437,8 @@ fn (t &Table) register_aggregate_field(mut sym TypeSymbol, name string) ?StructF
454
437
}
455
438
456
439
pub fn (t &Table) struct_has_field (struct_ & TypeSymbol, name string ) bool {
457
- // println('struct_has_field($s.name, $name) types.len=$t.types.len s.parent_idx=$s.parent_idx')
458
- if _ := t.find_field (struct_, name) {
459
- return true
460
- }
461
- return false
440
+ t.find_field (struct_, name) or { return false }
441
+ return true
462
442
}
463
443
464
444
// struct_fields returns all fields including fields from embeds
@@ -477,7 +457,6 @@ pub fn (t &Table) struct_fields(sym &TypeSymbol) []StructField {
477
457
478
458
// search from current type up through each parent looking for field
479
459
pub fn (t &Table) find_field (s & TypeSymbol, name string ) ? StructField {
480
- // println('find_field($s.name, $name) types.len=$t.types.len s.parent_idx=$s.parent_idx')
481
460
mut ts := unsafe { s }
482
461
for {
483
462
match mut ts.info {
@@ -707,7 +686,6 @@ fn (mut t Table) check_for_already_registered_symbol(typ TypeSymbol, existing_id
707
686
match ex_type.kind {
708
687
.placeholder {
709
688
// override placeholder
710
- // println('overriding type placeholder `$typ.name`')
711
689
t.type_symbols[existing_idx] = TypeSymbol{
712
690
...typ
713
691
methods: ex_type.methods
@@ -914,7 +892,6 @@ pub fn (t &Table) map_cname(key_type Type, value_type Type) string {
914
892
value_type_sym := t.get_type_symbol (value_type)
915
893
suffix := if value_type.is_ptr () { '_ptr' } else { '' }
916
894
return 'Map_${key_type_sym.cname} _$value_type_sym.cname ' + suffix
917
- // return 'map_${value_type_sym.name}' + suffix
918
895
}
919
896
920
897
pub fn (mut t Table) find_or_register_chan (elem_type Type, is_mut bool ) int {
@@ -1099,7 +1076,6 @@ pub fn (mut t Table) add_placeholder_type(name string, language Language) int {
1099
1076
language: language
1100
1077
mod: modname
1101
1078
}
1102
- // println('added placeholder: $name - $ph_type.idx')
1103
1079
return t.register_type_symbol (ph_type)
1104
1080
}
1105
1081
0 commit comments