pike.git / src / las.c

version» Context lines:

pike.git/src/las.c:754:    return res;       case 3:    return mkefuncallnode("`[]",mknode(F_ARG_LIST,a,b));    }    break;       case F_ASSIGN:    case F_MULTI_ASSIGN:    case F_ASSIGN_SELF: -  if ((!a || a->token == F_CONSTANT) && (Pike_compiler->compiler_pass == 2)) { +  if ((!a || a->token == F_CONSTANT) && +  (Pike_compiler->compiler_pass == COMPILER_PASS_LAST)) {    yyerror("Illegal lvalue.");    }    break;   #ifdef PIKE_DEBUG    case F_CAST:    case F_SOFT_CAST:    Pike_fatal("Attempt to create a cast-node with mknode()!\n");    case F_CONSTANT:    Pike_fatal("Attempt to create an F_CONSTANT-node with mknode()!\n");    case F_LOCAL:
pike.git/src/las.c:1374:    struct pike_type *result_type = NULL;       if(!n) return 0;      #ifdef PIKE_DEBUG    if (!type) {    Pike_fatal("Soft cast to no type!\n");    }   #endif /* PIKE_DEBUG */    -  if (Pike_compiler->compiler_pass == 2 && type->type != PIKE_T_AUTO ) { +  if (Pike_compiler->compiler_pass == COMPILER_PASS_LAST && +  type->type != PIKE_T_AUTO ) {    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);    free_string(t1);    return n;
pike.git/src/las.c:1479:    push_int(0);    return;       case F_GLOBAL:    /* FIXME: Ought to have the name of the identifier in the message. */    yyerror("Expected constant, got global variable.");    push_int(0);    return;       case F_UNDEFINED: -  if(Pike_compiler->compiler_pass==2) { +  if(Pike_compiler->compiler_pass == COMPILER_PASS_LAST) {    /* FIXME: Ought to have the name of the identifier in the message. */    yyerror("Expected constant, got undefined identifier.");    }    push_int(0);    return;       default:    {    if(is_const(n))    {
pike.git/src/las.c:1543:    i = ID_FROM_INT(p, numid);    } while (IDENTIFIER_IS_ALIAS(i->identifier_flags));    }    if(IDENTIFIER_IS_CONSTANT(i->identifier_flags))    {    if(i->func.const_info.offset != -1)    {    push_svalue(&PROG_FROM_INT(p, numid)->    constants[i->func.const_info.offset].sval);    }else{ -  if(Pike_compiler->compiler_pass!=1) +  if(Pike_compiler->compiler_pass != COMPILER_PASS_FIRST)    yyerror("Constant is not defined yet.");    push_int(0);    }    } else {    my_yyerror("Identifier %S is not a constant", i->name);    push_int(0);    }    }   }   
pike.git/src/las.c:1573:    if(!Pike_sp[-1].u.object->prog)    {    pop_stack();    push_int(0);    }else{    o_cast(program_type_string, T_PROGRAM);    }    break;       default: -  if (Pike_compiler->compiler_pass!=1) +  if (Pike_compiler->compiler_pass != COMPILER_PASS_FIRST)    yyerror("Illegal program identifier");    pop_stack();    push_int(0);       case T_FUNCTION:    case T_PROGRAM:    break;    }   }      void resolv_type(node *n)   {    resolv_constant(n);    -  +  if (TYPEOF(Pike_sp[-1]) == T_STRING) { +  /* Program name, etc */ +  if (call_handle_inherit(n->u.sval.u.string)) { +  stack_swap(); +  pop_stack(); +  } +  } +     if (TYPEOF(Pike_sp[-1]) == T_TYPE) {    /* "typedef" */    push_finished_type(Pike_sp[-1].u.type);    } else {    /* object type */    struct program *p = NULL;       if (TYPEOF(Pike_sp[-1]) == T_OBJECT) {    if(!(p = Pike_sp[-1].u.object->prog))    {
pike.git/src/las.c:1612:    int f = FIND_LFUN(p->inherits[SUBTYPEOF(Pike_sp[-1])].prog,    LFUN_CALL);    if(f!=-1)    {    SET_SVAL_SUBTYPE(Pike_sp[-1],    f + p->inherits[SUBTYPEOF(Pike_sp[-1])].    identifier_level);    SET_SVAL_TYPE(Pike_sp[-1], T_FUNCTION);    }else{    extern void f_object_program(INT32); -  if (Pike_compiler->compiler_pass == 2) +  if (Pike_compiler->compiler_pass == COMPILER_PASS_LAST)    yywarning("Using object as program identifier.");    f_object_program(1);    }    }    }       switch(TYPEOF(Pike_sp[-1])) {    case T_FUNCTION:    if((p = program_from_function(Pike_sp-1))) { -  push_object_type(0, p?(p->id):0); +  push_object_type(0, p->id);    break;    } else {    /* Attempt to get the return type for the function. */    struct pike_type *a, *b;    a = get_type_of_svalue(Pike_sp-1);    /* Note: check_splice_call() below eats a reference from a.    * Note: CALL_INHIBIT_WARNINGS is needed since we don't    * provide a function name (and we don't want    * warnings here anyway).    */
pike.git/src/las.c:1648:    if (b) {    push_finished_type(b);    free_type(b);    break;    }    }    }    /* FALL_THROUGH */       default: -  if (Pike_compiler->compiler_pass!=1) +  if (Pike_compiler->compiler_pass == COMPILER_PASS_FIRST) { +  /* The type isn't fully known yet, so do an extra pass. */ +  struct compilation *c = THIS_COMPILATION; +  c->flags |= COMPILER_NEED_EXTRA_PASS; +  } else {    my_yyerror("Illegal program identifier: %O.", Pike_sp-1); -  pop_stack(); -  push_int(0); +  }    push_object_type(0, 0);    break;       case T_PROGRAM:    p = Pike_sp[-1].u.program; -  push_object_type(0, p?(p->id):0); +  push_object_type(0, p->id);    break;    }    } -  +  +  pop_stack();   }      node *index_node(node * const n, char *node_name, struct pike_string *id)   {    node *ret;    JMP_BUF tmp;       check_tree(n,0);       if (!is_const(n)) {    /* Index dynamically. */ -  if (Pike_compiler->compiler_pass == 2 && !(THIS_COMPILATION->lex.pragmas -  & ID_DYNAMIC_DOT)) +  if (Pike_compiler->compiler_pass == COMPILER_PASS_LAST && +  !(THIS_COMPILATION->lex.pragmas & ID_DYNAMIC_DOT))    {    yywarning("Using . to index dynamically.");    }    return mknode(F_INDEX, copy_node(n), mkstrnode(id));    }       if(SETJMP(tmp))    {    if (node_name) {    handle_compile_exception ("Couldn't index module %s.", node_name);
pike.git/src/las.c:1963:       case T_MULTISET:    return make_node_from_multiset(s->u.multiset);       case T_MAPPING:    return make_node_from_mapping(s->u.mapping);       case T_OBJECT:   #ifdef PIKE_DEBUG    if (s->u.object->prog == placeholder_program && -  Pike_compiler->compiler_pass == 2) +  Pike_compiler->compiler_pass == COMPILER_PASS_LAST)    Pike_fatal("Got placeholder object in second pass.\n");   #endif    if(s->u.object == Pike_compiler->fake_object)    {    return mkefuncallnode("this_object", 0);    }    if(s->u.object->next == s->u.object)    {    int x=0;    node *n=mkefuncallnode("this_object", 0);
pike.git/src/las.c:3864:    if (!(CDR(n)->type == zero_type_string) ||    !(pike_types_le(CAR(n)->type, int_type_string))) {    yytype_report(REPORT_WARNING,    NULL, 0, CAR(n)->type,    NULL, 0, CDR(n)->type,    0, "Type mismatch in case range.");    }    }    }    } -  if (CDR(n) && (Pike_compiler->compiler_pass == 2)) { +  if (CDR(n) && (Pike_compiler->compiler_pass == COMPILER_PASS_LAST)) {    fix_type_field(CDR(n));    if (!match_types(CDR(n)->type, enumerable_type_string)) {    yytype_report(REPORT_WARNING,    NULL, 0, enumerable_type_string,    NULL, 0, CDR(n)->type,    0, "Case value is not an enumerable type.");    }    }    /* FALL_THROUGH */    case F_CASE: -  if (CAR(n) && (Pike_compiler->compiler_pass == 2)) { +  if (CAR(n) && (Pike_compiler->compiler_pass == COMPILER_PASS_LAST)) {    fix_type_field(CAR(n));    if (!match_types(CAR(n)->type, enumerable_type_string)) {    yytype_report(REPORT_WARNING,    NULL, 0, enumerable_type_string,    NULL, 0, CAR(n)->type,    0, "Case value is not an enumerable type.");    }    }    /* FALL_THROUGH */    case F_INC_LOOP:
pike.git/src/las.c:4254:    n=n->parent;    }while(n);       c->lex.current_line = save_line;    c->lex.current_file = dmalloc_touch(struct pike_string *, save_file);   }      void optimize_node(node *n)   {    if(n && -  Pike_compiler->compiler_pass==2 && +  Pike_compiler->compiler_pass == COMPILER_PASS_LAST &&    (n->node_info & OPT_TRY_OPTIMIZE))    {    optimize(n);    check_tree(n,0);    }   }      struct timer_oflo   {    INT32 counter;
pike.git/src/las.c:4586:    CHECK_COMPILER();       optimize_node(n);       check_tree(n, 0);       if(   #ifdef PIKE_DEBUG    (a_flag > 1) ||   #endif -  (c->lex.pragmas & ID_DISASSEMBLE)) +  ((c->lex.pragmas & ID_DISASSEMBLE) && +  (Pike_compiler->compiler_pass == COMPILER_PASS_LAST)))    fprintf(stderr, "Doing function '%s' at %lx\n", name->str,    (unsigned long)PIKE_PC);       args=count_arguments(type); -  + #ifdef PIKE_DEBUG +  if((a_flag > 1) || (c->lex.pragmas & ID_DISASSEMBLE)) +  fprintf(stderr, "args: %d\n", args); + #endif +     if(args < 0)    {    args=~args;    vargs=IDENTIFIER_VARARGS;    }else{    vargs=0;    }       if(Pike_compiler->compiler_frame->lexical_scope & SCOPE_SCOPED)    vargs|=IDENTIFIER_SCOPED;       if(Pike_compiler->compiler_frame->lexical_scope & SCOPE_SCOPE_USED)    vargs|=IDENTIFIER_SCOPE_USED;      #ifdef PIKE_DEBUG -  if(a_flag > 5) +  if((a_flag > 1) || (c->lex.pragmas & ID_DISASSEMBLE))    fprintf(stderr, "Extra identifier flags:0x%02x\n", vargs);   #endif    -  if(Pike_compiler->compiler_pass==1) +  if(Pike_compiler->compiler_pass != COMPILER_PASS_LAST)    {    tmp.offset=-1;   #ifdef PIKE_DEBUG    if(a_flag > 4)    {    fputs("Making prototype (pass 1) for: ", stderr);    print_tree(n);    }   #endif    }else{
pike.git/src/las.c:4687:    IDENTIFIER_HAS_BODY |    vargs),    NULL, (unsigned INT16)    (Pike_compiler->compiler_frame->opt_flags));    remove_clear_locals=args;    if(vargs) remove_clear_locals++;    tmp.offset=do_code_block(n, vargs);    remove_clear_locals=0x7fffffff;    Pike_compiler->compiler_frame->current_function_number = saved_fun_num;    } + #ifdef PIKE_DEBUG +  if(a_flag > 2) +  { +  fputs("Coded\n", stderr);    } -  + #endif +  }       ret=define_function(name,    type,    (unsigned INT16)modifiers,    (unsigned INT8)(IDENTIFIER_PIKE_FUNCTION |    IDENTIFIER_HAS_BODY |    vargs),    Pike_compiler->num_parse_error?NULL:&tmp,    (unsigned INT16)    (Pike_compiler->compiler_frame->opt_flags));         #ifdef PIKE_DEBUG    if(a_flag > 1)    fprintf(stderr,"Identifer = %d\n",ret);   #endif       free_node(n);    return ret;   }