mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
operator | not defined on bool
This commit is contained in:
parent
48c05b5a45
commit
3db4d66824
2
Makefile
2
Makefile
@ -15,7 +15,7 @@ ifdef WIN32
|
|||||||
$(CC) -std=gnu11 -DUNICODE -D_UNICODE -w -o v0.exe vc/v_win.c
|
$(CC) -std=gnu11 -DUNICODE -D_UNICODE -w -o v0.exe vc/v_win.c
|
||||||
./v0.exe -o v.exe compiler
|
./v0.exe -o v.exe compiler
|
||||||
else
|
else
|
||||||
$(CC) -std=gnu11 -w -o v vc/v.c -lm
|
$(CC) -std=gnu11 -o v vc/v.c -lm
|
||||||
endif
|
endif
|
||||||
rm -rf vc/
|
rm -rf vc/
|
||||||
@echo "V has been successfully built"
|
@echo "V has been successfully built"
|
||||||
|
@ -2052,7 +2052,6 @@ fn (p mut Parser) expression() string {
|
|||||||
println('expression() pass=$p.pass tok=')
|
println('expression() pass=$p.pass tok=')
|
||||||
p.print_tok()
|
p.print_tok()
|
||||||
}
|
}
|
||||||
p.cgen('/* expr start*/')
|
|
||||||
ph := p.cgen.add_placeholder()
|
ph := p.cgen.add_placeholder()
|
||||||
mut typ := p.term()
|
mut typ := p.term()
|
||||||
is_str := typ=='string'
|
is_str := typ=='string'
|
||||||
@ -2123,10 +2122,14 @@ fn (p mut Parser) expression() string {
|
|||||||
typ = p.dot(typ, ph)
|
typ = p.dot(typ, ph)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// + - |
|
// + - | ^
|
||||||
for p.tok == .plus || p.tok == .minus || p.tok == .pipe || p.tok == .amp || p.tok == .xor {
|
for p.tok == .plus || p.tok == .minus || p.tok == .pipe || p.tok == .amp ||
|
||||||
|
p.tok == .xor {
|
||||||
// for p.tok in [.plus, .minus, .pipe, .amp, .xor] {
|
// for p.tok in [.plus, .minus, .pipe, .amp, .xor] {
|
||||||
tok_op := p.tok
|
tok_op := p.tok
|
||||||
|
if typ == 'bool' {
|
||||||
|
p.error('operator ${p.tok.str()} not defined on bool ')
|
||||||
|
}
|
||||||
is_num := typ == 'void*' || typ == 'byte*' || is_number_type(typ)
|
is_num := typ == 'void*' || typ == 'byte*' || is_number_type(typ)
|
||||||
p.check_space(p.tok)
|
p.check_space(p.tok)
|
||||||
if is_str && tok_op == .plus && !p.is_js {
|
if is_str && tok_op == .plus && !p.is_js {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
- v ui for linux
|
- v ui for linux
|
||||||
- doom.v
|
- doom.v
|
||||||
+ tcc backend
|
+ tcc backend
|
||||||
- fix all c warnings with -pedantic
|
+ fix all c warnings with -pedantic
|
||||||
+ set up pvs
|
+ set up pvs
|
||||||
- ui/orm demo: a simple gui client for postgres/mysql/sqlite
|
- ui/orm demo: a simple gui client for postgres/mysql/sqlite
|
||||||
- ui demo: calculator
|
- ui demo: calculator
|
||||||
|
28
vlib/os/os.v
28
vlib/os/os.v
@ -457,12 +457,12 @@ pub fn filename(path string) string {
|
|||||||
// get_line returns a one-line string from stdin
|
// get_line returns a one-line string from stdin
|
||||||
pub fn get_line() string {
|
pub fn get_line() string {
|
||||||
str := get_raw_line()
|
str := get_raw_line()
|
||||||
$if windows {
|
$if windows {
|
||||||
return str.trim_right('\r\n')
|
return str.trim_right('\r\n')
|
||||||
}
|
}
|
||||||
$else {
|
$else {
|
||||||
return str.trim_right('\n')
|
return str.trim_right('\n')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_raw_line returns a one-line string from stdin along with '\n' if there is any
|
// get_raw_line returns a one-line string from stdin along with '\n' if there is any
|
||||||
@ -476,16 +476,13 @@ pub fn get_raw_line() string {
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
$else {
|
$else {
|
||||||
//u64 is used because C.getline needs a size_t as second argument
|
max := size_t(256)
|
||||||
//Otherwise, it would cause a valgrind warning and may be dangerous
|
buf := *char(malloc(int(max)))
|
||||||
//Malloc takes an int as argument so a cast has to be made
|
|
||||||
max := u64(256)
|
|
||||||
buf := malloc(int(max))
|
|
||||||
nr_chars := C.getline(&buf, &max, stdin)
|
nr_chars := C.getline(&buf, &max, stdin)
|
||||||
if nr_chars == 0 {
|
if nr_chars == 0 {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
return string(buf, nr_chars)
|
return string(byteptr(buf), nr_chars)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,6 +588,9 @@ fn on_segfault(f voidptr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn C.getpid() int
|
||||||
|
fn C.proc_pidpath (int, byteptr, int) int
|
||||||
|
|
||||||
pub fn executable() string {
|
pub fn executable() string {
|
||||||
$if linux {
|
$if linux {
|
||||||
mut result := malloc(MAX_PATH)
|
mut result := malloc(MAX_PATH)
|
||||||
@ -738,6 +738,10 @@ pub fn signal(signum int, handler voidptr) {
|
|||||||
C.signal(signum, handler)
|
C.signal(signum, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn C.fork() int
|
||||||
|
fn C.wait() int
|
||||||
|
|
||||||
pub fn fork() int {
|
pub fn fork() int {
|
||||||
$if !windows {
|
$if !windows {
|
||||||
pid := C.fork()
|
pid := C.fork()
|
||||||
|
@ -39,7 +39,7 @@ pub fn ls(path string) []string {
|
|||||||
if isnil(ent) {
|
if isnil(ent) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
name := tos_clone(ent.d_name)
|
name := tos_clone(byteptr(ent.d_name))
|
||||||
if name != '.' && name != '..' && name != '' {
|
if name != '.' && name != '..' && name != '' {
|
||||||
res << name
|
res << name
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ struct C.tm {
|
|||||||
tm_sec int
|
tm_sec int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn C.time(int) i64
|
||||||
|
|
||||||
pub fn now() Time {
|
pub fn now() Time {
|
||||||
t := C.time(0)
|
t := C.time(0)
|
||||||
mut now := &C.tm{!}
|
mut now := &C.tm{!}
|
||||||
|
Loading…
Reference in New Issue
Block a user