vfmt2: fix literal integer number formatting
parent
cff6f4abd6
commit
f73b38a0d8
|
@ -40,7 +40,7 @@ pub:
|
|||
|
||||
pub struct IntegerLiteral {
|
||||
pub:
|
||||
val int
|
||||
val string
|
||||
}
|
||||
|
||||
pub struct FloatLiteral {
|
||||
|
|
|
@ -69,9 +69,9 @@ pub fn (x Expr) str() string {
|
|||
*/
|
||||
|
||||
IntegerLiteral {
|
||||
return it.val.str()
|
||||
return it.val
|
||||
}
|
||||
IntegerLiteral {
|
||||
StringLiteral {
|
||||
return '"$it.val"'
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -492,12 +492,12 @@ pub fn (c mut Checker) array_init(array_init mut ast.ArrayInit) table.Type {
|
|||
mut fixed_size := 1
|
||||
match array_init.exprs[0] {
|
||||
ast.IntegerLiteral {
|
||||
fixed_size = it.val
|
||||
fixed_size = it.val.int()
|
||||
}
|
||||
else {
|
||||
c.error('expecting `int` for fixed size', array_init.pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
idx := c.table.find_or_register_array_fixed(array_init.elem_type, fixed_size, 1)
|
||||
array_type := table.new_type(idx)
|
||||
array_init.typ = array_type
|
||||
|
|
|
@ -433,7 +433,7 @@ fn (f mut Fmt) expr(node ast.Expr) {
|
|||
f.write(']')
|
||||
}
|
||||
ast.IntegerLiteral {
|
||||
f.write(it.val.str())
|
||||
f.write(it.val)
|
||||
}
|
||||
ast.MapInit {
|
||||
f.writeln('{')
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
x := 0xdeadbeef
|
||||
u := 9978654321
|
||||
}
|
|
@ -747,7 +747,7 @@ fn (g mut Gen) expr(node ast.Expr) {
|
|||
g.infix_expr(it)
|
||||
}
|
||||
ast.IntegerLiteral {
|
||||
g.write(it.val.str())
|
||||
g.write(it.val.int().str())
|
||||
}
|
||||
ast.MatchExpr {
|
||||
g.match_expr(it)
|
||||
|
|
|
@ -108,7 +108,7 @@ fn (g mut JsGen) expr(node ast.Expr) {
|
|||
// println('cgen expr()')
|
||||
match node {
|
||||
ast.IntegerLiteral {
|
||||
g.write(it.val.str())
|
||||
g.write(it.val)
|
||||
}
|
||||
ast.FloatLiteral {
|
||||
g.write(it.val)
|
||||
|
|
|
@ -1310,7 +1310,7 @@ fn (p mut Parser) parse_number_literal() ast.Expr {
|
|||
}
|
||||
else {
|
||||
node = ast.IntegerLiteral{
|
||||
val: lit.int()
|
||||
val: lit
|
||||
}
|
||||
}
|
||||
p.next()
|
||||
|
|
Loading…
Reference in New Issue