pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.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: builtin_functions.c,v 1.651 2008/01/29 20:10:06 grubba Exp $ + || $Id: builtin_functions.c,v 1.652 2008/04/14 10:14:35 grubba Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin_functions.c:37:   #include "opcodes.h"   #include "cyclic.h"   #include "signal_handler.h"   #include "pike_security.h"   #include "builtin_functions.h"   #include "bignum.h"   #include "peep.h"   #include "docode.h"   #include "lex.h"   #include "pike_float.h" + #include "pike_compiler.h"      #ifdef HAVE_POLL   #ifdef HAVE_POLL_H   #include <poll.h>   #endif /* HAVE_POLL_H */      #ifdef HAVE_SYS_POLL_H   #include <sys/poll.h>   #endif /* HAVE_SYS_POLL_H */   #endif /* HAVE_POLL */
pike.git/src/builtin_functions.c:1456:    else    {    pop_n_elems(args-1);    Pike_sp[-1].u.integer=Pike_sp[-1].subtype;    Pike_sp[-1].subtype=NUMBER_NUMBER;    }   }      static int generate_zero_type(node *n)   { +  struct compilation *c = THIS_COMPILATION; +  CHECK_COMPILER();    if(count_args(CDR(n)) != 1) return 0;    if(do_docode(CDR(n),DO_NOT_COPY) != 1)    Pike_fatal("Count args was wrong in generate_zero_type().\n");    emit0(F_ZERO_TYPE);    return 1;   }      /*    * Some wide-strings related functions    */
pike.git/src/builtin_functions.c:2379:    *!    *! @note    *! This function should only be used during a call of @[compile()].    *!    *! @seealso    *! @[get_active_error_handler()], @[compile()],    *! @[master()->get_compilation_handler()], @[CompilationHandler]    */   PMOD_EXPORT void f_get_active_compilation_handler(INT32 args)   { +  struct compilation *c = NULL; +  +  if (compilation_program) { +  struct pike_frame *compiler_frame = Pike_fp; +  +  while (compiler_frame && +  (compiler_frame->context->prog != compilation_program)) { +  compiler_frame = compiler_frame->next; +  } +  +  if (compiler_frame) { +  c = (struct compilation *)compiler_frame->current_storage; +  } +  } +     pop_n_elems(args); -  if (compat_handler) { -  ref_push_object(compat_handler); +  if (c && c->compat_handler) { +  ref_push_object(c->compat_handler);    } else {    push_int(0);    }   }      /*! @decl CompilationHandler get_active_error_handler()    *!    *! Returns the currently active compilation error handler    *! (second argument to @[compile()]), or @tt{0@} (zero) if none    *! is active.    *!    *! @note    *! This function should only be used during a call of @[compile()].    *!    *! @seealso    *! @[get_active_compilation_handler()], @[compile()], @[CompilationHandler]    */   PMOD_EXPORT void f_get_active_error_handler(INT32 args)   { -  +  struct compilation *c = NULL; +  +  if (compilation_program) { +  struct pike_frame *compiler_frame = Pike_fp; +  +  while (compiler_frame && +  (compiler_frame->context->prog != compilation_program)) { +  compiler_frame = compiler_frame->next; +  } +  +  if (compiler_frame) { +  c = (struct compilation *)compiler_frame->current_storage; +  } +  } +     pop_n_elems(args); -  if (error_handler) { -  ref_push_object(error_handler); +  if (c && c->handler) { +  ref_push_object(c->handler);    } else {    push_int(0);    }   }      /*! @decl array allocate(int size)    *! @decl array allocate(int size, mixed init)    *!    *! Allocate an array of @[size] elements. If @[init] is specified    *! then each element is initialized by copying that value
pike.git/src/builtin_functions.c:2543:    n->parent->node_info |= OPT_TYPE_NOT_FIXED;    }    }       return NULL;   }      static int generate_this_object(node *n)   {    int level; +  struct compilation *c = THIS_COMPILATION; +  CHECK_COMPILER();       if (CDR (n)) {    if (CDR (n)->token != F_CONSTANT)    /* Not a constant expression. Make a call to f_this_object. */    return 0;    else {   #ifdef PIKE_DEBUG    if (CDR (n)->u.sval.type != T_INT || CDR (n)->u.sval.u.integer < 0)    Pike_fatal ("The type check for this_object() failed.\n");   #endif
pike.git/src/builtin_functions.c:4069:    *! Also note that @[compile()] does not preprocess the program.    *! To preprocess the program you can use @[compile_string()] or    *! call the preprocessor manually by calling @[cpp()].    *!    *! @seealso    *! @[compile_string()], @[compile_file()], @[cpp()], @[master()],    *! @[CompilationHandler]    */   PMOD_EXPORT void f_compile(INT32 args)   { -  struct program *p=0; -  struct object *o; -  struct object *placeholder=0; -  int major=-1; -  int minor=-1; +  struct object *ce = clone_object(compilation_program, 0); +  ONERROR err;    -  +  SET_ONERROR(err, do_free_object, ce);    -  check_all_args("compile",args, -  BIT_STRING, -  BIT_VOID | BIT_INT | BIT_OBJECT, -  BIT_VOID | BIT_INT, -  BIT_VOID | BIT_INT, -  BIT_VOID | BIT_INT | BIT_PROGRAM, -  BIT_VOID | BIT_INT | BIT_OBJECT, -  0); +  apply_low(ce, CE_COMPILE_FUN_NUM, args);    -  check_c_stack(65536); -  -  o=0; -  switch(args) -  { -  case 3: -  SIMPLE_BAD_ARG_ERROR("compile", 4, "int"); -  default: -  if(Pike_sp[5-args].type == T_OBJECT) { -  if (Pike_sp[5-args].subtype) { -  Pike_error("compile: " -  "Subtyped placeholder objects are not supported yet.\n"); +  CALL_AND_UNSET_ONERROR(err);   } -  placeholder=Pike_sp[5-args].u.object; -  } +     -  case 5: -  if(Pike_sp[4-args].type == T_PROGRAM) -  p=Pike_sp[4-args].u.program; +     -  case 4: -  major=Pike_sp[2-args].u.integer; -  minor=Pike_sp[3-args].u.integer; -  -  case 2: -  if(Pike_sp[1-args].type == T_OBJECT) { -  if (Pike_sp[1-args].subtype) { -  Pike_error("compile: " -  "Subtyped handler objects are not supported yet.\n"); -  } -  o=Pike_sp[1-args].u.object; -  } -  -  case 0: case 1: break; -  } -  -  p = compile(Pike_sp[-args].u.string, o, major, minor, p, placeholder); -  -  pop_n_elems(args); -  push_program(p); - } -  -  +    /*! @decl array|mapping|multiset set_weak_flag(array|mapping|multiset m, @    *! int state)    *!    *! Set the value @[m] to use weak or normal references in its    *! indices and/or values (whatever is applicable). @[state] is a    *! bitfield built by using @expr{|@} between the following flags:    *!    *! @int    *! @value Pike.WEAK_INDICES    *! Use weak references for indices. Only applicable for