pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1: - /* $Id: master.pike.in,v 1.20 1998/04/29 00:18:38 hubbe Exp $ + /* $Id: master.pike.in,v 1.21 1998/04/29 03:08:25 grubba Exp $    *    * Master-file for Pike.    *    * Based on master.pike 1.67.    */      int is_absolute_path(string p)   {   #ifdef __NT__    p=replace(p,"\\","/");
pike.git/lib/master.pike.in:310:      }      object new(mixed prog, mixed ... args)   {    if(stringp(prog))    prog=cast_to_program(prog,backtrace()[-2][0]);    return prog(@args);   }    + multiset mkmultiset(array a) + { +  return aggregate_multiset(@a); + } +  + function clone = new; +  + /* This array contains the names of the functions +  * that a replacing master-object may want to override. +  */ + constant master_efuns = ({ +  "basename", +  "dirname", +  "is_absolute_path", +  "explode_path", +  +  "compile_string", +  "compile_file", +  "add_include_path", +  "remove_include_path", +  "add_module_path", +  "remove_module_path", +  "add_program_path", +  "remove_program_path", +  "describe_backtrace", +  "mkmultiset", +  "new", +  "clone", +  +  "getenv", +  "putenv", +  + #ifdef GETCWD_CACHE +  "cd", +  "getcwd", + #endif + }); +    /* Note that create is called before add_precompiled_program    */   void create()   { -  add_constant("basename",basename); -  add_constant("dirname",dirname); -  add_constant("is_absolute_path",is_absolute_path); -  add_constant("explode_path",explode_path); +  object o = this_object();    -  add_constant("compile_string",compile_string); -  add_constant("compile_file",compile_file); -  add_constant("add_include_path",add_include_path); -  add_constant("remove_include_path",remove_include_path); -  add_constant("add_module_path",add_module_path); -  add_constant("remove_module_path",remove_module_path); -  add_constant("add_program_path",add_program_path); -  add_constant("remove_program_path",remove_program_path); -  add_constant("describe_backtrace",describe_backtrace); -  add_constant("mkmultiset",lambda(mixed *a) { return aggregate_multiset(@a); }); -  add_constant("strlen",sizeof); -  add_constant("new",new); -  add_constant("clone",new); -  add_constant("UNDEFINED",UNDEFINED); +  foreach(master_efuns, string e) { +  if (o[e]) { +  add_constant(e, o[e]); +  } else { +  throw(({ sprintf("Function %O is missing from master.pike.\n", e), +  backtrace() })); +  } +  }    - #ifdef GETCWD_CACHE -  add_constant("cd",cd); -  add_constant("getcwd",getcwd); - #endif +  add_constant("strlen", sizeof); +  add_constant("UNDEFINED", UNDEFINED); +  add_constant("write", _static_modules.files()->_stdout->write);       random_seed(time() + (getpid() * 0x11111111));   }      /*    * This function is called whenever a inherit is called for.    * It is supposed to return the program to inherit.    * The first argument is the argument given to inherit, and the second    * is the file name of the program currently compiling. Note that the    * file name can be changed with #line, or set by compile_string, so
pike.git/lib/master.pike.in:501:   void _main(string *orig_argv, string *env)   {    string *argv=copy_value(orig_argv);    int i,debug,trace;    object script;    object tmp;    string a,b;    mixed *q;       foreach(env,a) if(sscanf(a,"%s=%s",a,b)) environment[a]=b; -  add_constant("getenv",getenv); -  add_constant("putenv",putenv); +     -  add_constant("write",_static_modules.files()->_stdout->write); -  +     // add path for architecture-shared files    add_include_path("¤share_prefix¤/include");    add_module_path("¤share_prefix¤/modules");       // add path for architecture-dependant files    add_include_path("¤lib_prefix¤/include");    add_module_path("¤lib_prefix¤/modules");       q=(getenv("PIKE_INCLUDE_PATH")||"")/":"-({""});    for(i=sizeof(q)-1;i>=0;i--) add_include_path(q[i]);
pike.git/lib/master.pike.in:538:    q=tmp->find_all_options(argv,({    ({"version",tmp->NO_ARG,({"-v","--version"})}),    ({"help",tmp->NO_ARG,({"-h","--help"})}),    ({"execute",tmp->HAS_ARG,({"-e","--execute"})}),    ({"preprocess",tmp->HAS_ARG,({"-E","--preprocess"})}),    ({"modpath",tmp->HAS_ARG,({"-M","--module-path"})}),    ({"ipath",tmp->HAS_ARG,({"-I","--include-path"})}),    ({"ppath",tmp->HAS_ARG,({"-P","--program-path"})}),    ({"warnings",tmp->NO_ARG,({"-w","--warnings"})}),    ({"ignore",tmp->HAS_ARG,"-ms"}), +  ({"compiler_trace",tmp->NO_ARG,"--compiler-trace"}),    ({"debug",tmp->MAY_HAVE_ARG,"--debug",0,1}),    ({"trace",tmp->MAY_HAVE_ARG,"--trace",0,1}),    ({"ignore",tmp->MAY_HAVE_ARG,"-Dqdatpl",0,1})    }), 1);       /* Parse -M and -I backwards */    for(i=sizeof(q)-1;i>=0;i--)    {    switch(q[i][0])    {    case "debug":    debug+=(int)q[i][1];    break;    -  + #if constant(_compiler_trace) +  case "compiler_trace": +  _compiler_trace(1); +  break; + #endif /* constant(_compiler_trace) */ +     case "trace":    trace+=(int)q[i][1];    break;       case "modpath":    add_module_path(q[i][1]);    break;       case "ipath":    add_include_path(q[i][1]);