pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   /* -*- Pike -*-    * -  * $Id: master.pike.in,v 1.147 2001/03/14 21:44:04 mast Exp $ +  * $Id: master.pike.in,v 1.148 2001/03/20 02:45:49 hubbe Exp $    *    * Master-file for Pike.    *    * Based on master.pike 1.67.    */      // Some configurable parameters useful for debugging      #pike __REAL_VERSION__   #define PIKE_AUTORELOAD
pike.git/lib/master.pike.in:184:   //! @global   //! Compile the Pike code contained in the file @[filename] into a program.   //!   //! This function will compile the file @[filename] to a Pike program that can   //! later be instantiated. It is the same as doing   //! @code{@[compile_string](@[Stdio.read_file](@[filename]), @[filename])@}.   //!   //! @seealso   //! @[compile()], @[compile_string()], @[cpp()]   //! - program compile_file(string filename, object|void handler) + program compile_file(string filename, +  object|void handler, +  void|program p, +  void|object o)   {    AUTORELOAD_CHECK_FILE(filename);    return compile(cpp(master_read_file(filename), -  filename, 1, handler, compat_major, compat_minor), -  handler, compat_major, compat_minor); +  filename, +  1, +  handler, +  compat_major, +  compat_minor), +  handler, +  compat_major, +  compat_minor, +  p, +  o);   }         #ifdef GETCWD_CACHE   string current_path;   int cd(string s)   {    current_path=0;    return predef::cd(s);   }
pike.git/lib/master.pike.in:332:   {    // Filenames of potential precompiled files in priority order.    return ({ fname + ".o" });   }      #if constant(_static_modules.Builtin.mutex)   #define THREADED   object compilation_mutex = _static_modules.Builtin()->mutex();   #endif    - static program low_findprog(string pname, string ext, object|void handler) + static program low_findprog(string pname, +  string ext, +  object|void handler, +  void|int mkobj)   {    program ret;    Stat s;    string fname=pname+ext;      #ifdef THREADED    object key;    // FIXME: The catch is needed, since we might be called in    // a context when threads are disabled.    // (compile() disables threads).
pike.git/lib/master.pike.in:419:    handler->compile_warning(oname, 0,    "Compiled file is out of date\n");    } else {    compile_warning(oname, 0, "Compiled file is out of date\n");    }    }    }    }      // werror("2.5: %O\n",fname); -  -  if ( mixed e=catch { ret=compile_file(fname); } ) +  programs[fname]=ret=__empty_program(); +  if ( mixed e=catch { +  ret=compile_file(fname, +  0, +  ret, +  mkobj? (objects[ret]=__null_program()) : 0); +  } )    {   // werror("-3: %O\n",fname); -  programs[fname]=0; +  ret=programs[fname]=0;    if(arrayp(e) && sizeof(e) && e[0] == "Compilation failed.\n")    e[1]=({});    throw(e);    }    break;   #if constant(load_module)    case ".so":    if (fname == "") {    werror(sprintf("low_find_prog(\"%s\", \"%s\") => load_module(\"\")\n"    "%s\n", pname, ext, describe_backtrace(backtrace())));    }       ret=load_module(fakeroot(fname));   #endif /* load_module */    }       AUTORELOAD_FINISH(ret,programs,fname);    - // werror("3: %O\n",fname); + // werror("3: %O (%O)\n",fname, ret);    return programs[fname]=ret;    }    return 0;   }    - static program findprog(string pname, string ext, object|void handler) + static program findprog(string pname, +  string ext, +  object|void handler, +  void|int mkobj)   {    switch(ext)    {    case ".pike":    case ".so": -  return low_findprog(pname,ext,handler); +  return low_findprog(pname,ext,handler, mkobj);       default:    pname+=ext;    return -  low_findprog(pname,"", handler) || -  low_findprog(pname,".pike", handler) || -  low_findprog(pname,".so", handler); +  low_findprog(pname,"", handler, mkobj) || +  low_findprog(pname,".pike", handler, mkobj) || +  low_findprog(pname,".so", handler, mkobj);    }   }    - /* This function is called when the driver wants to cast a string -  * to a program, this might be because of an explicit cast, an inherit -  * or a implict cast. In the future it might receive more arguments, -  * to aid the master finding the right program. -  */ - program cast_to_program(string pname, string current_file, object|void handler) + program low_cast_to_program(string pname, +  string current_file, +  object|void handler, +  void|int mkobj)   {    string ext;    string nname;    array(string) tmp=EXPLODE_PATH(pname);       if(sscanf(reverse(tmp[-1]),"%s.%s",ext, nname))    {    ext="."+reverse(ext);    tmp[-1]=reverse(nname);    pname=tmp*"/";    }else{    ext="";    }    if(IS_ABSOLUTE_PATH(pname))    {    pname=combine_path("/",pname); -  return findprog(pname,ext,handler); +  return findprog(pname,ext,handler,mkobj);    }else{    string cwd;    if(current_file)    {    cwd=DIRNAME(current_file);    }else{    cwd=getcwd();    }    -  if(program ret=findprog(combine_path(cwd,pname),ext,handler)) +  if(program ret=findprog(combine_path(cwd,pname),ext,handler,mkobj))    return ret;       foreach(pike_program_path, string path) -  if(program ret=findprog(combine_path(path,pname),ext,handler)) +  if(program ret=findprog(combine_path(path,pname),ext,handler,mkobj))    return ret;       return 0;    }   }    -  +  + /* This function is called when the driver wants to cast a string +  * to a program, this might be because of an explicit cast, an inherit +  * or a implict cast. In the future it might receive more arguments, +  * to aid the master finding the right program. +  */ + program cast_to_program(string pname, +  string current_file, +  object|void handler) + { +  return low_cast_to_program(pname, current_file, handler); + } +  +    /* This function is called when an error occurs that is not caught    * with catch().    */   void handle_error(array(mixed)|object trace)   {    if(mixed x=catch {    werror(describe_backtrace(trace));    })    {    // One reason for this might be too little stack space, which
pike.git/lib/master.pike.in:658:    return cast_to_program(pname, current_file, handler);   }      mapping (program:object) objects=([object_program(this_object()):this_object()]);      object low_cast_to_object(string oname, string current_file)   {    program p;    object o;    -  p=cast_to_program(oname, current_file); +  p=low_cast_to_program(oname, current_file, 0, 1);    if(!p) return 0;    if(!(o=objects[p])) o=objects[p]=p();    return o;   }      /* This function is called when the drivers wants to cast a string    * to an object because of an implict or explicit cast. This function    * may also receive more arguments in the future.    */   object cast_to_object(string oname, string current_file)
pike.git/lib/master.pike.in:711:    mixed `[](string index) { if(module) return module[index]; }    array(string) _indices() { if(module) return indices(module); }    array _values() { if(module) return values(module); }    }       static mixed ind(string index)    {    if(module)    {    object o; -  if(!zero_type(o=module[index])) return o; +  if(!zero_type(o=module[index])) +  { + // werror("Dirnode(%O) module[%O] -> %O\n",dirname,index, o); +  return o;    } -  +  }       if( !files )    files = get_dir(fakeroot(dirname));       int ret;    foreach( files, string s )    {    if( search(s, index)!=-1 || search(index,s)!=-1 )    {    ret=1;
pike.git/lib/master.pike.in:734:    }    }    if(!ret)    return UNDEFINED;    index = dirname+"/"+index;    if(object o=findmodule(index))    {    if(mixed tmp=o->_module_value) o=tmp;    return o;    } -  if (program p=cast_to_program( index, 0 )) return p; +  if (program p=cast_to_program( index, 0 )) +  { + // werror("dirnode(%O)[%O] -> %O\n",dirname,index,p); +  return p; +  } +  werror("Returning UNDEFINED for %s\n",ind);    return UNDEFINED;    }       mixed `[](string index)    {    mixed ret; -  + // werror("Dirnode(%O) cache[%O] ?????\n",dirname,index);    if(!zero_type(ret=cache[index]))    { -  + // werror("Dirnode(%O) cache[%O] -> %O\n",dirname,index, ret);    // The check below is to (hopefully) avoid calling any function    // in ret (like `! or `==) in case it's an object.    if(!intp (ret) || ret) return ret;    return UNDEFINED;    }    return cache[index]=ind(index);    }       static int _cache_full;    void fill_cache()
pike.git/lib/master.pike.in:913:      // Variables mustn't be static to allow for replace_master().   // /grubba 1998-04-10   mapping(string:mixed) fc=([]);      object findmodule(string fullname)   {    object o;    if(!zero_type(o=fc[fullname]))    { + // werror("fc[%O] -> %O\n",fullname, o);    return o;    }       if(Stat stat=master_file_stat(fakeroot(fullname+".pmod")))    {    if(stat[1]==-2)    return fc[fullname]=dirnode(fullname+".pmod");    }       if(o=low_cast_to_object(fullname+".pmod","/."))
pike.git/lib/master.pike.in:2165:    loop_next - 1 + sizeof (frames)];    if (loops)    frames += ({sprintf ("... last %d frames above repeated %d times ...\n",    -loop_start, loops)});    frames += tail;    }       ret += frames * "";    }    -  return ret; +  return ret || "No backtrace!\n";;   }      //! @global   //! Returns only the error message from a backtrace.   //!   //! If there is no error message in the backtrace, a fallback message   //! will be returned.   //!   //! @seealso   //! @[backtrace()], @[describe_backtrace()]