pike.git / src / las.c

version» Context lines:

pike.git/src/las.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: las.c,v 1.236 2001/02/21 20:21:42 grubba Exp $"); + RCSID("$Id: las.c,v 1.237 2001/02/23 14:46:21 grubba Exp $");      #include "language.h"   #include "interpret.h"   #include "las.h"   #include "array.h"   #include "object.h"   #include "stralloc.h"   #include "dynamic_buffer.h"   #include "lex.h"   #include "pike_types.h"
pike.git/src/las.c:245:    return 0;    else    return count_args(CAR(n));       case F_SOFT_CAST:    return count_args(CAR(n));       case F_CASE:    case F_FOR:    case F_DO: +  case F_LOOP:    case F_INC_LOOP:    case F_DEC_LOOP:    case F_DEC_NEQ_LOOP:    case F_INC_NEQ_LOOP:    case F_BREAK:    case F_RETURN:    case F_CONTINUE:    case F_FOREACH:    return 0;   
pike.git/src/las.c:347:    return b;   }      int check_tailrecursion(void)   {    int e;    if(debug_options & NO_TAILRECURSION) return 0;    for(e=0;e<Pike_compiler->compiler_frame->max_number_of_locals;e++)    {    if(!pike_type_allow_premature_toss( -  Pike_compiler->compiler_frame->variable[e].type->str)) +  Pike_compiler->compiler_frame->variable[e].type))    return 0;    }    return 1;   }         #define NODES 128 /* 256 */      #undef BLOCK_ALLOC_NEXT   #define BLOCK_ALLOC_NEXT u.node.a
pike.git/src/las.c:1943:    {    case F_CONSTANT: return IS_ZERO(& n->u.sval);    default: return 0;    }   }      int node_may_overload(node *n, int lfun)   {    if(!n) return 0;    if(!n->type) return 1; -  return type_may_overload(n->type->str, lfun); +  return type_may_overload(n->type, lfun);   }      /* FIXME: Ought to use parent pointer to avoid recursion. */   node **last_cmd(node **a)   {    node **n;    if(!a || !*a) return (node **)NULL;       fatal_check_c_stack(16384);   
pike.git/src/las.c:2523:    a=copy_vars(p);    find_used_variables(CADR(n),a,noblock,0);    find_used_variables(CDDR(n),p,noblock,0);    do_and_vars(p, a);    break;       case F_INC_NEQ_LOOP:    case F_DEC_NEQ_LOOP:    case F_INC_LOOP:    case F_DEC_LOOP: +  case F_LOOP:    case F_FOREACH:    case F_FOR:    find_used_variables(CAR(n),p,noblock,0);    a=copy_vars(p);    find_used_variables(CDR(n),a,noblock,0);    do_and_vars(p, a);    break;       case F_SWITCH:    find_used_variables(CAR(n),p,noblock,0);
pike.git/src/las.c:2839:    if(!n) return 0;    switch(n->token)    {    case F_CAST:    case F_SOFT_CAST:    case F_APPLY:    return n->type != void_type_string;       case F_POP_VALUE:    case F_FOREACH: +  case F_LOOP:    case F_INC_NEQ_LOOP:    case F_DEC_NEQ_LOOP:    case F_INC_LOOP:    case F_DEC_LOOP: return 0;       case F_COMMA_EXPR:    case F_VAL_LVAL:    case F_LVALUE_LIST:    case F_ARG_LIST:   
pike.git/src/las.c:2930:    yywarning("%s", msg);    else    my_yyerror("%s", msg);    }       yyexplain_nonmatching_types(expected_t, got_t, flags);   }      void fix_type_field(node *n)   { -  struct pike_type *type_a,*type_b; +  struct pike_type *type_a, *type_b;    struct pike_type *old_type;       if (n->type && !(n->node_info & OPT_TYPE_NOT_FIXED))    return; /* assume it is correct */       old_type = n->type;    n->type = 0;    n->node_info &= ~OPT_TYPE_NOT_FIXED;       switch(n->token)
pike.git/src/las.c:2970:    copy_type(n->type, old_type);    break;       case F_LAND:    case F_LOR:    if (!CAR(n) || CAR(n)->type == void_type_string) {    yyerror("Conditional uses void expression.");    copy_type(n->type, mixed_type_string);    break;    } -  if(!match_types(CAR(n)->type,mixed_type_string)) +  if(!match_types(CAR(n)->type, mixed_type_string))    yyerror("Bad conditional expression.");       if (!CDR(n) || CDR(n)->type == void_type_string) -  copy_type(n->type,void_type_string); +  copy_type(n->type, void_type_string);    else if(n->token == F_LAND || CAR(n)->type == CDR(n)->type)    { -  copy_type(n->type,CDR(n)->type); +  copy_type(n->type, CDR(n)->type);    }else{    n->type = or_pike_types(CAR(n)->type, CDR(n)->type, 0);    }    break;       case F_ASSIGN:    if (!CAR(n) || (CAR(n)->type == void_type_string)) {    my_yyerror("Assigning a void expression.");    copy_type(n->type, void_type_string);    break;
pike.git/src/las.c:3185:    /* print_tree(n); */       free_type(s);    }    copy_type(n->type, mixed_type_string);    break;       case '?':    if (!CAR(n) || (CAR(n)->type == void_type_string)) {    yyerror("Conditional expression is void."); -  } else if(!match_types(CAR(n)->type,mixed_type_string)) +  } else if(!match_types(CAR(n)->type, mixed_type_string))    yyerror("Bad conditional expression.");       if(!CDR(n) || !CADR(n) || !CDDR(n) ||    CADR(n)->type == void_type_string ||    CDDR(n)->type == void_type_string)    {    copy_type(n->type, void_type_string);    break;    }   
pike.git/src/las.c:3347:    Pike_compiler->compiler_frame->current_return_type==void_type_string &&    CAR(n)->token == F_CONSTANT &&    IS_ZERO(& CAR(n)->u.sval)    )    ) {    if (!match_types(Pike_compiler->compiler_frame->current_return_type,    CAR(n)->type))    {    yyerror("Wrong return type.");    yyexplain_nonmatching_types(Pike_compiler->compiler_frame->current_return_type, -  CAR(n)->type,0); +  CAR(n)->type, 0);    }    else if (lex.pragmas & ID_STRICT_TYPES)    {    yytype_error("Return type mismatch.",    Pike_compiler->compiler_frame->current_return_type,    CAR(n)->type,    YYTE_IS_WARNING);    }    }    }
pike.git/src/las.c:3394:    CDR(n)->type, CAR(n)->type, YYTE_IS_WARNING);    }    }    }    }    /* FALL_THROUGH */    case F_INC_LOOP:    case F_DEC_LOOP:    case F_DEC_NEQ_LOOP:    case F_INC_NEQ_LOOP: +  case F_LOOP:    case F_CONTINUE:    case F_BREAK:    case F_DEFAULT:    case F_POP_VALUE:    copy_type(n->type, void_type_string);    break;       case F_DO:    if (!CDR(n) || (CDR(n)->type == void_type_string)) {    yyerror("do - while(): Conditional expression is void."); -  } else if(!match_types(CDR(n)->type,mixed_type_string)) +  } else if(!match_types(CDR(n)->type, mixed_type_string))    yyerror("Bad conditional expression do - while().");    copy_type(n->type, void_type_string);    break;       case F_FOR:    if (!CAR(n) || (CAR(n)->type == void_type_string)) {    yyerror("for(): Conditional expression is void."); -  } else if(!match_types(CAR(n)->type,mixed_type_string)) +  } else if(!match_types(CAR(n)->type, mixed_type_string))    yyerror("Bad conditional expression for().");    copy_type(n->type, void_type_string);    break;       case F_SWITCH:    if (!CAR(n) || (CAR(n)->type == void_type_string)) {    yyerror("switch(): Conditional expression is void."); -  } else if(!match_types(CAR(n)->type,mixed_type_string)) +  } else if(!match_types(CAR(n)->type, mixed_type_string))    yyerror("Bad switch expression.");    copy_type(n->type, void_type_string);    break;       case F_CONSTANT:    n->type = get_type_of_svalue(& n->u.sval);    break;       case F_FOREACH:    if (!CAR(n) || (CAR(n)->token != F_VAL_LVAL)) {
pike.git/src/las.c:3497:    if (!pike_types_le(CDAR(n)->type, string_type_string)) {    if (!match_types(CDAR(n)->type, string_type_string)) {    yytype_error("Bad argument 2 to sscanf().",    string_type_string, CDAR(n)->type, 0);    } else if (lex.pragmas & ID_STRICT_TYPES) {    yytype_error("Argument 2 to sscanf() has bad type.",    string_type_string, CDAR(n)->type, YYTE_IS_WARNING);    }    }    } +  /* FIXME: */    MAKE_CONSTANT_SHARED_STRING(n->type, tIntPos);    break;       case F_UNDEFINED:    copy_type(n->type, zero_type_string);    break;       case F_ARG_LIST:    if (n->parent) {    /* Propagate the changed type all the way up to the apply node. */
pike.git/src/las.c:3520:    case F_COMMA_EXPR:    if(!CAR(n) || CAR(n)->type==void_type_string)    {    if(CDR(n))    copy_type(n->type, CDR(n)->type);    else    copy_type(n->type, void_type_string);    break;    }    -  if(!CDR(n) || CDR(n)->type==void_type_string) +  if(!CDR(n) || CDR(n)->type == void_type_string)    {    if(CAR(n))    copy_type(n->type, CAR(n)->type);    else    copy_type(n->type, void_type_string);    break;    }    if (n->token == F_ARG_LIST) {    n->type = or_pike_types(CAR(n)->type, CDR(n)->type, 0);    } else {    copy_type(n->type, CDR(n)->type);    }    break;       case F_MAGIC_INDEX:    /* FIXME: Could have a stricter type for ::`->(). */ -  +  /* FIXME: */    MAKE_CONSTANT_SHARED_STRING(n->type, tFunc(tMix,tMix));    break;    case F_MAGIC_SET_INDEX:    /* FIXME: Could have a stricter type for ::`->=(). */ -  +  /* FIXME: */    MAKE_CONSTANT_SHARED_STRING(n->type, tFunc(tMix tSetvar(0,tMix), tVar(0)));    break;       case F_CATCH:    /* FALL_THROUGH */    default:    copy_type(n->type, mixed_type_string);    }       if (n->type != old_type) {
pike.git/src/las.c:3886: Inside #if defined(SHARED_NODES) && !defined(IN_TPIKE)
   const unsigned char *cont_u,    const unsigned char *break_u,    const unsigned char *catch_u)   {    node *car, *cdr;       if (!n)    return NULL;       switch(n->token) { +  /* FIXME: Does not support F_LOOP yet. */    case F_ASSIGN:    if ((CDR(n)->token == F_LOCAL) && (!CDR(n)->u.integer.b)) {    /* Assignment of local variable */    if (!(usage[CDR(n)->u.integer.a] & 1)) {    /* Value isn't used. */    struct pike_type *ref_type;    MAKE_CONSTANT_SHARED_STRING(ref_type, tOr(tComplex, tString));    if (!match_types(CDR(n)->type, ref_type)) {    /* The variable doesn't hold a refcounted value. */    free_type(ref_type);
pike.git/src/las.c:4767:    }   }      /* FIXME: Ought to use parent pointer to avoid recursion. */   static int is_null_branch(node *n)   {    if(!n) return 1;       fatal_check_c_stack(16384);    -  if((n->token==F_CAST && n->type==void_type_string) || +  if((n->token==F_CAST && n->type == void_type_string) ||    n->token == F_POP_VALUE)    return is_null_branch(CAR(n));    if(n->token==F_ARG_LIST)    return is_null_branch(CAR(n)) && is_null_branch(CDR(n));    return 0;   }      static struct svalue *is_stupid_func(node *n,    int args,    int vargs,
pike.git/src/las.c:4795:       if(n->token == F_ARG_LIST)    {    if(is_null_branch(CAR(n)))    n=CDR(n);    else    n=CAR(n);    continue;    }    -  if((n->token == F_CAST && n->type==void_type_string) || +  if((n->token == F_CAST && n->type == void_type_string) ||    n->token == F_POP_VALUE)    {    n=CAR(n);    continue;    }    break;    }       if(!n || n->token != F_RETURN) return 0;    n=CAR(n);