deprecate `import module`
parent
211275ab49
commit
f91d527154
|
@ -3,13 +3,14 @@
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
module builtin
|
module builtin
|
||||||
|
|
||||||
import strings
|
import (
|
||||||
|
strings
|
||||||
|
)
|
||||||
|
|
||||||
pub struct array {
|
pub struct array {
|
||||||
pub:
|
pub:
|
||||||
// Using a void pointer allows to implement arrays without generics and without generating
|
data voidptr// Using a void pointer allows to implement arrays without generics and without generating
|
||||||
// extra code for every type.
|
// extra code for every type.
|
||||||
data voidptr
|
|
||||||
len int
|
len int
|
||||||
cap int
|
cap int
|
||||||
element_size int
|
element_size int
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
// Use of this source code is governed by an MIT license
|
// Use of this source code is governed by an MIT license
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
module builtin
|
module builtin
|
||||||
import strconv.ftoa
|
|
||||||
|
import (
|
||||||
|
strconv.ftoa
|
||||||
|
)
|
||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
// ----- f64 to string functions -----
|
// ----- f64 to string functions -----
|
||||||
|
|
||||||
// str return a f64 as string in scientific notation, auto display digits limit
|
// str return a f64 as string in scientific notation, auto display digits limit
|
||||||
[inline]
|
[inline]
|
||||||
pub fn (d f64) str() string {
|
pub fn (d f64) str() string {
|
||||||
|
@ -23,7 +24,7 @@ pub fn (x f64) strsci(digit_num int) string {
|
||||||
} else if n_digit > 17 {
|
} else if n_digit > 17 {
|
||||||
n_digit = 17
|
n_digit = 17
|
||||||
}
|
}
|
||||||
return ftoa.f64_to_str(x,n_digit)
|
return ftoa.f64_to_str(x, n_digit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// return a decimal notation of the input f64
|
// return a decimal notation of the input f64
|
||||||
|
@ -33,7 +34,6 @@ pub fn (x f64) strlong() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- f32 to string functions -----
|
// ----- f32 to string functions -----
|
||||||
|
|
||||||
// str return a f32 as string in scientific notation, auto display digits limit
|
// str return a f32 as string in scientific notation, auto display digits limit
|
||||||
[inline]
|
[inline]
|
||||||
pub fn (d f32) str() string {
|
pub fn (d f32) str() string {
|
||||||
|
@ -49,7 +49,7 @@ pub fn (x f32) strsci(digit_num int) string {
|
||||||
} else if n_digit > 8 {
|
} else if n_digit > 8 {
|
||||||
n_digit = 8
|
n_digit = 8
|
||||||
}
|
}
|
||||||
return ftoa.f32_to_str(x,n_digit)
|
return ftoa.f32_to_str(x, n_digit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// return a decimal notation of the input f32
|
// return a decimal notation of the input f32
|
||||||
|
@ -59,20 +59,26 @@ pub fn (x f32) strlong() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- C functions -----
|
// ----- C functions -----
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
fn f32_abs(a f32) f32 {
|
fn f32_abs(a f32) f32 {
|
||||||
return if a < 0 { -a } else { a }
|
return if a < 0 {
|
||||||
|
-a
|
||||||
|
} else {
|
||||||
|
a
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
fn f64_abs(a f64) f64 {
|
fn f64_abs(a f64) f64 {
|
||||||
return if a < 0 { -a } else { a }
|
return if a < 0 {
|
||||||
|
-a
|
||||||
|
} else {
|
||||||
|
a
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare floats using C epsilon
|
// compare floats using C epsilon
|
||||||
// ==
|
// ==
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn (a f64) eq(b f64) bool {
|
pub fn (a f64) eq(b f64) bool {
|
||||||
return f64_abs(a - b) <= C.DBL_EPSILON
|
return f64_abs(a - b) <= C.DBL_EPSILON
|
||||||
|
@ -175,4 +181,3 @@ fn (a f64) gebit(b f64) bool {
|
||||||
fn (a f32) gebit(b f32) bool {
|
fn (a f32) gebit(b f32) bool {
|
||||||
return C.DEFAULT_GE(a, b)
|
return C.DEFAULT_GE(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1496,6 +1496,7 @@ fn (p mut Parser) import_stmt() []ast.Import {
|
||||||
}
|
}
|
||||||
p.check(.rpar)
|
p.check(.rpar)
|
||||||
} else {
|
} else {
|
||||||
|
p.warn('`import module` has been deprecated, use `import ( module )` instead')
|
||||||
imports << p.parse_import()
|
imports << p.parse_import()
|
||||||
}
|
}
|
||||||
return imports
|
return imports
|
||||||
|
|
Loading…
Reference in New Issue