Branch: Tag:

2018-07-18

2018-07-18 12:43:50 by Henrik Grubbström (Grubba) <grubba@grubba.org>

EFUNs: Added get_active_compiler().

This function could be used to implement get_active_error_handler()
and get_active_compilation_handler().

API clean up in preparation for moving handling of handlers
to code written in Pike.

3034:    ref_push_mapping(get_builtin_constants());   }    + /*! @decl CompilerEnvironment.PikeCompiler get_active_compiler() +  *! +  *! Returns the most recent of the currently active pike compilers, +  *! or @[UNDEFINED] if none is active. +  *! +  *! @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_compiler(INT32 args) + { +  struct compilation *c = NULL; +  +  /* NB: This is an efun, so we need to keep the stack clean. */ +  pop_n_elems(args); +  +  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 && compiler_frame->current_object->prog) { +  ref_push_object(compiler_frame->current_object); +  return; +  } +  } +  +  push_undefined(); + } +    /*! @decl CompilationHandler get_active_compilation_handler()    *!    *! Returns the currently active compilation compatibility handler, or
9769:    tFunc(tNone,tMap(tStr,tMix)),OPT_EXTERNAL_DEPEND);       /* function(:object) */ +  ADD_EFUN("get_active_compiler", f_get_active_compiler, +  tFunc(tNone, tObj), OPT_EXTERNAL_DEPEND); +  +  /* function(:object) */    ADD_EFUN("get_active_compilation_handler",    f_get_active_compilation_handler,    tFunc(tNone, tObj), OPT_EXTERNAL_DEPEND);