pike.git / src / las.c

version» Context lines:

pike.git/src/las.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: las.c,v 1.346 2004/05/29 18:13:41 grubba Exp $ + || $Id: las.c,v 1.347 2004/06/30 00:19:27 nilsson Exp $   */      #include "global.h" - RCSID("$Id: las.c,v 1.346 2004/05/29 18:13:41 grubba Exp $"); + RCSID("$Id: las.c,v 1.347 2004/06/30 00:19:27 nilsson Exp $");      #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"   #include "constants.h"
pike.git/src/las.c:1516:   #endif /* PIKE_DEBUG */       if (Pike_compiler->compiler_pass == 2) {    if (type == void_type_string) {    yywarning("Soft cast to void.");    return mknode(F_POP_VALUE, n, 0);    }       if(type==n->type) {    struct pike_string *t1 = describe_type(type); -  yywarning("Soft cast to %s is a noop.", t1->str); +  yywarning("Soft cast to %S is a noop.", t1);    free_string(t1);    return n;    }       if (n->type) {    if (!check_soft_cast(type, n->type)) {    struct pike_string *t1 = describe_type(type);    struct pike_string *t2 = describe_type(n->type); -  yywarning("Soft cast to %s isn't a restriction of %s.", -  t1->str, t2->str); +  yywarning("Soft cast to %S isn't a restriction of %S.", +  t1, t2);    free_string(t2);    free_string(t1);    }    /* FIXME: check_soft_cast() is weaker than pike_types_le()    * The resulting type should probably be the and between the old    * and the new type.    */    }    }   
pike.git/src/las.c:1619:    case F_UNDEFINED:    if(Pike_compiler->compiler_pass==2) {    /* FIXME: Ought to have the name of the identifier in the message. */    yyerror("Expected constant, got undefined identifier");    }    push_int(0);    return;       default:    { -  char fnord[1000]; +     if(is_const(n))    {    ptrdiff_t args=eval_low(n,1);    if(args==1) return;       if(args!=-1)    {    if(!args)    {    yyerror("Expected constant, got void expression");    }else{    yyerror("Possible internal error!!!");    pop_n_elems(DO_NOT_WARN(args-1));    return;    }    }    }    -  sprintf(fnord,"Expected constant, got something else (%d)",n->token); -  yyerror(fnord); +  my_yyerror("Expected constant, got something else (%d)",n->token);    push_int(0);    return;    }    }       i=ID_FROM_INT(p, numid);       /* Warning:    * This code doesn't produce function pointers for class constants,    * which can be harmful...
pike.git/src/las.c:1663:    {    if(i->func.offset != -1)    {    push_svalue(&PROG_FROM_INT(p, numid)->constants[i->func.offset].sval);    }else{    if(Pike_compiler->compiler_pass!=1)    yyerror("Constant is not defined yet.");    push_int(0);    }    }else{ -  my_yyerror("Identifier '%s' is not a constant", i->name->str); +  my_yyerror("Identifier %S is not a constant", i->name);    push_int(0);    }    }   }      /* Leaves a function or object on the stack */   void resolv_class(node *n)   {    check_tree(n,0);   
pike.git/src/las.c:1839:    } else {    handle_compile_exception ("Couldn't index module.");    }    }else{    resolv_constant(n);    switch(Pike_sp[-1].type)    {    case T_INT:    if(!Pike_compiler->num_parse_error) {    if (node_name) { -  my_yyerror("Failed to index module '%s' with '%s' " +  my_yyerror("Failed to index module \"%s\" with %S "    "(module doesn't exist?)", -  node_name, id->str); +  node_name, id);    } else { -  my_yyerror("Failed to index module with '%s' " +  my_yyerror("Failed to index module with %S "    "(module doesn't exist?)", -  id->str); +  id);    }    }    break;       case T_FLOAT:    case T_STRING:    case T_ARRAY:    if (node_name) {    my_yyerror("Failed to index module '%s' (Not a module?)",    node_name);
pike.git/src/las.c:1896:    }    }       default:    {    ptrdiff_t c;    DECLARE_CYCLIC();    c = PTR_TO_INT(BEGIN_CYCLIC(Pike_sp[-1].u.refs, id));    if(c>1)    { -  my_yyerror("Recursive module dependency in '%s'.",id->str); +  my_yyerror("Recursive module dependency in %S.", id);    pop_stack();    push_int(0);    }else{    int exception = 0;    SET_CYCLIC_RET(c+1);    ref_push_string(id);    {    JMP_BUF recovery;    STACK_LEVEL_START(2);    if (SETJMP_SP(recovery, 2)) {
pike.git/src/las.c:1930:    }       if(Pike_sp[-1].type == T_INT &&    !Pike_sp[-1].u.integer &&    Pike_sp[-1].subtype==NUMBER_UNDEFINED)    {    if(Pike_compiler->new_program->flags & PROGRAM_PASS_1_DONE)    {    if (!exception) {    if (node_name) { -  my_yyerror("Index '%s' not present in module '%s'.", -  id->str, node_name); +  my_yyerror("Index %S not present in module \"%s\".", +  id, node_name);    } else { -  my_yyerror("Index '%s' not present in module.", id->str); +  my_yyerror("Index %S not present in module.", id);    }    }    }else if (!(Pike_compiler->flags & COMPILATION_FORCE_RESOLVE)) {    /* Hope it's there in pass 2 */    pop_stack();   #if 0    fprintf(stderr, "Placeholder deployed when indexing ");    print_tree(n);    fprintf(stderr, "with %s\n", id->str);   #endif
pike.git/src/las.c:1958:    else if ((Pike_compiler->new_program->flags & PROGRAM_PASS_1_DONE) &&    ((Pike_sp[-1].type == T_OBJECT &&    Pike_sp[-1].u.object == placeholder_object) ||    (Pike_sp[-1].type == T_PROGRAM &&    Pike_sp[-1].u.program == placeholder_program)) &&    /* Ugly special case: We must be able to get    * predef::__placeholder_object. */    (!node_name || strcmp (node_name, "predef"))) {    if (node_name)    my_yyerror("Got placeholder %s (resolver problem) " -  "when indexing module '%s' with '%s'.", +  "when indexing module \"%s\" with %S.",    get_name_of_type (Pike_sp[-1].type), -  node_name, id->str); +  node_name, id);    else    my_yyerror("Got placeholder %s (resolver problem) " -  "when indexing a module with '%s'.", +  "when indexing a module with %S.",    get_name_of_type (Pike_sp[-1].type), -  id->str); +  id);    }    }    END_CYCLIC();    }    }    }    UNSETJMP(tmp);    ret=mkconstantsvaluenode(Pike_sp-1);    pop_stack();    return ret;
pike.git/src/las.c:3512:    n->type = 0;    n->node_info &= ~OPT_TYPE_NOT_FIXED;       switch(n->token)    {    case F_SOFT_CAST:    if (CAR(n) && CAR(n)->type) {    if (!check_soft_cast(old_type, CAR(n)->type)) {    struct pike_string *t1 = describe_type(old_type);    struct pike_string *t2 = describe_type(CAR(n)->type); -  yywarning("Soft cast to %s isn't a restriction of %s.", -  t1->str, t2->str); +  yywarning("Soft cast to %S isn't a restriction of %S.", +  t1, t2);    free_string(t2);    free_string(t1);    }    /* FIXME: check_soft_cast() is weaker than pike_types_le()    * The resulting type should probably be the AND between the old    * and the new type.    */    }    /* FALL_THROUGH */    case F_CAST:
pike.git/src/las.c:3574:    CDR(n)->type, CAR(n)->type, 0);    } else if (lex.pragmas & ID_STRICT_TYPES) {    struct pike_string *t1 = describe_type(CAR(n)->type);    struct pike_string *t2 = describe_type(CDR(n)->type);   #ifdef PIKE_DEBUG    if (l_flag > 0) {    fprintf(stderr, "Warning: Invalid assignment: ");    print_tree(n);    }   #endif /* PIKE_DEBUG */ -  yywarning("An expression type %s cannot be assigned to " -  "a variable of type %s.", -  t1->str, t2->str); +  yywarning("An expression type %S cannot be assigned to " +  "a variable of type %S.", t1, t2);    free_string(t2);    free_string(t1);    }    }    }    n->type = and_pike_types(CAR(n)->type, CDR(n)->type);    break;       case F_ARRAY_LVALUE:    {
pike.git/src/las.c:3959:    MAKE_CONST_STRING(op_string, "`%");    break;    case F_DIV_EQ:    MAKE_CONST_STRING(op_string, "`/");    break;    default:    Pike_fatal("fix_type_field(): Unhandled token: %d\n", n->token);    break;    }    if (!(op_node = find_module_identifier(op_string, 0))) { -  my_yyerror("Internally used efun undefined for token %d: %s()", -  n->token, op_string->str); +  my_yyerror("Internally used efun undefined for token %d: %S", +  n->token, op_string);    copy_pike_type(n->type, mixed_type_string);    break;    }    if (!op_node->type) {    fix_type_field(op_node);    }       push_finished_type(CAR(n)->type);    push_type(T_VOID);    push_type(T_MANY);
pike.git/src/las.c:3988:    n->type = check_call(call_type,    op_node->type ? op_node->type : mixed_type_string,    (lex.pragmas & ID_STRICT_TYPES) &&    !(op_node->node_info & OPT_WEAK_TYPE));    if (n->type) {    /* Type check ok. */    free_node(op_node);    free_type(call_type);    break;    } -  my_yyerror("Bad arguments to %s=().", op_string->str); +  my_yyerror("Bad arguments to %S.", op_string);    yytype_error(NULL, op_node->type ? op_node->type : mixed_type_string,    call_type, 0);    free_node(op_node);    free_type(call_type);    }    copy_pike_type(n->type, mixed_type_string);    break;       case F_INC:    case F_DEC:
pike.git/src/las.c:4242:    struct pike_type *array_zero;    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); +  yywarning("Got: %S", t);    free_string(t);    }       if (!CDAR(n) || pike_types_le(CDAR(n)->type, void_type_string)) {    yyerror("Bad argument 2 to foreach().");    } else {    struct pike_type *value_type = array_value_type(CAAR(n)->type);       if (!pike_types_le(value_type, CDAR(n)->type)) {    if (!match_types(value_type, CDAR(n)->type)) {