1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: remove remaining switch statements and show a warning

This commit is contained in:
Alexander Medvednikov
2019-10-24 19:19:03 +03:00
parent 753fe32793
commit 36eb1b77d0
8 changed files with 203 additions and 143 deletions

View File

@ -380,34 +380,33 @@ pub fn system(cmd string) int {
pub fn sigint_to_signal_name(si int) string {
// POSIX signals:
switch si {
case 1: return 'SIGHUP'
case 2: return 'SIGINT'
case 3: return 'SIGQUIT'
case 4: return 'SIGILL'
case 6: return 'SIGABRT'
case 8: return 'SIGFPE'
case 9: return 'SIGKILL'
case 11: return 'SIGSEGV'
case 13: return 'SIGPIPE'
case 14: return 'SIGALRM'
case 15: return 'SIGTERM'
match si {
1 {return 'SIGHUP'}
2 {return 'SIGINT'}
3 {return 'SIGQUIT'}
4 {return 'SIGILL'}
6 {return 'SIGABRT'}
8 {return 'SIGFPE'}
9 {return 'SIGKILL'}
11 {return 'SIGSEGV'}
13 {return 'SIGPIPE'}
14 {return 'SIGALRM'}
15 {return 'SIGTERM'}
}
///////////////////////////////////
$if linux {
// From `man 7 signal` on linux:
switch si {
case 30,10,16: return 'SIGUSR1'
case 31,12,17: return 'SIGUSR2'
case 20,17,18: return 'SIGCHLD'
case 19,18,25: return 'SIGCONT'
case 17,19,23: return 'SIGSTOP'
case 18,20,24: return 'SIGTSTP'
case 21,21,26: return 'SIGTTIN'
case 22,22,27: return 'SIGTTOU'
///////////////////////////////
case 5: return 'SIGTRAP'
case 7: return 'SIGBUS'
match si {
30,10,16{ return 'SIGUSR1'}
31,12,17{ return 'SIGUSR2'}
20,17,18{ return 'SIGCHLD'}
19,18,25{ return 'SIGCONT'}
17,19,23{ return 'SIGSTOP'}
18,20,24{ return 'SIGTSTP'}
21,21,26{ return 'SIGTTIN'}
22,22,27{ return 'SIGTTOU'}
///////////////////////////////
5{ return 'SIGTRAP'}
7{ return 'SIGBUS' }
}
}
return 'unknown'