381 sym = get_base_type(sym);
382 if (!sym || sym->type != SYM_FN)
383 return 0;
384 sym = get_base_type(sym);
385 return type_unsigned(sym);
386 }
387
388 int is_pointer(struct expression *expr)
389 {
390 return type_is_ptr(get_type(expr));
391 }
392
393 int returns_pointer(struct symbol *sym)
394 {
395 if (!sym)
396 return 0;
397 sym = get_base_type(sym);
398 if (!sym || sym->type != SYM_FN)
399 return 0;
400 sym = get_base_type(sym);
401 if (sym->type == SYM_PTR)
402 return 1;
403 return 0;
404 }
405
406 sval_t sval_type_max(struct symbol *base_type)
407 {
408 sval_t ret;
409
410 if (!base_type || !type_bits(base_type))
411 base_type = &llong_ctype;
412 ret.type = base_type;
413
414 ret.value = (~0ULL) >> (64 - type_positive_bits(base_type));
415 return ret;
416 }
417
418 sval_t sval_type_min(struct symbol *base_type)
419 {
420 sval_t ret;
421
479 return 0;
480 }
481
482 int is_static(struct expression *expr)
483 {
484 char *name;
485 struct symbol *sym;
486 int ret = 0;
487
488 name = expr_to_str_sym(expr, &sym);
489 if (!name || !sym)
490 goto free;
491
492 if (sym->ctype.modifiers & MOD_STATIC)
493 ret = 1;
494 free:
495 free_string(name);
496 return ret;
497 }
498
499 int is_local_variable(struct expression *expr)
500 {
501 struct symbol *sym;
502 char *name;
503
504 name = expr_to_var_sym(expr, &sym);
505 free_string(name);
506 if (!sym || !sym->scope || !sym->scope->token || !cur_func_sym)
507 return 0;
508 if (cmp_pos(sym->scope->token->pos, cur_func_sym->pos) < 0)
509 return 0;
510 if (is_static(expr))
511 return 0;
512 return 1;
513 }
514
515 int types_equiv(struct symbol *one, struct symbol *two)
516 {
517 if (!one && !two)
518 return 1;
519 if (!one || !two)
520 return 0;
521 if (one->type != two->type)
522 return 0;
523 if (one->type == SYM_PTR)
524 return types_equiv(get_real_base_type(one), get_real_base_type(two));
525 if (type_positive_bits(one) != type_positive_bits(two))
526 return 0;
527 return 1;
528 }
529
530 int fn_static(void)
531 {
532 return !!(cur_func_sym->ctype.modifiers & MOD_STATIC);
|
381 sym = get_base_type(sym);
382 if (!sym || sym->type != SYM_FN)
383 return 0;
384 sym = get_base_type(sym);
385 return type_unsigned(sym);
386 }
387
388 int is_pointer(struct expression *expr)
389 {
390 return type_is_ptr(get_type(expr));
391 }
392
393 int returns_pointer(struct symbol *sym)
394 {
395 if (!sym)
396 return 0;
397 sym = get_base_type(sym);
398 if (!sym || sym->type != SYM_FN)
399 return 0;
400 sym = get_base_type(sym);
401 if (sym && sym->type == SYM_PTR)
402 return 1;
403 return 0;
404 }
405
406 sval_t sval_type_max(struct symbol *base_type)
407 {
408 sval_t ret;
409
410 if (!base_type || !type_bits(base_type))
411 base_type = &llong_ctype;
412 ret.type = base_type;
413
414 ret.value = (~0ULL) >> (64 - type_positive_bits(base_type));
415 return ret;
416 }
417
418 sval_t sval_type_min(struct symbol *base_type)
419 {
420 sval_t ret;
421
479 return 0;
480 }
481
482 int is_static(struct expression *expr)
483 {
484 char *name;
485 struct symbol *sym;
486 int ret = 0;
487
488 name = expr_to_str_sym(expr, &sym);
489 if (!name || !sym)
490 goto free;
491
492 if (sym->ctype.modifiers & MOD_STATIC)
493 ret = 1;
494 free:
495 free_string(name);
496 return ret;
497 }
498
499 bool is_local_variable(struct expression *expr)
500 {
501 struct symbol *sym;
502
503 if (!expr || expr->type != EXPR_SYMBOL || !expr->symbol)
504 return false;
505 sym = expr->symbol;
506 if (!(sym->ctype.modifiers & MOD_TOPLEVEL))
507 return true;
508 return false;
509 }
510
511 int types_equiv(struct symbol *one, struct symbol *two)
512 {
513 if (!one && !two)
514 return 1;
515 if (!one || !two)
516 return 0;
517 if (one->type != two->type)
518 return 0;
519 if (one->type == SYM_PTR)
520 return types_equiv(get_real_base_type(one), get_real_base_type(two));
521 if (type_positive_bits(one) != type_positive_bits(two))
522 return 0;
523 return 1;
524 }
525
526 int fn_static(void)
527 {
528 return !!(cur_func_sym->ctype.modifiers & MOD_STATIC);
|