mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: remove math dependency
This commit is contained in:
parent
25ef0ee593
commit
67ae167013
@ -5,7 +5,7 @@
|
|||||||
module main
|
module main
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import math
|
//import math
|
||||||
import strings
|
import strings
|
||||||
|
|
||||||
struct Table {
|
struct Table {
|
||||||
@ -778,14 +778,14 @@ fn (table &Table) cgen_name_type_pair(name, typ string) string {
|
|||||||
fn is_valid_int_const(val, typ string) bool {
|
fn is_valid_int_const(val, typ string) bool {
|
||||||
x := val.int()
|
x := val.int()
|
||||||
switch typ {
|
switch typ {
|
||||||
case 'byte': return 0 <= x && x <= math.MaxU8
|
case 'byte': return 0 <= x && x <= 255
|
||||||
case 'u16': return 0 <= x && x <= math.MaxU16
|
case 'u16': return 0 <= x && x <= 65535
|
||||||
//case 'u32': return 0 <= x && x <= math.MaxU32
|
//case 'u32': return 0 <= x && x <= math.MaxU32
|
||||||
//case 'u64': return 0 <= x && x <= math.MaxU64
|
//case 'u64': return 0 <= x && x <= math.MaxU64
|
||||||
//////////////
|
//////////////
|
||||||
case 'i8': return math.MinI8 <= x && x <= math.MaxI8
|
case 'i8': return -128 <= x && x <= 127
|
||||||
case 'i16': return math.MinI16 <= x && x <= math.MaxI16
|
case 'i16': return -32768 <= x && x <= 32767
|
||||||
case 'int': return math.MinI32 <= x && x <= math.MaxI32
|
case 'int': return -2147483648 <= x && x <= 2147483647
|
||||||
//case 'i64':
|
//case 'i64':
|
||||||
//x64 := val.i64()
|
//x64 := val.i64()
|
||||||
//return i64(-(1<<63)) <= x64 && x64 <= i64((1<<63)-1)
|
//return i64(-(1<<63)) <= x64 && x64 <= i64((1<<63)-1)
|
||||||
|
Loading…
Reference in New Issue
Block a user