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

x64 machine code generation (ELF)

This commit is contained in:
Alexander Medvednikov
2019-11-19 09:53:52 +03:00
parent ab91733a28
commit 9712213f50
13 changed files with 564 additions and 15 deletions

View File

@ -11,6 +11,8 @@ fn (p mut Parser) for_st() {
next_tok := p.peek()
//debug := p.scanner.file_path.contains('r_draw')
p.open_scope()
mut label := 0
mut to := 0
if p.tok == .lcbr {
// Infinite loop
p.gen('while (1) {')
@ -130,9 +132,17 @@ fn (p mut Parser) for_st() {
if is_range {
p.check_types(typ, 'int')
p.check_space(.dotdot)
if p.pref.x64 {
to = p.lit.int()
}
range_typ, range_expr := p.tmp_expr()
p.check_types(range_typ, 'int')
range_end = range_expr
if p.pref.x64 {
label = p.x64.gen_loop_start(expr.int())
//to = range_expr.int() // TODO why empty?
}
}
is_arr := typ.contains('array')
is_str := typ == 'string'
@ -189,5 +199,8 @@ fn (p mut Parser) for_st() {
p.close_scope()
p.for_expr_cnt--
p.returns = false // TODO handle loops that are guaranteed to return
if label > 0 {
p.x64.gen_loop_end(to, label)
}
}