1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: map[string]pointer, ?pointer, fix []pointer

This commit is contained in:
れもん
2019-12-22 07:44:16 +09:00
committed by Alexander Medvednikov
parent b76227b781
commit 28ecfb231d
14 changed files with 98 additions and 48 deletions

View File

@ -96,7 +96,7 @@ fn (p mut Parser) gen_handle_option_or_else(_typ, name string, fn_call_ph int) s
is_assign := name.len > 0
tmp := p.get_tmp()
p.cgen.set_placeholder(fn_call_ph, '$typ $tmp = ')
typ = typ[7..]
typ = parse_pointer(typ[7..])
p.genln(';')
or_tok_idx := p.token_idx
p.check(.key_orelse)
@ -324,7 +324,7 @@ fn (p mut Parser) gen_method_call(receiver &Var, receiver_type string, cgen_name
if ftyp == 'void*' {
if receiver_type.starts_with('array_') {
// array_int => int
cast = receiver_type.all_after('array_')
cast = parse_pointer(receiver_type.all_after('array_'))
cast = '*($cast*) '
}
else {
@ -611,7 +611,7 @@ fn (p mut Parser) cast(typ string) {
fn type_default(typ string) string {
if typ.starts_with('array_') {
return 'new_array(0, 1, sizeof( ${typ[6..]} ))'
return 'new_array(0, 1, sizeof( ${parse_pointer(typ[6..])} ))'
}
// Always set pointers to 0
if typ.ends_with('*') {