Branch: Tag:

2001-05-24

2001-05-24 18:14:28 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Improved propagation of the error-handler.

Rev: lib/master.pike.in:1.154

1:   /* -*- Pike -*-    * -  * $Id: master.pike.in,v 1.153 2001/04/17 08:41:58 mirar Exp $ +  * $Id: master.pike.in,v 1.154 2001/05/24 18:14:28 grubba Exp $    *    * Master-file for Pike.    *
443:    programs[fname]=ret=__empty_program();    if ( mixed e=catch {    ret=compile_file(fname, -  0, +  handler,    ret,    mkobj? (objects[ret]=__null_program()) : 0);    } )
503:    string nname;    array(string) tmp=EXPLODE_PATH(pname);    +  // werror("low_cast_to_program(%O, %O, %O, %O)\n", +  // pname, current_file, handler, mkobj); +     if(sscanf(reverse(tmp[-1]),"%s.%s",ext, nname))    {    ext="."+reverse(ext);
694:      mapping (program:object) objects=([object_program(this_object()):this_object()]);    - object low_cast_to_object(string oname, string current_file) + object low_cast_to_object(string oname, string current_file, +  object|void current_handler)   {    program p;    object o;    -  p=low_cast_to_program(oname, current_file, 0, 1); +  p = low_cast_to_program(oname, current_file, current_handler, 1);    if(!p) return 0;    if(!(o=objects[p])) o=objects[p]=p();    return o;
718:    return 0;   }    - class dirnode + class dirnode(string dirname, object|void handler)   {    constant is_resolv_dirnode = 1; -  string dirname; +     mixed module=module_checker();    mapping(string:mixed) cache=([]);    array(string) files;    -  void create(string name) -  { -  dirname=name; -  } -  +     class module_checker    {    int `!()    {    module=0; -  if(module=findmodule(dirname+"/module")) +  if(module=findmodule(dirname+"/module", handler))    if(mixed tmp=module->_module_value)    module=tmp;    return !module;
774:    if(!ret)    return UNDEFINED;    index = dirname+"/"+index; -  if(object o=findmodule(index)) +  if(object o=findmodule(index, handler))    {    if(mixed tmp=o->_module_value) o=tmp;    return o;    } -  if (program p=cast_to_program( index, 0 )) +  if (program p=cast_to_program( index, 0, handler ))    {   // werror("dirnode(%O)[%O] -> %O\n",dirname,index,p);    return p;
960:   // /grubba 1998-04-10   mapping(string:mixed) fc=([]);    - object findmodule(string fullname) + object findmodule(string fullname, object|void handler)   {    object o;    if(!zero_type(o=fc[fullname]))
972:    if(Stat stat=master_file_stat(fakeroot(fullname+".pmod")))    {    if(stat[1]==-2) -  return fc[fullname]=dirnode(fullname+".pmod"); +  return fc[fullname]=dirnode(fullname+".pmod", handler);    }    -  if(o=low_cast_to_object(fullname+".pmod","/.")) +  if(o = low_cast_to_object(fullname+".pmod", "/.", handler))    return fc[fullname]=o;      #if constant(load_module)    if(master_file_stat(fakeroot(fullname+".so"))) -  return fc[fullname]=low_cast_to_object(fullname,"/."); +  return fc[fullname] = low_cast_to_object(fullname, "/.", handler);   #endif       return fc[fullname]=UNDEFINED;
996:    tmp[-1]=what;    path=combine_path_with_cwd( tmp*"/");    } +  if (handler) { +  return dirnode(path, handler); +  }    return fc[path]=dirnode(path);   }   
1133:    return x;    }    -  mixed resolv_base(string identifier, string|void current_file) +  mixed resolv_base(string identifier, string|void current_file, +  object|void current_handler)    {    array(mixed) tmp = ({});    string dir=current_file ? dirname(current_file) : "/"; -  +     foreach(pike_module_path, string path)    { -  string file=combine_path(dir ,path,identifier); -  if(mixed ret=findmodule(file)) { +  string file=combine_path(dir, path, identifier); +  if(mixed ret=findmodule(file, current_handler)) {    if ((objectp(ret)) &&    (ret->is_resolv_dirnode || ret->is_resolv_joinnode)) {    if (mixed new_ret = ret->_module_value) {
1172:    }       mapping resolv_cache = set_weak_flag( ([]), 1 ); -  mixed resolv(string identifier, string|void current_file) +  mixed resolv(string identifier, string|void current_file, +  object|void current_handler)    { -  +  // FIXME: Support having the cache in the handler?    if( no_resolv[ identifier ] )    return UNDEFINED;   
1182:    if( !zero_type (ret = resolv_cache[id]) )    return ret == ZERO_TYPE ? UNDEFINED : resolv_cache[id];    array(string) tmp=identifier/"."; -  ret=resolv_base(tmp[0],current_file); +  ret=resolv_base(tmp[0], current_file, current_handler);    foreach(tmp[1..],string index) ret=ret[index];    resolv_cache[id] = zero_type (ret) ? ZERO_TYPE : ret;    return ret;