Branch: Tag:

2001-03-20

2001-03-20 02:45:51 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

second step towards two-pass compilation over several files..

Rev: lib/master.pike.in:1.148
Rev: src/builtin.cmod:1.24
Rev: src/builtin_functions.c:1.355
Rev: src/object.c:1.164
Rev: src/object.h:1.58
Rev: src/program.c:1.304
Rev: src/program.h:1.120

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.    *
191:   //! @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);   }      
339:   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;
426:    }      // 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);
449:       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;
494:    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)
504:    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().    */
665:    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;
718:    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));
741:    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;
920:    object o;    if(!zero_type(o=fc[fullname]))    { + // werror("fc[%O] -> %O\n",fullname, o);    return o;    }   
2172:    ret += frames * "";    }    -  return ret; +  return ret || "No backtrace!\n";;   }      //! @global