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.85 1999/09/06 11:13:17 hubbe Exp $"); + RCSID("$Id: las.c,v 1.86 1999/09/11 08:15:55 hubbe 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:688:       sprintf(fnord,"Expected constant, got something else (%d)",n->token);    yyerror(fnord);    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... +  * /Hubbe +  */    if(IDENTIFIER_IS_CONSTANT(i->identifier_flags))    {    push_svalue(PROG_FROM_INT(p, numid)->constants +    i->func.offset);    }else{    my_yyerror("Identifier '%s' is not a constant", i->name->str);    push_int(0);    }    }   }    - void resolv_program(node *n) + /* Leaves a function or object on the stack */ + void resolv_class(node *n)   {    check_tree(n,0);       resolv_constant(n);    switch(sp[-1].type)    {    case T_OBJECT:    if(!sp[-1].u.object->prog)    {    pop_stack();    push_int(0);    }else{    f_object_program(1);    }    break;    -  +  default: +  yyerror("Illegal program identifier"); +  pop_stack(); +  push_int(0); +     case T_FUNCTION: -  +  case T_PROGRAM: +  break; +  } + } +  + /* This one always leaves a program if possible */ + void resolv_program(node *n) + { +  check_tree(n,0); +  +  resolv_class(n); +  switch(sp[-1].type) +  { +  case T_FUNCTION:    if(program_from_function(sp-1))    break;       default:    yyerror("Illegal program identifier");    pop_stack();    push_int(0);       case T_PROGRAM:    break;
pike.git/src/las.c:1550:    case F_VAL_LVAL:    case F_LVALUE_LIST:    case F_ARG_LIST:    return cntargs(CAR(n))+cntargs(CDR(n));       /* this might not be true, but it doesn't matter very much */    default: return 1;    }   }    + static int function_type_max=0; +    static void low_build_function_type(node *n)   {    if(!n) return; -  +  if(function_type_max++ > 999) +  { +  reset_type_stack(); +  push_type(T_MIXED); +  push_type(T_MIXED); /* is varargs */ +  push_type(T_MANY); +  return; +  }    switch(n->token)    {    case F_ARG_LIST:    low_build_function_type(CDR(n));    low_build_function_type(CAR(n));    break;       case F_PUSH_ARRAY: /* We let this ruin type-checking for now.. */    reset_type_stack();    push_type(T_MIXED);
pike.git/src/las.c:1630:    break;       case F_APPLY:    {    struct pike_string *s;    struct pike_string *f;    INT32 max_args,args;    push_type(T_MIXED); /* match any return type, even void */    push_type(T_VOID); /* not varargs */    push_type(T_MANY); +  function_type_max=0;    low_build_function_type(CDR(n));    push_type(T_FUNCTION);    s=pop_type();    f=CAR(n)->type?CAR(n)->type:mixed_type_string;    n->type=check_call(s,f);    args=count_arguments(s);    max_args=count_arguments(f);    if(max_args<0) max_args=0x7fffffff;       if(!n->type)