From ff80e3a5fa05da5480dc0049b12202c494cd3f94 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 3 Dec 2019 16:09:37 +0300 Subject: [PATCH] i8 print test + $if mac => $if macos --- vlib/builtin/int_test.v | 10 ++++++++++ vlib/compiler/cgen.v | 1 + vlib/compiler/comptime.v | 3 +++ vlib/compiler/main.v | 5 +++-- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/vlib/builtin/int_test.v b/vlib/builtin/int_test.v index a2f955945f..ecf5d84844 100644 --- a/vlib/builtin/int_test.v +++ b/vlib/builtin/int_test.v @@ -75,6 +75,16 @@ fn test_and() { assert c[4] & 1 != 0 } +fn test_i8_print() { + b := i8(0) + println(b) + c := i16(7) + println(c) + d := u16(6) + println(d) + assert true +} + /* fn test_cmp() { assert 1 ≠ 2 diff --git a/vlib/compiler/cgen.v b/vlib/compiler/cgen.v index 0fb0c3a4ab..10757df406 100644 --- a/vlib/compiler/cgen.v +++ b/vlib/compiler/cgen.v @@ -289,6 +289,7 @@ fn os_name_to_ifdef(name string) string { match name { 'windows' { return '_WIN32' } 'mac' { return '__APPLE__' } + 'macos' { return '__APPLE__' } 'linux' { return '__linux__' } 'freebsd' { return '__FreeBSD__' } 'openbsd'{ return '__OpenBSD__' } diff --git a/vlib/compiler/comptime.v b/vlib/compiler/comptime.v index 323f6cc67c..a6946eae14 100644 --- a/vlib/compiler/comptime.v +++ b/vlib/compiler/comptime.v @@ -23,6 +23,9 @@ fn (p mut Parser) comp_time() { p.fspace() if name in supported_platforms { ifdef_name := os_name_to_ifdef(name) + if name == 'mac' { + p.warn('use `macos` instead of `mac`') + } if not { p.genln('#ifndef $ifdef_name') } diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index a9daccce7f..f9dad0736b 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -25,8 +25,8 @@ enum BuildMode { } const ( - supported_platforms = ['windows', 'mac', 'linux', 'freebsd', 'openbsd', - 'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku'] + supported_platforms = ['windows', 'mac', 'macos', 'linux', 'freebsd', + 'openbsd', 'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku'] ) enum OS { @@ -1141,6 +1141,7 @@ pub fn os_from_string(os string) OS { 'linux' { return .linux} 'windows' { return .windows} 'mac' { return .mac} + 'macos' { return .mac} 'freebsd' { return .freebsd} 'openbsd' { return .openbsd} 'netbsd' { return .netbsd}