mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: second batch of start_tmp()
This commit is contained in:
@@ -65,8 +65,7 @@ fn (p mut Parser) for_st() {
|
||||
p.check(.key_in)
|
||||
p.fspace()
|
||||
tmp := p.get_tmp()
|
||||
p.cgen.start_tmp()
|
||||
mut typ := p.bool_expression()
|
||||
mut typ, expr := p.tmp_expr()
|
||||
is_arr := typ.starts_with('array_')
|
||||
is_map := typ.starts_with('map_')
|
||||
is_str := typ == 'string'
|
||||
@@ -74,7 +73,6 @@ fn (p mut Parser) for_st() {
|
||||
if !is_arr && !is_str && !is_map && !is_variadic_arg {
|
||||
p.error('cannot range over type `$typ`')
|
||||
}
|
||||
expr := p.cgen.end_tmp()
|
||||
if !is_variadic_arg {
|
||||
if p.is_js {
|
||||
p.genln('var $tmp = $expr;')
|
||||
@@ -125,18 +123,16 @@ fn (p mut Parser) for_st() {
|
||||
p.check(.key_in)
|
||||
p.fspace()
|
||||
tmp := p.get_tmp()
|
||||
p.cgen.start_tmp()
|
||||
mut typ := p.bool_expression()
|
||||
expr := p.cgen.end_tmp()
|
||||
mut typ, expr := p.tmp_expr()
|
||||
is_range := p.tok == .dotdot
|
||||
is_variadic_arg := typ.starts_with('varg_')
|
||||
mut range_end := ''
|
||||
if is_range {
|
||||
p.check_types(typ, 'int')
|
||||
p.check_space(.dotdot)
|
||||
p.cgen.start_tmp()
|
||||
p.check_types(p.bool_expression(), 'int')
|
||||
range_end = p.cgen.end_tmp()
|
||||
range_typ, range_expr := p.tmp_expr()
|
||||
p.check_types(range_typ, 'int')
|
||||
range_end = range_expr
|
||||
}
|
||||
is_arr := typ.contains('array')
|
||||
is_str := typ == 'string'
|
||||
|
||||
Reference in New Issue
Block a user