parser: fix multiple output modifiers in asm (#10347)
parent
751b1cffd3
commit
9553c5a4e6
|
@ -1577,7 +1577,7 @@ pub fn (expr Expr) is_expr() bool {
|
||||||
|
|
||||||
pub fn (expr Expr) is_lit() bool {
|
pub fn (expr Expr) is_lit() bool {
|
||||||
return match expr {
|
return match expr {
|
||||||
BoolLiteral, StringLiteral, IntegerLiteral { true }
|
BoolLiteral, CharLiteral, StringLiteral, IntegerLiteral { true }
|
||||||
else { false }
|
else { false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1558,7 +1558,9 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) (string, token.Position) {
|
||||||
return '', pos
|
return '', pos
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c.error('unexpected expression `$expr.type_name()`', expr.position())
|
if !expr.is_lit() {
|
||||||
|
c.error('unexpected expression `$expr.type_name()`', expr.position())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if explicit_lock_needed {
|
if explicit_lock_needed {
|
||||||
|
|
|
@ -1411,7 +1411,7 @@ fn (mut p Parser) asm_ios(output bool) []ast.AsmIO {
|
||||||
if mut expr is ast.ParExpr {
|
if mut expr is ast.ParExpr {
|
||||||
expr = expr.expr
|
expr = expr.expr
|
||||||
} else {
|
} else {
|
||||||
p.error('asm in/output must be incolsed in brackets $expr.type_name()')
|
p.error('asm in/output must be incolsed in brackets')
|
||||||
}
|
}
|
||||||
mut alias := ''
|
mut alias := ''
|
||||||
if p.tok.kind == .key_as {
|
if p.tok.kind == .key_as {
|
||||||
|
|
|
@ -352,6 +352,9 @@ pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr {
|
||||||
|
|
||||||
pub fn (mut p Parser) expr_with_left(left ast.Expr, precedence int, is_stmt_ident bool) ast.Expr {
|
pub fn (mut p Parser) expr_with_left(left ast.Expr, precedence int, is_stmt_ident bool) ast.Expr {
|
||||||
mut node := left
|
mut node := left
|
||||||
|
if p.inside_asm && p.prev_tok.position().line_nr < p.tok.position().line_nr {
|
||||||
|
return node
|
||||||
|
}
|
||||||
// Infix
|
// Infix
|
||||||
for precedence < p.tok.precedence() {
|
for precedence < p.tok.precedence() {
|
||||||
if p.tok.kind == .dot {
|
if p.tok.kind == .dot {
|
||||||
|
|
|
@ -169,4 +169,17 @@ fn test_flag_output() {
|
||||||
; r (zero)
|
; r (zero)
|
||||||
}
|
}
|
||||||
assert out
|
assert out
|
||||||
|
|
||||||
|
mut maybe_four := 4
|
||||||
|
mut four := 4
|
||||||
|
asm amd64 {
|
||||||
|
subl four, maybe_four
|
||||||
|
testl four, maybe_four
|
||||||
|
movl maybe_four, 9
|
||||||
|
; +m (maybe_four)
|
||||||
|
+r (four)
|
||||||
|
=@ccz (out)
|
||||||
|
}
|
||||||
|
assert out
|
||||||
|
assert maybe_four == 9
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,4 +151,17 @@ fn test_flag_output() {
|
||||||
; r (zero)
|
; r (zero)
|
||||||
}
|
}
|
||||||
assert out
|
assert out
|
||||||
|
|
||||||
|
mut maybe_four := 4
|
||||||
|
mut four := 4
|
||||||
|
asm amd64 {
|
||||||
|
subl four, maybe_four
|
||||||
|
testl four, maybe_four
|
||||||
|
movl maybe_four, 9
|
||||||
|
; +m (maybe_four)
|
||||||
|
+r (four)
|
||||||
|
=@ccz (out)
|
||||||
|
}
|
||||||
|
assert out
|
||||||
|
assert maybe_four == 9
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue