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.241 2001/02/25 13:37:50 grubba Exp $"); + RCSID("$Id: las.c,v 1.242 2001/03/03 00:22:44 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:3445:    yyerror("foreach(): No expression to loop over.");    } else {    if (!CAAR(n) || pike_types_le(CAAR(n)->type, void_type_string)) {    yyerror("foreach(): Looping over a void expression.");    } else {    if(CDAR(n) && CDAR(n)->token == ':')    {    /* Check the iterator type */    struct pike_type *iterator_type;    struct pike_type *foreach_call_type; -  MAKE_CONSTANT_SHARED_STRING(iterator_type, +  MAKE_CONSTANT_TYPE(iterator_type,    tOr5(tArray, tStr, tObj,    tMapping, tMultiset));    if (!pike_types_le(CAAR(n)->type, iterator_type)) {    if (!match_types(CAAR(n)->type, iterator_type)) {    yytype_error("Bad argument 1 to foreach()", iterator_type,    CAAR(n)->type, 0);       /* No use checking the index and value types if    * the iterator type is bad.    */
pike.git/src/las.c:3477:    push_type(T_MANY);    push_finished_type(CAAR(n)->type);    push_type(T_FUNCTION);       foreach_call_type = pop_type();       if (CADAR(n)) {    /* Check the index type */    struct pike_type *index_fun_type;    struct pike_type *index_type; -  MAKE_CONSTANT_SHARED_STRING(index_fun_type, +  MAKE_CONSTANT_TYPE(index_fun_type,    tOr4(tFunc(tOr(tArray, tStr), tZero),    tFunc(tMap(tSetvar(0, tMix),    tMix), tVar(0)),    tFunc(tSet(tSetvar(1, tMix)),    tVar(1)),    tFunc(tObj, tZero)));    index_type = check_call(foreach_call_type, index_fun_type, 0);    if (!index_type) {    /* Should not happen. */    yyerror("Bad iterator type for index in foreach().");
pike.git/src/las.c:3506:    }    }    free_type(index_type);    }    free_type(index_fun_type);    }    if (CDDAR(n)) {    /* Check the value type */    struct pike_type *value_fun_type;    struct pike_type *value_type; -  MAKE_CONSTANT_SHARED_STRING(value_fun_type, +  MAKE_CONSTANT_TYPE(value_fun_type,    tOr5(tFunc(tArr(tSetvar(0, tMix)),    tVar(0)),    tFunc(tStr, tZero),    tFunc(tMap(tMix,tSetvar(1, tMix)),    tVar(1)),    tFunc(tMultiset, tInt1),    tFunc(tObj, tZero)));    value_type = check_call(foreach_call_type, value_fun_type, 0);    if (!value_type) {    /* Should not happen. */
pike.git/src/las.c:3536:    }    }    free_type(value_type);    }    free_type(value_fun_type);    }    free_type(foreach_call_type);    } else {    /* Old-style foreach */    struct pike_type *array_zero; -  MAKE_CONSTANT_SHARED_STRING(array_zero, tArr(tZero)); +  MAKE_CONSTANT_TYPE(array_zero, tArr(tZero));       if (!pike_types_le(array_zero, CAAR(n)->type)) {    yyerror("Bad argument 1 to foreach().");    } else {    if ((lex.pragmas & ID_STRICT_TYPES) &&    !pike_types_le(CAAR(n)->type, array_type_string)) {    struct pike_string *t = describe_type(CAAR(n)->type);    yywarning("Argument 1 to foreach() is not always an array.");    yywarning("Got: %s", t->str);    free_string(t);
pike.git/src/las.c:3599:    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); +  MAKE_CONSTANT_TYPE(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. */    n->parent->node_info |= OPT_TYPE_NOT_FIXED;
pike.git/src/las.c:3640:    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)); +  MAKE_CONSTANT_TYPE(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))); +  MAKE_CONSTANT_TYPE(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) {    if (n->parent) {
pike.git/src/las.c:3997: Inside #if defined(SHARED_NODES) && !defined(IN_TPIKE)
   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)); +  MAKE_CONSTANT_TYPE(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);    return low_localopt(CAR(n), usage, switch_u, cont_u,    break_u, catch_u);    }    free_type(ref_type);    }    usage[CDR(n)->u.integer.a] = 0;    cdr = CDR(n);