mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
remove old float
type entirely
This commit is contained in:
@ -110,7 +110,7 @@ string res = tos2("");
|
||||
|
||||
fn is_js_prim(typ string) bool {
|
||||
return typ == 'int' || typ == 'string' ||
|
||||
typ == 'bool' || typ == 'float' || typ == 'f32' || typ == 'f64' ||
|
||||
typ == 'bool' || typ == 'f32' || typ == 'f64' ||
|
||||
typ == 'i8' || typ == 'i16' || typ == 'i32' || typ == 'i64'
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ mut:
|
||||
is_so bool
|
||||
is_live bool // for hot code reloading
|
||||
is_prof bool // benchmark every function
|
||||
translated bool // `v translated doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
|
||||
translated bool // `v translate doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
|
||||
obfuscate bool // `v -obf program.v`, renames functions to "f_XXX"
|
||||
lang_dir string // "~/code/v"
|
||||
is_verbose bool // print extra information with `v.log()`
|
||||
|
@ -1924,23 +1924,16 @@ fn (p mut Parser) factor() string {
|
||||
tok := p.tok
|
||||
switch tok {
|
||||
case INT:
|
||||
p.gen(p.lit)
|
||||
p.fgen(p.lit)
|
||||
typ = 'int'
|
||||
// typ = 'number'
|
||||
if p.lit.starts_with('u') {
|
||||
typ = 'long'
|
||||
}
|
||||
if p.lit.contains('.') || p.lit.contains('e') {
|
||||
// typ = 'f64'
|
||||
typ = 'float'
|
||||
typ = 'f32'
|
||||
// typ = 'f64' // TODO
|
||||
}
|
||||
case FLOAT:
|
||||
// TODO remove float
|
||||
typ = 'float'
|
||||
// typ = 'f64'
|
||||
// p.gen('(f64)$p.lit')
|
||||
p.gen('$p.lit')
|
||||
p.gen(p.lit)
|
||||
p.fgen(p.lit)
|
||||
case MINUS:
|
||||
p.gen('-')
|
||||
@ -2101,8 +2094,7 @@ fn (p mut Parser) typ_to_fmt(typ string) string {
|
||||
case 'byte': return '%d'
|
||||
case 'bool': return '%d'
|
||||
case 'u32': return '%d'
|
||||
case 'float': return '%f'
|
||||
case 'double', 'f64': return '%f'
|
||||
case 'double', 'f64', 'f32': return '%f'
|
||||
case 'i64': return '%lld'
|
||||
case 'byte*': return '%s'
|
||||
// case 'array_string': return '%s'
|
||||
@ -3133,30 +3125,34 @@ fn is_compile_time_const(s string) bool {
|
||||
|
||||
// fmt helpers
|
||||
fn (scanner mut Scanner) fgen(s string) {
|
||||
/*
|
||||
if scanner.fmt_line_empty {
|
||||
s = repeat_char(`\t`, scanner.fmt_indent) + s
|
||||
}
|
||||
scanner.fmt_out.write(s)
|
||||
scanner.fmt_line_empty = false
|
||||
*/
|
||||
}
|
||||
|
||||
fn (scanner mut Scanner) fgenln(s string) {
|
||||
/*
|
||||
if scanner.fmt_line_empty {
|
||||
s = repeat_char(`\t`, scanner.fmt_indent) + s
|
||||
}
|
||||
scanner.fmt_out.writeln(s)
|
||||
scanner.fmt_line_empty = true
|
||||
*/
|
||||
}
|
||||
|
||||
fn (p mut Parser) fgen(s string) {
|
||||
p.scanner.fgen(s)
|
||||
//p.scanner.fgen(s)
|
||||
}
|
||||
|
||||
fn (p mut Parser) fspace() {
|
||||
p.fgen(' ')
|
||||
//p.fgen(' ')
|
||||
}
|
||||
|
||||
fn (p mut Parser) fgenln(s string) {
|
||||
p.scanner.fgenln(s)
|
||||
//p.scanner.fgenln(s)
|
||||
}
|
||||
|
||||
|
@ -97,8 +97,8 @@ fn (f Fn) str() string {
|
||||
// fn (types array_Type) print_to_file(f string) {
|
||||
// }
|
||||
const (
|
||||
NUMBER_TYPES = ['number', 'int', 'i8', 'u8', 'i16', 'u16', 'i32', 'u32', 'byte', 'i64', 'u64', 'long', 'double', 'float', 'f32', 'f64']
|
||||
FLOAT_TYPES = ['double', 'float', 'f32', 'f64']
|
||||
NUMBER_TYPES = ['number', 'int', 'i8', 'u8', 'i16', 'u16', 'i32', 'u32', 'byte', 'i64', 'u64', 'long', 'double', 'f32', 'f64']
|
||||
FLOAT_TYPES = ['double', 'f32', 'f64']
|
||||
)
|
||||
|
||||
fn is_number_type(typ string) bool {
|
||||
@ -130,7 +130,6 @@ fn new_table(obfuscate bool) *Table {
|
||||
t.register_type('byteptr')
|
||||
t.register_type('intptr')
|
||||
t.register_type('double')// TODO remove
|
||||
t.register_type('float')// TODO remove
|
||||
t.register_type('f32')
|
||||
t.register_type('f64')
|
||||
t.register_type('rune')
|
||||
@ -421,16 +420,16 @@ fn (p mut Parser) _check_types(got, expected string, throw bool) bool {
|
||||
return true
|
||||
}
|
||||
// Allow ints to be used as floats
|
||||
if got.eq('int') && expected.eq('float') {
|
||||
if got == 'int' && expected == 'f32' {
|
||||
return true
|
||||
}
|
||||
if got.eq('int') && expected.eq('f64') {
|
||||
if got == 'int' && expected == 'f64' {
|
||||
return true
|
||||
}
|
||||
if got == 'f64' && expected == 'float' {
|
||||
if got == 'f64' && expected == 'f32' {
|
||||
return true
|
||||
}
|
||||
if got == 'float' && expected == 'f64' {
|
||||
if got == 'f32' && expected == 'f64' {
|
||||
return true
|
||||
}
|
||||
// Allow ints to be used as longs
|
||||
|
@ -10,7 +10,6 @@ enum Token {
|
||||
INT
|
||||
STRING
|
||||
CHAR
|
||||
FLOAT
|
||||
PLUS
|
||||
MINUS
|
||||
MUL
|
||||
@ -129,7 +128,6 @@ fn build_token_str() []string {
|
||||
s[INT] = 'INT'
|
||||
s[STRING] = 'STR'
|
||||
s[CHAR] = 'CHAR'
|
||||
s[FLOAT] = 'FLOAT'
|
||||
s[PLUS] = '+'
|
||||
s[MINUS] = '-'
|
||||
s[MUL] = '*'
|
||||
|
Reference in New Issue
Block a user