> compile NEMU

221220000 张三
Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
 18:05:05 up 11:21,  1 user,  load average: 0.54, 0.34, 0.20
This commit is contained in:
tracer-ics2023
2024-08-22 18:05:05 +08:00
committed by zzy
parent 7b7e787fe3
commit 67584a0fc7
4 changed files with 42 additions and 18 deletions

View File

@ -50,18 +50,23 @@ static int pos;
} \
} while(0)
static void _gen_rand_expr() {
static void _gen_rand_expr(int deepth) {
if (deepth == 0) {
GEN_RAND();
return;
}
deepth -= 1;
switch (choose(3)) {
case 0: GEN_RAND(); break;
case 1: GEN("("); _gen_rand_expr(); GEN(")"); break;
default: _gen_rand_expr(); GEN_OP(); _gen_rand_expr(); break;
case 1: GEN("("); _gen_rand_expr(deepth); GEN(")"); break;
default: _gen_rand_expr(deepth); GEN_OP(); _gen_rand_expr(deepth); break;
}
}
static void gen_rand_expr() {
buf[0] = '\0';
pos = 0;
_gen_rand_expr();
_gen_rand_expr(choose(10));
}
int main(int argc, char *argv[]) {