pike.git / src / program.c

version» Context lines:

pike.git/src/program.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: program.c,v 1.681 2008/05/02 04:15:14 mast Exp $ + || $Id: program.c,v 1.682 2008/05/02 10:56:06 grubba Exp $   */      #include "global.h"   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"   #include "pike_types.h"   #include "stralloc.h"   #include "las.h"   #include "lex.h"
pike.git/src/program.c:4500:    }   }      int call_handle_inherit(struct pike_string *s)   {    struct compilation *c = THIS_COMPILATION;    int args;       CHECK_COMPILER();    -  reference_shared_string(s); -  push_string(s); +  ref_push_string(s);    if (!TEST_COMPAT(7,6)) {    /* In Pike 7.7 and later filenames belonging to Pike are assumed    * to be encoded according to UTF-8.    */    f_string_to_utf8(1);    } -  ref_push_string(c->lex.current_file); -  if (c->handler && c->handler->prog) { -  ref_push_object(c->handler); -  args = 3; -  } -  else args = 2; +     -  if (safe_apply_handler("handle_inherit", c->handler, c->compat_handler, -  args, BIT_PROGRAM|BIT_FUNCTION|BIT_ZERO)) +  if (safe_apply_current2(PC_HANDLE_INHERIT_FUN_NUM, 1, NULL))    if (Pike_sp[-1].type != T_INT)    return 1;    else {    pop_stack();    my_yyerror("Couldn't find program %S", s);    }    else {    handle_compile_exception ("Error finding program");    }   
pike.git/src/program.c:7361:   {    if(get_master())    {    APPLY_MASTER("get_default_module", args);    } else {    pop_n_elems(args);    push_undefined();    }   }    + /*! @decl program handle_inherit(string inh, string current_file, @ +  *! object|void handler) +  *! +  *! Look up an inherit @[inh]. +  */ + static void f_compilation_env_handle_inherit(INT32 args) + { +  if(get_master()) +  { +  APPLY_MASTER("handle_inherit", args); +  } else { +  pop_n_elems(args); +  push_undefined(); +  } + } +    /*! @class PikeCompiler    *!    *! The Pike compiler.    *!    *! An object of this class compiles a single string    *! of Pike code.    */      static void free_compilation(struct compilation *c)   {
pike.git/src/program.c:8303:    }    }else{    use_module(sp-1);    pop_stack();    }       STACK_LEVEL_DONE(0);    push_int(0);   }    + /*! @decl program handle_inherit(string inh) +  *! +  *! Look up an inherit @[inh] in the current program. +  */ + static void f_compilation_handle_inherit(INT32 args) + { +  struct compilation *c = THIS_COMPILATION; +  struct object *handler; +  int fun = -1; +  +  if (args > 1) pop_n_elems(args-1); +  +  ref_push_string(c->lex.current_file); +  if (c->handler && c->handler->prog) { +  ref_push_object(c->handler); +  args = 3; +  } +  else args = 2; +  +  if (((handler = c->handler) && handler->prog && +  ((fun = find_identifier("handle_inherit", handler->prog)) != -1)) || +  ((handler = c->compat_handler) && handler->prog && +  ((fun = find_identifier("handle_inherit", handler->prog)) != -1))) { +  apply_low(handler, fun, args); +  } else { +  apply_external(1, CE_HANDLE_INHERIT_FUN_NUM, args); +  } + } +    static void f_compilation__sprintf(INT32 args)   {    struct compilation *c = THIS_COMPILATION;    struct string_builder buf;    init_string_builder_alloc(&buf, 50, 0);    string_builder_strcat(&buf, "PikeCompiler(");    if (c->prog) {    string_builder_strcat(&buf, "\"\", ");    } else {    string_builder_strcat(&buf, "UNDEFINED, ");
pike.git/src/program.c:8571:    f_compilation_get_compilation_handler,    tFunc(tInt tInt, tObj), 0);       ADD_FUNCTION("get_default_module", f_compilation_get_default_module,    tFunc(tNone, tOr(tMap(tStr, tMix), tObj)), 0);       ADD_FUNCTION("change_compiler_compatibility",    f_compilation_change_compiler_compatibility,    tFunc(tInt tInt, tVoid), 0);    +  ADD_FUNCTION("handle_inherit", f_compilation_handle_inherit, +  tFunc(tStr, tPrg(tObj)), 0); +     ADD_FUNCTION("_sprintf", f_compilation__sprintf,    tFunc(tInt tOr(tMap(tStr, tMix), tVoid), tStr), ID_STATIC);       start_new_program();       ADD_STORAGE(struct program_state);    Pike_compiler->new_program->event_handler = program_state_event_handler;    Pike_compiler->new_program->flags |=    PROGRAM_NEEDS_PARENT|PROGRAM_USES_PARENT|PROGRAM_HAS_C_METHODS;   
pike.git/src/program.c:8623:    Pike_fp->context = compilation_program->inherits;       ADD_FUNCTION("get_compilation_handler",    f_compilation_env_get_compilation_handler,    tFunc(tInt tInt, tObj), 0);       ADD_FUNCTION("get_default_module",    f_compilation_env_get_default_module,    tFunc(tNone, tOr(tMap(tStr, tMix), tObj)), 0);    +  ADD_FUNCTION("handle_inherit", f_compilation_env_handle_inherit, +  tFunc(tStr tStr tOr(tObj, tVoid), tPrg(tObj)), 0); +     {    struct pike_string *type_name;    struct svalue type_value;       /* enum SeverityLevel { NOTICE, WARNING, ERROR, FATAL } */    type_value.type = PIKE_T_TYPE;    type_value.subtype = 0;    type_value.u.type = CONSTTYPE(tName("SeverityLevel", tInt03));    simple_add_constant("SeverityLevel", &type_value, 0);    free_svalue(&type_value);