pike.git / src / las.c

version» Context lines:

pike.git/src/las.c:271:    if(tmp1==-1 || tmp2==-1) return -1;    if(tmp1 < tmp2) return tmp1;    return tmp2;    }       case F_PUSH_ARRAY:    return -1;       case F_APPLY:    if(CAR(n)->token == F_CONSTANT && -  CAR(n)->u.sval.type == T_FUNCTION && -  CAR(n)->u.sval.subtype == FUNCTION_BUILTIN && +  TYPEOF(CAR(n)->u.sval) == T_FUNCTION && +  SUBTYPEOF(CAR(n)->u.sval) == FUNCTION_BUILTIN &&    n->type == void_type_string)    return 0;    return 1;       case F_RANGE_FROM_BEG:    case F_RANGE_FROM_END:    return 1;    case F_RANGE_OPEN:    return 0;   
pike.git/src/las.c:740:       case F_AUTO_MAP:    case F_APPLY:    {    unsigned INT16 opt_flags = OPT_SIDE_EFFECT | OPT_EXTERNAL_DEPEND;    struct identifier *i = NULL;       if (a) {    switch(a->token) {    case F_CONSTANT: -  switch(a->u.sval.type) +  switch(TYPEOF(a->u.sval))    {    case T_FUNCTION: -  if (a->u.sval.subtype == FUNCTION_BUILTIN) +  if (SUBTYPEOF(a->u.sval) == FUNCTION_BUILTIN)    {    opt_flags = a->u.sval.u.efun->flags;    } else if (a->u.sval.u.object->prog) { -  i = ID_FROM_INT(a->u.sval.u.object->prog, a->u.sval.subtype); +  i = ID_FROM_INT(a->u.sval.u.object->prog, SUBTYPEOF(a->u.sval));    } else {    yyerror("Calling function in destructed module.");    }    break;       case T_PROGRAM:    if(a->u.sval.u.program->flags & PROGRAM_CONSTANT) {    opt_flags=0;    }    if (a->u.sval.u.program->flags & PROGRAM_USES_PARENT) {
pike.git/src/las.c:933:    verify_shared_strings_tables();   #endif       return res;   }      node *debug_mkstrnode(struct pike_string *str)   {    node *res = mkemptynode();    res->token = F_CONSTANT; -  res->u.sval.type = T_STRING; - #ifdef __CHECKER__ -  res->u.sval.subtype = 0; - #endif -  copy_shared_string(res->u.sval.u.string, str); +  SET_SVAL(res->u.sval, T_STRING, 0, string, str); +  add_ref(str);    res->type = get_type_of_svalue(&res->u.sval);    res->tree_info = OPT_SAFE;    return res;   }      node *debug_mkintnode(INT_TYPE nr)   {    node *res = mkemptynode();    res->token = F_CONSTANT; -  res->u.sval.type = T_INT; -  res->u.sval.subtype = NUMBER_NUMBER; -  res->u.sval.u.integer = nr; +  SET_SVAL(res->u.sval, T_INT, NUMBER_NUMBER, integer, nr);    res->type=get_type_of_svalue( & res->u.sval);    res->tree_info = OPT_SAFE;       return res;   }      node *debug_mknewintnode(INT_TYPE nr)   {    node *res = mkemptynode();    res->token = F_CONSTANT; -  res->u.sval.type = T_INT; -  res->u.sval.subtype = NUMBER_NUMBER; -  res->u.sval.u.integer = nr; +  SET_SVAL(res->u.sval, T_INT, NUMBER_NUMBER, integer, nr);    res->type=get_type_of_svalue( & res->u.sval);    res->tree_info = OPT_SAFE;    return res;   }      node *debug_mkfloatnode(FLOAT_TYPE foo)   {    node *res = mkemptynode();    res->token = F_CONSTANT;    copy_pike_type(res->type, float_type_string); -  res->u.sval.type = T_FLOAT; - #ifdef __CHECKER__ -  res->u.sval.subtype = 0; - #endif -  res->u.sval.u.float_number = foo; +  SET_SVAL(res->u.sval, T_FLOAT, 0, float_number, foo);    res->tree_info = OPT_SAFE;       return res;   }         node *debug_mkprgnode(struct program *p)   {    struct svalue s; -  s.u.program=p; -  s.type = T_PROGRAM; - #ifdef __CHECKER__ -  s.subtype = 0; - #endif +  SET_SVAL(s, T_PROGRAM, 0, program, p);    return mkconstantsvaluenode(&s);   }      node *debug_mkapplynode(node *func,node *args)   {    return mknode(F_APPLY, func, args);   }      node *debug_mkefuncallnode(char *function, node *args)   {
pike.git/src/las.c:1184:    copy_pike_type(res->type, id->type);       /* FIXME */    if(IDENTIFIER_IS_CONSTANT(id->identifier_flags))    {    if (!(PTR_FROM_INT(parent_prog, i)->id_flags & ID_LOCAL)) {    /* It's possible to overload the identifier. */    res->node_info = OPT_EXTERNAL_DEPEND;    } else if (id->func.const_info.offset != -1) {    struct svalue *s = &parent_prog->constants[id->func.const_info.offset].sval; -  if ((s->type == T_PROGRAM) && +  if ((TYPEOF(*s) == T_PROGRAM) &&    (s->u.program->flags & PROGRAM_USES_PARENT)) {    /* The constant program refers to its parent, so we need as well. */    res->node_info = OPT_EXTERNAL_DEPEND;    }    }    }else{    res->node_info = OPT_NOT_CONST;    if (IDENTIFIER_IS_VARIABLE(id->identifier_flags) &&    (id->run_time_type == PIKE_T_GET_SET)) {    /* Special case of F_EXTERNAL for ease of detection. */
pike.git/src/las.c:1538:    }    }   }      /* Leaves a function or object on the stack */   void resolv_class(node *n)   {    check_tree(n,0);       resolv_constant(n); -  switch(Pike_sp[-1].type) +  switch(TYPEOF(Pike_sp[-1]))    {    case T_OBJECT:    if(!Pike_sp[-1].u.object->prog)    {    pop_stack();    push_int(0);    }else{    f_object_program(1);    }    break;
pike.git/src/las.c:1568:    break;    }   }      /* This one always leaves a program if possible */   void resolv_program(node *n)   {    check_tree(n,0);       resolv_class(n); -  switch(Pike_sp[-1].type) +  switch(TYPEOF(Pike_sp[-1]))    {    case T_FUNCTION:    if(program_from_function(Pike_sp-1))    break;       default:    if (Pike_compiler->compiler_pass!=1)    yyerror("Illegal program identifier");    pop_stack();    push_int(0);
pike.git/src/las.c:1606:       if(SETJMP(tmp))    {    if (node_name) {    handle_compile_exception ("Couldn't index module %s.", node_name);    } else {    handle_compile_exception ("Couldn't index module.");    }    }else{    resolv_constant(n); -  switch(Pike_sp[-1].type) +  switch(TYPEOF(Pike_sp[-1]))    {    case T_INT:    if (!Pike_sp[-1].u.integer) {    if(!Pike_compiler->num_parse_error) {    if (node_name) {    my_yyerror("Failed to index module %s with '%S'. "    "(Module doesn't exist?)",    node_name, id);    } else {    my_yyerror("Failed to index module with '%S'. "
pike.git/src/las.c:1630:    }    break;    }    /* Fall through. */       case T_FLOAT:    case T_STRING:    case T_ARRAY:    if (node_name) {    my_yyerror("Failed to index module %s, got %s. (Not a module?)", -  node_name, get_name_of_type (Pike_sp[-1].type)); +  node_name, get_name_of_type (TYPEOF(Pike_sp[-1])));    } else {    my_yyerror("Failed to index a module, got %s. (Not a module?)", -  get_name_of_type (Pike_sp[-1].type)); +  get_name_of_type (TYPEOF(Pike_sp[-1])));    }    pop_stack();    push_int(0);    break;       case T_OBJECT:    case T_PROGRAM:    if(!(Pike_compiler->new_program->flags & PROGRAM_PASS_1_DONE))    {    struct program *p; -  if(Pike_sp[-1].type == T_OBJECT) +  if(TYPEOF(Pike_sp[-1]) == T_OBJECT)    p=Pike_sp[-1].u.object->prog;    else    p=Pike_sp[-1].u.program;       if(p && !(p->flags & PROGRAM_PASS_1_DONE))    {    if(report_compiler_dependency(p))    {    pop_stack();   #if 0
pike.git/src/las.c:1699:    }    push_undefined();    exception = 1;    } else {    f_index(2);    }    STACK_LEVEL_DONE(1);    UNSETJMP(recovery);    }    -  if(Pike_sp[-1].type == T_INT && +  if(TYPEOF(Pike_sp[-1]) == T_INT &&    !Pike_sp[-1].u.integer && -  Pike_sp[-1].subtype==NUMBER_UNDEFINED) +  SUBTYPEOF(Pike_sp[-1]) == NUMBER_UNDEFINED)    {    if(Pike_compiler->new_program->flags & PROGRAM_PASS_1_DONE)    {    if (!exception) {    struct compilation *c = THIS_COMPILATION;    if (node_name) {    my_yyerror("Index '%S' not present in module %s.",    id, node_name);    } else {    my_yyerror("Index '%S' not present in module.", id);
pike.git/src/las.c:1730: Inside #if 0
  #if 0    fprintf(stderr, "Placeholder deployed when indexing ");    print_tree(n);    fprintf(stderr, "with %s\n", id->str);   #endif    ref_push_object(placeholder_object);    }    }       else if (Pike_compiler->new_program->flags & PROGRAM_PASS_1_DONE) { -  if (((Pike_sp[-1].type == T_OBJECT && +  if (((TYPEOF(Pike_sp[-1]) == T_OBJECT &&    Pike_sp[-1].u.object == placeholder_object) || -  (Pike_sp[-1].type == T_PROGRAM && +  (TYPEOF(Pike_sp[-1]) == 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 when indexing "    "module %s with '%S'. (Resolver problem.)", -  get_name_of_type (Pike_sp[-1].type), +  get_name_of_type (TYPEOF(Pike_sp[-1])),    node_name, id);    else    my_yyerror("Got placeholder %s when indexing "    "module with '%S'. (Resolver problem.)", -  get_name_of_type (Pike_sp[-1].type), +  get_name_of_type (TYPEOF(Pike_sp[-1])),    id);    }    }       else {    /* If we get a program that hasn't gone through pass 1 yet    * then we have to register a dependency now in our pass 1    * so that our pass 2 gets delayed. Otherwise the other    * program might still be just as unfinished when we come    * back here in pass 2. */    struct program *p = NULL; -  if (Pike_sp[-1].type == T_PROGRAM) +  if (TYPEOF(Pike_sp[-1]) == T_PROGRAM)    p = Pike_sp[-1].u.program; -  else if (Pike_sp[-1].type == T_OBJECT || -  (Pike_sp[-1].type == T_FUNCTION && -  Pike_sp[-1].subtype != FUNCTION_BUILTIN)) +  else if (TYPEOF(Pike_sp[-1]) == T_OBJECT || +  (TYPEOF(Pike_sp[-1]) == T_FUNCTION && +  SUBTYPEOF(Pike_sp[-1]) != FUNCTION_BUILTIN))    p = Pike_sp[-1].u.object->prog;    if (p && !(p->flags & PROGRAM_PASS_1_DONE))    report_compiler_dependency (p);    }    }    END_CYCLIC();    }    }    }    UNSETJMP(tmp);
pike.git/src/las.c:1828:    if(car_is_node(a) && !node_is_eq(CAR(a), CAR(b))) return 0;    if(cdr_is_node(a) && !node_is_eq(CDR(a), CDR(b))) return 0;    return 1;    }   }      node *debug_mktypenode(struct pike_type *t)   {    node *res = mkemptynode();    res->token = F_CONSTANT; -  copy_pike_type(res->u.sval.u.type, t); -  res->u.sval.type = T_TYPE; +  SET_SVAL(res->u.sval, T_TYPE, 0, type, t); +  add_ref(t);    /* FIXME: Should be type(val) */    type_stack_mark();    push_finished_type(t);    push_type(T_TYPE);    res->type = pop_unfinished_type();    return res;   }      node *low_mkconstantsvaluenode(const struct svalue *s)   {    node *res = mkemptynode();    res->token = F_CONSTANT;    assign_svalue_no_free(& res->u.sval, s); -  if(s->type == T_OBJECT || -  (s->type==T_FUNCTION && s->subtype!=FUNCTION_BUILTIN)) +  if(TYPEOF(*s) == T_OBJECT || +  (TYPEOF(*s) == T_FUNCTION && SUBTYPEOF(*s) != FUNCTION_BUILTIN))    {    if(!(s->u.object->prog && (s->u.object->prog->flags & PROGRAM_CONSTANT)))    res->node_info|=OPT_EXTERNAL_DEPEND;    }    res->type = get_type_of_svalue(s);    res->tree_info |= OPT_SAFE;    return res;   }      node *debug_mkconstantsvaluenode(const struct svalue *s)   {    return low_mkconstantsvaluenode(s);   }      node *debug_mkliteralsvaluenode(const struct svalue *s)   {    node *res = low_mkconstantsvaluenode(s);    -  if(s->type!=T_STRING && s->type!=T_INT && s->type!=T_FLOAT) +  if(TYPEOF(*s) != T_STRING && TYPEOF(*s) != T_INT && TYPEOF(*s) != T_FLOAT)    res->node_info|=OPT_EXTERNAL_DEPEND;       return res;   }      node *debug_mksvaluenode(struct svalue *s)   { -  switch(s->type) +  switch(TYPEOF(*s))    {    case T_ARRAY:    return make_node_from_array(s->u.array);       case T_MULTISET:    return make_node_from_multiset(s->u.multiset);       case T_MAPPING:    return make_node_from_mapping(s->u.mapping);   
pike.git/src/las.c:1918:    n=mkefuncallnode("function_object",    mkefuncallnode("object_program",n));    }   #endif    return n;    }    break;       case T_FUNCTION:    { -  if(s->subtype != FUNCTION_BUILTIN) +  if(SUBTYPEOF(*s) != FUNCTION_BUILTIN)    {    if(s->u.object == Pike_compiler->fake_object) -  return mkidentifiernode(s->subtype); +  return mkidentifiernode(SUBTYPEOF(*s));       if(s->u.object->next == s->u.object)    { -  return mkexternalnode(s->u.object->prog, s->subtype); +  return mkexternalnode(s->u.object->prog, SUBTYPEOF(*s));    }      /* yyerror("Non-constant function pointer! (should not happen!)"); */    }    }    }       return mkconstantsvaluenode(s);   }   
pike.git/src/las.c:2108:   node **my_get_arg(node **a,int n) { return low_get_arg(a,&n); }      node **is_call_to(node *n, c_fun f)   {    switch(n->token)    {    case F_AUTO_MAP:    case F_APPLY:    if(CAR(n) &&    CAR(n)->token == F_CONSTANT && -  CAR(n)->u.sval.type == T_FUNCTION && -  CAR(n)->u.sval.subtype == FUNCTION_BUILTIN && +  TYPEOF(CAR(n)->u.sval) == T_FUNCTION && +  SUBTYPEOF(CAR(n)->u.sval) == FUNCTION_BUILTIN &&    CAR(n)->u.sval.u.efun->function == f)    return &_CDR(n);    }    return 0;   }         /* FIXME: Ought to use parent pointer to avoid recursion. */   static void low_print_tree(node *foo,int needlval)   {
pike.git/src/las.c:3143: Inside #if 0 /* FIXME */
  #if 0 /* FIXME */    case F_TRAMPOLINE:   #endif    case F_IDENTIFIER:    name = ID_FROM_INT(Pike_compiler->new_program, n->u.id.number)->name;    break;       case F_ARROW:    case F_INDEX:    if(CDR(n)->token == F_CONSTANT && -  CDR(n)->u.sval.type == T_STRING) +  TYPEOF(CDR(n)->u.sval) == T_STRING)    {    name = CDR(n)->u.sval.u.string;    }else{    MAKE_CONST_STRING(name, "dynamically resolved function");    }    break;       case F_CONSTANT: -  switch(n->u.sval.type) +  switch(TYPEOF(n->u.sval))    {    case T_FUNCTION: -  if(n->u.sval.subtype == FUNCTION_BUILTIN) +  if(SUBTYPEOF(n->u.sval) == FUNCTION_BUILTIN)    {    name = n->u.sval.u.efun->name;    }else{ -  name = ID_FROM_INT(n->u.sval.u.object->prog, n->u.sval.subtype)->name; +  name = +  ID_FROM_INT(n->u.sval.u.object->prog, SUBTYPEOF(n->u.sval))->name;    }    break;       case T_ARRAY:    MAKE_CONST_STRING(name, "array call");    break;       case T_PROGRAM:    MAKE_CONST_STRING(name, "clone call");    break;
pike.git/src/las.c:3237:    case F_TRAMPOLINE:    MAKE_CONST_STRING(name, "trampoline function");    break;       case F_LOCAL:    MAKE_CONST_STRING(name, "local variable");    break;       case F_APPLY:    if ((CAR(n)->token == F_CONSTANT) && -  (CAR(n)->u.sval.type == T_FUNCTION) && -  (CAR(n)->u.sval.subtype == FUNCTION_BUILTIN) && +  (TYPEOF(CAR(n)->u.sval) == T_FUNCTION) && +  (SUBTYPEOF(CAR(n)->u.sval) == FUNCTION_BUILTIN) &&    (CAR(n)->u.sval.u.efun->function == debug_f_aggregate)) {    if (CDR(n)) {    n = CDR(n);    while (n && (n->token == F_ARG_LIST)) n = CAR(n);    if (n) {    /* FIXME: Should really join the names of all the args. */    name = get_name_of_function(n);    } else {    MAKE_CONST_STRING(name, "dynamic array");    }
pike.git/src/las.c:3290:    n->type = 0;    n->node_info &= ~OPT_TYPE_NOT_FIXED;       switch(n->token)    {    case F_SOFT_CAST:    if (CAR(n) && CAR(n)->type) {   #ifdef NEW_ARG_CHECK    struct pike_type *soft_type = NULL;    if (CDR(n) && (CDR(n)->token == F_CONSTANT) && -  (CDR(n)->u.sval.type == T_TYPE)) { +  (TYPEOF(CDR(n)->u.sval) == T_TYPE)) {    soft_type = CDR(n)->u.sval.u.type;    if ((n->type = soft_cast(soft_type, CAR(n)->type, 0))) {    /* Success. */    break;    }    ref_push_type_value(CAR(n)->type);    ref_push_type_value(soft_type);    yytype_report(REPORT_ERROR, NULL, 0, NULL, NULL, 0, NULL,    2, "Soft cast of %O to %O isn't a valid cast.");    } else {
pike.git/src/las.c:3673: Inside #if 0 /* FIXME */
  #if 0 /* FIXME */    case F_TRAMPOLINE:   #endif    case F_IDENTIFIER:    name=ID_FROM_INT(Pike_compiler->new_program, CAR(n)->u.id.number)->name;    break;       case F_ARROW:    case F_INDEX:    if(CDAR(n)->token == F_CONSTANT && -  CDAR(n)->u.sval.type == T_STRING) +  TYPEOF(CDAR(n)->u.sval) == T_STRING)    {    name=CDAR(n)->u.sval.u.string;    }else{    alternate_name="dynamically resolved function";    }    break;       case F_CONSTANT: -  switch(CAR(n)->u.sval.type) +  switch(TYPEOF(CAR(n)->u.sval))    {    case T_FUNCTION: -  if(CAR(n)->u.sval.subtype == FUNCTION_BUILTIN) +  if(SUBTYPEOF(CAR(n)->u.sval) == FUNCTION_BUILTIN)    {    name=CAR(n)->u.sval.u.efun->name;    }else{    name=ID_FROM_INT(CAR(n)->u.sval.u.object->prog, -  CAR(n)->u.sval.subtype)->name; +  SUBTYPEOF(CAR(n)->u.sval))->name;    }    break;       case T_ARRAY:    alternate_name="array call";    break;       case T_PROGRAM:    alternate_name="clone call";    break;
pike.git/src/las.c:5580: Inside #if defined(SHARED_NODES) && 0
  #if defined(SHARED_NODES) && 0    /* Try the local variable usage analyser. */    n = localopt(n);    /* Try optimizing some more. */    optimize(n);   #endif /* SHARED_NODES && 0 */    n = mknode(F_ARG_LIST, n, 0);       if((foo=is_stupid_func(n, args, vargs, type)))    { -  if(foo->type == T_FUNCTION && foo->subtype==FUNCTION_BUILTIN) +  if(TYPEOF(*foo) == T_FUNCTION && SUBTYPEOF(*foo) == FUNCTION_BUILTIN)    {    tmp.c_fun=foo->u.efun->function;    if(tmp.c_fun != f_destruct &&    tmp.c_fun != f_this_object &&    tmp.c_fun != f_backtrace)    {   #ifdef PIKE_DEBUG    struct compilation *c = THIS_COMPILATION;       if(a_flag > 1)