mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
generic functions
This commit is contained in:

committed by
Alexander Medvednikov

parent
f63e24e51d
commit
8a31ee4b53
@ -41,17 +41,17 @@ fn (p mut Parser) comp_time() {
|
||||
stack++
|
||||
} else if p.tok == .rcbr {
|
||||
stack--
|
||||
}
|
||||
}
|
||||
if p.tok == .eof {
|
||||
break
|
||||
}
|
||||
}
|
||||
if stack <= 0 && p.tok == .rcbr {
|
||||
//p.warn('exiting $stack')
|
||||
p.next()
|
||||
break
|
||||
}
|
||||
}
|
||||
p.next()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.statements_no_rcbr()
|
||||
}
|
||||
@ -185,8 +185,9 @@ fn (p mut Parser) chash() {
|
||||
flag = flag.replace('@VROOT', p.vroot)
|
||||
flag = flag.replace('@VMOD', v_modules_path)
|
||||
//p.log('adding flag "$flag"')
|
||||
_ = p.table.parse_cflag(flag, p.mod) or {
|
||||
_p := p.table.parse_cflag(flag, p.mod) or {
|
||||
p.error_with_token_index(err, p.cur_tok_index()-1)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -219,16 +220,16 @@ fn (p mut Parser) chash() {
|
||||
$if js {
|
||||
for p.tok != .eof {
|
||||
p.next()
|
||||
}
|
||||
}
|
||||
} $else {
|
||||
p.next()
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$if !js {
|
||||
if !p.can_chash {
|
||||
println('hash="$hash"')
|
||||
println(hash.starts_with('include'))
|
||||
if hash.starts_with('include') { println("include") } else {}
|
||||
p.error('bad token `#` (embedding C code is no longer supported)')
|
||||
}
|
||||
}
|
||||
@ -307,7 +308,7 @@ fn (p mut Parser) gen_struct_str(typ Type) {
|
||||
is_public: true
|
||||
receiver_typ: typ.name
|
||||
})
|
||||
|
||||
|
||||
mut sb := strings.new_builder(typ.fields.len * 20)
|
||||
sb.writeln('fn (a $typ.name) str() string {\nreturn')
|
||||
sb.writeln("'{")
|
||||
|
Reference in New Issue
Block a user