fix parser.fileis()

pull/3060/head
Alexander Medvednikov 2019-12-11 21:42:22 +03:00
parent 6ffed854cc
commit ad250523cd
3 changed files with 4 additions and 3 deletions

View File

@ -4,6 +4,7 @@
module builtin module builtin
__global g_m2_buf byteptr
__global g_m2_ptr byteptr __global g_m2_ptr byteptr
fn init() { fn init() {

View File

@ -526,6 +526,7 @@ pub fn (v mut V) generate_main() {
cgen.genln(' main__main();') cgen.genln(' main__main();')
if !v.pref.is_bare { if !v.pref.is_bare {
cgen.genln('free(g_str_buf);') cgen.genln('free(g_str_buf);')
cgen.genln('free(g_m2_ptr);')
} }
v.gen_main_end('return 0') v.gen_main_end('return 0')
} }

View File

@ -1352,7 +1352,6 @@ fn (p mut Parser) statement(add_semi bool) string {
// this can be `user = ...` or `user.field = ...`, in both cases `v` is `user` // this can be `user = ...` or `user.field = ...`, in both cases `v` is `user`
fn (p mut Parser) assign_statement(v Var, ph int, is_map bool) { fn (p mut Parser) assign_statement(v Var, ph int, is_map bool) {
errtok := p.cur_tok_index() errtok := p.cur_tok_index()
//p.log('assign_statement() name=$v.name tok=')
is_vid := p.fileis('vid') // TODO remove is_vid := p.fileis('vid') // TODO remove
tok := p.tok tok := p.tok
//if !v.is_mut && !v.is_arg && !p.pref.translated && !v.is_global{ //if !v.is_mut && !v.is_arg && !p.pref.translated && !v.is_global{
@ -1829,6 +1828,7 @@ fn (p mut Parser) dot(str_typ_ string, method_ph int) string {
if typ.name.len == 0 { if typ.name.len == 0 {
p.error('dot(): cannot find type `$str_typ`') p.error('dot(): cannot find type `$str_typ`')
} }
// foo.$action()
if p.tok == .dollar { if p.tok == .dollar {
p.comptime_method_call(typ) p.comptime_method_call(typ)
return 'void' return 'void'
@ -1841,7 +1841,6 @@ fn (p mut Parser) dot(str_typ_ string, method_ph int) string {
else if field_name == 'map' && str_typ.starts_with('array_') { else if field_name == 'map' && str_typ.starts_with('array_') {
return p.gen_array_map(str_typ, method_ph) return p.gen_array_map(str_typ, method_ph)
} }
fname_tidx := p.cur_tok_index() fname_tidx := p.cur_tok_index()
//p.log('dot() field_name=$field_name typ=$str_typ') //p.log('dot() field_name=$field_name typ=$str_typ')
//if p.fileis('main.v') { //if p.fileis('main.v') {
@ -2175,7 +2174,7 @@ struct IndexConfig {
// for debugging only // for debugging only
fn (p &Parser) fileis(s string) bool { fn (p &Parser) fileis(s string) bool {
return p.scanner.file_path.contains(s) return os.filename(p.scanner.file_path).contains(s)
} }
// in and dot have higher priority than `!` // in and dot have higher priority than `!`