pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:788:    if(autoreload_on) { \    int mtime = get_precompiled_mtime (X); \    if (mtime >= 0 && mtime > newest) \    if(s->mtime>newest) newest=[int]s->mtime; \    } \    } while(0)      #define AUTORELOAD_FINISH(VAR, CACHE, FILE) \    if(autoreload_on) { \    mixed val = CACHE[FILE]; \ -  if(!zero_type (val) && val != no_value && \ +  if(!undefinedp (val) && val != no_value && \    newest <= load_time[FILE]) { \    VAR = val; \    } \    } \    load_time[FILE] = newest; \    if(___newest > newest) newest=___newest;         mapping(string:int) load_time=([]);   #else
pike.git/lib/master.pike.in:827:    void|program p,    void|object o,    void|int _show_if_constant_errors)   {   #ifdef RECUR_COMPILE_DEBUG    werror ("%*s>>> compile_string %O\n", GET_MSG_DEPTH, "", filename);    INC_MSG_DEPTH();   #endif    string code = cpp(source, filename||"-", 1, handler,    compat_major, compat_minor, -  (zero_type(_show_if_constant_errors)? +  (undefinedp(_show_if_constant_errors)?    show_if_constant_errors:    _show_if_constant_errors));    program ret;    if(code)    ret = compile(code,    handler,    compat_major,    compat_minor,    p,    o);
pike.git/lib/master.pike.in:901:    string file = BASENAME(dir);    dir = dirname(dir);       if(time() > invalidate_time)    {    dir_cache = ([]);    invalidate_time = time()+FILE_STAT_CACHE_TIME;    }       multiset(string) d = dir_cache[dir]; -  if( zero_type(d) ) +  if( undefinedp(d) )    {    array(string) tmp = master_get_dir(dir);    if(tmp)    {   #ifdef __NT__    tmp = map(tmp, lower_case);   #endif    d = dir_cache[dir] = (multiset)tmp;    }    else
pike.git/lib/master.pike.in:1497:    }    }   #endif       if( (s=master_file_stat(fakeroot(fname))) && s->isreg )    {   #ifdef PIKE_AUTORELOAD    if(!autoreload_on || load_time[fname] >= s->mtime)   #endif    { -  if(!zero_type (ret=programs[fname]) && ret != no_value) { +  if(!undefinedp (ret=programs[fname]) && ret != no_value) {    resolv_debug ("low_findprog %s: returning cached (no autoreload)\n", fname);    return ret;    }    }       AUTORELOAD_BEGIN();      #ifdef PIKE_AUTORELOAD    if (load_time[fname] >= s->mtime) -  if (!zero_type (ret=programs[fname]) && ret != no_value) { +  if (!undefinedp (ret=programs[fname]) && ret != no_value) {    resolv_debug ("low_findprog %s: returning cached (autoreload)\n", fname);    return ret;    }   #endif       switch(ext)    {    case "":    case ".pike":    foreach(query_precompiled_names(fname), string oname) {
pike.git/lib/master.pike.in:1727:    ext="."+reverse(ext);    pname=pname[..<sizeof(ext)];    }    else {    ext="";    }       if(IS_ABSOLUTE_PATH(pname))    {    program|NoValue prog = programs[pname]; -  if ((!zero_type(prog)) && (prog != no_value)) +  if ((!undefinedp(prog)) && (prog != no_value))    {    return prog;    }    pname=combine_path("",pname);    return findprog(pname,ext,handler,mkobj);    }    else {    string cwd;    if(current_file)    {
pike.git/lib/master.pike.in:1892:   //! @decl int werror(string fmt, mixed ... args)   //! @appears werror   //! Writes a string on stderr. Works just like @[Stdio.File.write]   //! on @[Stdio.stderr].      /* Note that create is called before add_precompiled_program    */   protected void create()   {    foreach(master_efuns, string e) -  if (!zero_type(this[e])) +  if (has_index(this, e))    add_constant(e, this[e]);    else    error("Function %O is missing from master.pike.\n", e);       add_constant("__dirnode", dirnode);    add_constant("__joinnode", joinnode);       add_constant("write", write);    add_constant("werror", werror);    // To make it possible to overload get_dir and file_stat later on.
pike.git/lib/master.pike.in:2260:    DEC_RESOLV_MSG_DEPTH();    resolv_debug("dirnode(%O)->ind(%O) => cache_full %O\n",    dirname, index, cache[index]);    return cache[index];    }       if(module)    {    mixed o;   // _describe(module); -  if(!zero_type(o=module[index])) +  if(!undefinedp(o=module[index]))    {    DEC_RESOLV_MSG_DEPTH();    resolv_debug ("dirnode(%O)->ind(%O) => found %O\n",    dirname, index, o);    return o;    }    resolv_debug ("dirnode(%O)->ind(%O) => not found in module\n",    dirname, index);    }    else
pike.git/lib/master.pike.in:2284:    return low_ind(index);    }       protected mixed `[](string index)    {    mixed ret;   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) cache[%O] ?????\n",    sizeof(backtrace()),dirname,index);   #endif -  if(!zero_type(ret=cache[index])) +  if(!undefinedp(ret=cache[index]))    {   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) cache[%O] => %O%s\n",    sizeof(backtrace()),dirname,index, ret,    (ret != ZERO_TYPE)?"":" (zero_type)");   #endif    if (ret != ZERO_TYPE) return ret;   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) ZERO_TYPE!\n",    sizeof(backtrace()),dirname);
pike.git/lib/master.pike.in:2310:    // We might have gotten placeholder objects in the first pass    // which must not be cached to the second.    if(ret == predef::__placeholder_object) {   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) PLACE_HOLDER.\n",    sizeof(backtrace()),dirname);   #endif    return ret;    }    -  cache[index] = zero_type(ret) ? ZERO_TYPE : ret; +  cache[index] = undefinedp(ret) ? ZERO_TYPE : ret;    return ret;    }       mixed safe_index(string index)    {    mixed err;    resolv_debug ("dirnode(%O): %O...\n", dirname, index);    if (err = catch { return `[](index); }) {    call_compile_warning (compilation_handler,    dirname+"."+fname,
pike.git/lib/master.pike.in:2474:       protected mixed ind(string index)    {    resolv_debug ("joinnode(%O)->ind(%O)\n", joined_modules, index);    INC_RESOLV_MSG_DEPTH();       array(mixed) res = ({});    foreach(joined_modules, object|mapping o)    {    mixed ret; -  if (!zero_type(ret = o[index])) +  if (!undefinedp(ret = o[index]))    {    if (objectp(ret) &&    (ret->is_resolv_dirnode || ret->is_resolv_joinnode))    {    // Only join directorynodes (or joinnodes).    res += ({ ret });    } else {    DEC_RESOLV_MSG_DEPTH();    resolv_debug ("joinnode(%O)->ind(%O) => found %O\n",    joined_modules, index, ret);
pike.git/lib/master.pike.in:2508:       DEC_RESOLV_MSG_DEPTH();    resolv_debug ("joinnode(%O)->ind(%O) => not found. Trying fallback %O\n",    joined_modules, index, fallback_module);    return fallback_module[index];    }       protected mixed `[](string index)    {    mixed ret; -  if (!zero_type(ret = cache[index])) { +  if (!undefinedp(ret = cache[index])) {    if (ret != ZERO_TYPE) {    return ret;    }    return UNDEFINED;    }    ret = ind(index);       // We might have gotten placeholder objects in the first pass    // which must not be cached to the second.    if(ret == predef::__placeholder_object) return ret;    -  if (zero_type(ret)) { +  if (undefinedp(ret)) {    cache[index] = ZERO_TYPE;    } else {    cache[index] = ret;    }    return ret;    }       protected int _cache_full;       void fill_cache()    {   #if 0    werror(call_describe_backtrace(({ "Filling cache in joinnode\n",    backtrace() })));   #endif    if (_cache_full) {    return;    }    foreach(joined_modules, object|mapping|program o) {    foreach(indices(o), string index) { -  if (zero_type(cache[index])) { +  if (!has_index(cache, index)) {    `[](index);    }    }    }    foreach(indices(fallback_module), string index) {    `[](index);    }    _cache_full = 1;    }   
pike.git/lib/master.pike.in:2654:    node->add_path(path);    return node;   }      program|object findmodule(string fullname, object|void handler,    void|string name)   {    program|object o;       resolv_debug ("findmodule(%O)\n", fullname); -  if(!zero_type(o=fc[fullname]) && o != no_value) +  if(!undefinedp(o=fc[fullname]) && o != no_value)    {    if (objectp(o) || programp(o) || o != 0) {    resolv_debug ("findmodule(%O) => found %O (cached)\n", fullname, o);    return o;    }    resolv_debug ("findmodule(%O) => not found (cached)\n", fullname);    return UNDEFINED;    }       if(Stat stat=master_file_stat(fakeroot(fullname)))
pike.git/lib/master.pike.in:3051:    // werror("Resolv_base(%O)\n",identifier);    return get_root_module(current_handler)[identifier];    }       //! Same as @[resolv], but throws an error instead of returning    //! @[UNDEFINED] if the resolv failed.    mixed resolv_or_error(string identifier, string|void current_file,    void|object current_handler)    {    mixed res = resolv(identifier, current_file, current_handler); -  if(zero_type(res)) error("Could not resolve %s.\n", identifier); +  if(undefinedp(res)) error("Could not resolve %s.\n", identifier);    return res;    }       //!    mixed resolv(string identifier, string|void current_file,    object|void current_handler)    {    resolv_debug("resolv(%O, %O)\n",identifier, current_file);    INC_RESOLV_MSG_DEPTH();   
pike.git/lib/master.pike.in:3089:    switch(scope) {    case "predef":    ret = all_constants();    break;    default:    if (sscanf(scope, "%d.%d%*s", int major, int minor) == 3) {    // Versioned identifier.    ret = get_compilation_handler(major, minor);    if (ret) {    mixed mod = ret->get_default_module(); -  if (!zero_type(mod = mod[tmp[0]])) { +  if (!undefinedp(mod = mod[tmp[0]])) {    ret = mod;    } else {    ret = ret->resolv(tmp[0]);    }    tmp = tmp[1..];    break;    }    }    error("resolv(%O, %O, %O): Unsupported scope: %O!\n",    identifier, current_file, current_handler, scope);    }    } else {    tmp = identifier/".";    ret = resolv_base(tmp[0], current_file, current_handler);    tmp = tmp[1..];    }    foreach(tmp,string index) {    resolv_debug("indexing %O with %O...\n",    ret, index);    resolv_debug("indices(%O): %O\n", ret, indices(ret)); -  if (zero_type(ret)) break; +  if (undefinedp(ret)) break;    ret = ret[index];    }    DEC_RESOLV_MSG_DEPTH();   #ifdef RESOLV_DEBUG -  if (zero_type (ret)) +  if (undefinedp (ret))    resolv_debug("resolv(%O, %O) => not found\n",identifier, current_file);    else    resolv_debug("resolv(%O, %O) => found %O\n",identifier, current_file, ret);   #endif /* RESOLV_DEBUG */    return ret;    }          //! This function is called whenever an #include directive is    //! encountered. It receives the argument for #include and should
pike.git/lib/master.pike.in:4050:    else if (intp (ident[m]) && ident[m] > 1)    ident[m] = "@" + identcount++;    };       string res;    if (catch (res=sprintf("%t",m)))    res = "object"; // Object with a broken _sprintf(), probably.    switch(res)    {    case "int": -  if (!m && zero_type (m) == 1) +  if (!m && undefinedp (m) == 1)    return "UNDEFINED";    case "float":    return (string)m;    case "string":    return describe_string ([string]m, maxlen);    case "array":    res = describe_array ([array]m, maxlen);    break;    case "mapping":    res = describe_mapping ([mapping]m, maxlen);
pike.git/lib/master.pike.in:4345:    }       // We're really out of luck here...    return res + (describe_program(parent_fun)||"unknown_program") + "()->";   }      //!   string describe_object(object o)   {    string s; -  if(zero_type (o)) return 0; // Destructed. +  if(undefinedp (o)) return 0; // Destructed.       // Handled by the search of all_constants() below.    // if (o == _static_modules) return "_static_modules";       program|function(mixed...:void|object) parent_fun = object_program(o);       /* Constant object? */    catch {    object|program parent_obj =    (function_object(parent_fun) || function_program(parent_fun));
pike.git/lib/master.pike.in:4485:    }       // Note: Partial code duplication in describe_error and get_backtrace.       if (objectp(trace) && ([object]trace)->is_generic_error) {    object err_obj = [object] trace;    if (mixed err = catch {       if (functionp (err_obj->message))    ret = err_obj->message(); -  else if (zero_type (ret = err_obj->error_message)) +  else if (undefinedp (ret = err_obj->error_message))    // For compatibility with error objects trying to behave    // like arrays.    ret = err_obj[0];    if (!ret)    ret = "";    else if (!stringp (ret))    ret = sprintf ("<Message in %O is %t, expected string>\n",    err_obj, ret);       if (functionp (err_obj->backtrace))    trace = err_obj->backtrace(); -  else if (zero_type (trace = err_obj->error_backtrace)) +  else if (undefinedp (trace = err_obj->error_backtrace))    // For compatibility with error objects trying to behave    // like arrays.    trace = err_obj[1];    if (!trace)    return ret + "<No backtrace>\n";    else if (!arrayp (trace))    return sprintf ("%s<Backtrace in %O is %t, expected array>\n",    ret, err_obj, trace);       })
pike.git/lib/master.pike.in:4638:    row = describe_program(object_program(tmp)) + " with broken _sprintf()";    } else {    row = "Destructed object";    }    }    }) {    row = sprintf("Error indexing backtrace line %d: %s (%O)!", e, err[0], err[1]);    }       int dup_frame; -  if (!zero_type(dup_frame = prev_pos[row])) { +  if (!undefinedp(dup_frame = prev_pos[row])) {    dup_frame -= sizeof(frames);    if (!loop_start) {    loop_start = dup_frame;    loop_next = dup_frame + 1;    loops = 0;    continue;    } else {    int new_loop = 0;    if (!loop_next) loop_next = loop_start, new_loop = 1;    if (dup_frame == loop_next++) {
pike.git/lib/master.pike.in:4714:    mixed msg;       // Note: Partial code duplication in describe_backtrace and get_backtrace.       if (objectp(err) && ([object]err)->is_generic_error) {    object err_obj = [object] err;    if (mixed err = catch {       if (functionp (err_obj->message))    msg = err_obj->message(); -  else if (zero_type (msg = err_obj->error_message)) +  else if (undefinedp (msg = err_obj->error_message))    // For compatibility with error objects trying to behave    // like arrays.    msg = err_obj[0];       if (stringp (msg))    return msg;    else if (!msg)    return "<No error message>\n";    else    return sprintf ("<Message in %O is %t, expected string>\n",
pike.git/lib/master.pike.in:4760:   {    array bt;       // Note: Partial code duplication in describe_backtrace and describe_error.       if (objectp(err) && ([object]err)->is_generic_error) {    object err_obj = [object] err;       if (functionp (err_obj->backtrace))    bt = err_obj->backtrace(); -  else if (zero_type (bt = err_obj->error_backtrace)) +  else if (undefinedp (bt = err_obj->error_backtrace))    // For compatibility with error objects trying to behave like    // arrays.    bt = err_obj[1];       if (bt && !arrayp (bt))    error ("Backtrace in %O is %t, expected array.\n", err_obj, bt);    }       else if (arrayp(err) && sizeof([array]err)==2 &&    (!(bt = ([array]err)[1]) || arrayp (bt)))
pike.git/lib/master.pike.in:4785:       return bt;   }         #ifdef ENCODE_DEBUG   # define ENC_MSG(X...) do werror (X); while (0)   # define ENC_RETURN(val) do { \    mixed _v__ = (val); \    werror (" returned %s\n", \ -  zero_type (_v__) ? "UNDEFINED" : \ +  undefinedp (_v__) ? "UNDEFINED" : \    narrowify_string(sprintf ("%O", _v__))); \    return _v__; \   } while (0)   #else   # define ENC_MSG(X...) do {} while (0)   # define ENC_RETURN(val) do return (val); while (0)   #endif      #ifdef DECODE_DEBUG   # define DEC_MSG(X...) do werror (X); while (0)   # define DEC_RETURN(val) do { \    mixed _v__ = (val); \    werror (" returned %s\n", \ -  zero_type (_v__) ? "UNDEFINED" : \ +  undefinedp (_v__) ? "UNDEFINED" : \    narrowify_string(sprintf ("%O", _v__))); \    return _v__; \   } while (0)   #else   # define DEC_MSG(X...) do {} while (0)   # define DEC_RETURN(val) do return (val); while (0)   #endif      class Encoder   //! @appears Pike.Encoder
pike.git/lib/master.pike.in:5290:    }       protected mixed thingof (string|array what)    {    mixed res;    array sublist;    if (arrayp (what)) sublist = [array]what, what = [array|string]sublist[0];       switch (what[0]) {    case 'c': -  if (zero_type (res = all_constants()[what[1..]])) +  if (undefinedp (res = all_constants()[what[1..]]))    error ("Cannot find global constant %O.\n", what[1..]);    break;    case 's': -  if (zero_type (res = _static_modules[what[1..]])) +  if (undefinedp (res = _static_modules[what[1..]]))    error ("Cannot find %O in _static_modules.\n", what[1..]);    break;    case 'r': -  if (zero_type (res = resolv ([string]what[1..], fname, handler))) +  if (undefinedp (res = resolv ([string]what[1..], fname, handler)))    error ("Cannot resolve %O.\n", what[1..]);    break;    case 'p':    if (!(res = low_cast_to_program ([string]what[1..], fname, handler)))    error ("Cannot find program for %O.\n", what[1..]);    break;    case 'o':    if (!objectp(res = low_cast_to_object([string]what[1..], fname, handler)))    error ("Cannot find object for %O.\n", what[1..]);    break;
pike.git/lib/master.pike.in:5325:    DEC_MSG (" got %O\n", res);       if (sublist) {    mixed subres = res;    for (int i = 1; i < sizeof (sublist); i++) {    mixed op = sublist[i];    if (stringp (op)) {    if (!programp (subres) && !objectp (subres) && !mappingp (subres))    error ("Cannot subindex %O%{[%O]%} since it's a %t.\n",    res, sublist[1..i-1], subres); -  if (zero_type (subres = ([mapping]subres)[op])) +  if (undefinedp (subres = ([mapping]subres)[op]))    error ("Cannot find %O in %O%{[%O]%}.\n",    op, res, sublist[1..i-1]);    DEC_MSG (" indexed with %O: %O\n", op, subres);    }    else switch (op) {    case 'm':    if (objectp (subres) && ([object]subres)->is_resolv_joinnode) {    dirnode found;    foreach (([object(joinnode)]subres)->joined_modules,    object|mapping part)
pike.git/lib/master.pike.in:5560:    /* Do we want to make an error if major.minor > __MAJOR__.__MINOR ?    *    * No; it's useful for referring to the next version when writing    * compat modules.    */    return 0;    }       CompatResolver ret;    -  if(!zero_type(ret=compat_handler_cache[v])) return ret; +  if(!undefinedp(ret=compat_handler_cache[v])) return ret;       array(string) files;    array(Version) available=({});      #if "#share_prefix#"[0]!='#'    if (!(files = master_get_dir("#share_prefix#"))) {    werror ("Error listing directory %O: %s\n",    "#share_prefix#", strerror (errno()));    files = ({});    }