Skip to content
Snippets Groups Projects
Commit b1693aa9 authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

a little bit better module dumping

Rev: bin/install.pike:1.54
Rev: lib/master.pike.in:1.112
Rev: lib/modules/Standards.pmod/ASN1.pmod/Types.pmod:1.13
Rev: src/dumpmodule.pike:1.9
Rev: src/modules/Regexp/module.pmod.in:1.3
parent fccf996e
No related branches found
No related tags found
No related merge requests found
...@@ -1141,6 +1141,7 @@ void do_install() ...@@ -1141,6 +1141,7 @@ void do_install()
if(sizeof(to_dump)) if(sizeof(to_dump))
{ {
rm("dumpmodule.log");
status("Dumping modules, please wait..."); status("Dumping modules, please wait...");
foreach(to_dump, string mod) rm(mod+".o"); foreach(to_dump, string mod) rm(mod+".o");
/* Dump 50 modules at a time */ /* Dump 50 modules at a time */
......
/* -*- Pike -*- /* -*- Pike -*-
* *
* $Id: master.pike.in,v 1.111 2000/03/30 21:06:53 grubba Exp $ * $Id: master.pike.in,v 1.112 2000/04/08 01:30:19 hubbe Exp $
* *
* Master-file for Pike. * Master-file for Pike.
* *
...@@ -574,7 +574,7 @@ object cast_to_object(string oname, string current_file) ...@@ -574,7 +574,7 @@ object cast_to_object(string oname, string current_file)
if(object o=low_cast_to_object(oname, current_file)) if(object o=low_cast_to_object(oname, current_file))
return o; return o;
error("Cast '"+oname+"' to object failed"+ error("Cast '"+oname+"' to object failed"+
(current_file?sprintf("for '%s'",current_file):"")+".\n"); ((current_file && current_file!="-")?sprintf(" for '%s'",current_file):"")+".\n");
return 0; return 0;
} }
...@@ -1646,30 +1646,33 @@ class Codec ...@@ -1646,30 +1646,33 @@ class Codec
function functionof(string x) function functionof(string x)
{ {
if(sscanf(x,"efun:%s",x)) return f[x]; if(sscanf(x,"efun:%s",x)) return f[x];
if(sscanf(x,"resolv:%s",x)) return resolv(x);
return 0; return 0;
} }
object objectof(string x) object objectof(string x)
{ {
if(sscanf(x,"efun:%s",x)) return f[x]; if(sscanf(x,"efun:%s",x)) return f[x];
if(sscanf(x,"resolv:%s",x)) return resolv(x);
return cast_to_object(x,0); return cast_to_object(x,0);
} }
program programof(string x) program programof(string x)
{ {
if(sscanf(x,"efun:%s",x)) return f[x]; if(sscanf(x,"efun:%s",x)) return f[x];
if(sscanf(x,"resolv:%s",x)) return resolv(x);
return cast_to_program(x,0); return cast_to_program(x,0);
} }
mixed encode_object(object x) mixed encode_object(object x)
{ {
if(x->_encode) return x->_encode();
error("Cannot encode objects yet.\n"); error("Cannot encode objects yet.\n");
} }
mixed decode_object(object x) mixed decode_object(object o, mixed data)
{ {
error("Cannot encode objects yet.\n"); o->_decode(data);
} }
} }
...@@ -390,6 +390,9 @@ class asn1_identifier ...@@ -390,6 +390,9 @@ class asn1_identifier
return this_object(); return this_object();
} }
mixed _encode() { return id; }
void _decode(mixed data) { id=data; }
object append(int ...args) object append(int ...args)
{ {
return object_program(this_object())(@id, @args); return object_program(this_object())(@id, @args);
......
...@@ -13,15 +13,21 @@ class FakeMaster ...@@ -13,15 +13,21 @@ class FakeMaster
} }
} }
#define error(X) throw( ({ (X), backtrace()[0..sizeof(backtrace())-2] }) ) #define error(X) throw( ({ (X), backtrace() }) )
mapping function_names=([]);
class Codec class Codec
{ {
string last_id;
string nameof(mixed x) string nameof(mixed x)
{ {
// if(logfile) logfile->write("%O\n",x);
// werror("%O\n",x); // werror("%O\n",x);
if(p!=x) if(p!=x)
if(mixed tmp=search(all_constants(),x)) if(mixed tmp=function_names[x])
return "efun:"+tmp; return tmp;
switch(sprintf("%t",x)) switch(sprintf("%t",x))
{ {
...@@ -40,13 +46,28 @@ class Codec ...@@ -40,13 +46,28 @@ class Codec
break; break;
case "object": case "object":
if(mixed tmp=search(master()->objects,x)) if(program p=search(master()->objects,x))
{ {
if(tmp=search(master()->programs,tmp)) if(string tmp=search(master()->programs,p))
{ {
return tmp; return tmp;
}else{
#if 0
werror("Completely failed to find this program:\n");
_describe(p);
#endif
} }
} }
if(object_program(x) == master()->dirnode)
{
/* FIXME: this is a bit ad-hoc */
string dirname=x->dirname;
dirname-=".pmod";
sscanf(dirname,"%*slib/modules/%s",dirname);
dirname=replace(dirname,"/",".");
if(master()->resolv(dirname) == x)
return "resolv:"+dirname;
}
break; break;
} }
return ([])[0]; return ([])[0];
...@@ -57,6 +78,9 @@ class Codec ...@@ -57,6 +78,9 @@ class Codec
if(sscanf(x,"efun:%s",x)) if(sscanf(x,"efun:%s",x))
return all_constants()[x]; return all_constants()[x];
if(sscanf(x,"resolv:%s",x))
return master()->resolv(x);
werror("Failed to decode %s\n",x); werror("Failed to decode %s\n",x);
return 0; return 0;
} }
...@@ -67,6 +91,9 @@ class Codec ...@@ -67,6 +91,9 @@ class Codec
if(sscanf(x,"efun:%s",x)) if(sscanf(x,"efun:%s",x))
return all_constants()[x]; return all_constants()[x];
if(sscanf(x,"resolv:%s",x))
return master()->resolv(x);
if(object tmp=(object)x) return tmp; if(object tmp=(object)x) return tmp;
werror("Failed to decode %s\n",x); werror("Failed to decode %s\n",x);
return 0; return 0;
...@@ -78,6 +105,9 @@ class Codec ...@@ -78,6 +105,9 @@ class Codec
if(sscanf(x,"efun:%s",x)) if(sscanf(x,"efun:%s",x))
return all_constants()[x]; return all_constants()[x];
if(sscanf(x,"resolv:%s",x))
return master()->resolv(x);
if(sscanf(x,"_static_modules.%s",x)) if(sscanf(x,"_static_modules.%s",x))
{ {
return (program)_static_modules[x]; return (program)_static_modules[x];
...@@ -90,13 +120,22 @@ class Codec ...@@ -90,13 +120,22 @@ class Codec
mixed encode_object(object x) mixed encode_object(object x)
{ {
// _describe(x); if(x->_encode) return x->_encode();
// if(logfile)
// logfile->write("Cannot encode objects yet: %s\n",master()->stupid_describe(x,100000));
#if 0
werror("\n>>>>>>encode object was called for:<<<<<<\n");
_describe(x);
werror("\n");
#endif
error("Cannot encode objects yet.\n"); error("Cannot encode objects yet.\n");
// error(sprintf("Cannot encode objects yet. %O\n",indices(x))); // error(sprintf("Cannot encode objects yet. %O\n",indices(x)));
} }
mixed decode_object(object x) mixed decode_object(program p, mixed data)
{ {
object ret=p(@data[0]);
if(sizeof(data)>1) ret->_decode(data[1]);
error("Cannot encode objects yet.\n"); error("Cannot encode objects yet.\n");
} }
} }
...@@ -104,15 +143,29 @@ class Codec ...@@ -104,15 +143,29 @@ class Codec
int quiet=0; int quiet=0;
Stdio.File logfile; Stdio.File logfile;
void log(string file, int line, string err)
class Handler
{
void compile_error(string file,int line,string err)
{
if(!logfile) return;
logfile->write(sprintf("%s:%d:%s\n",file,line,err));
}
void compile_warning(string file,int line,string err)
{ {
if(!logfile) return; if(!logfile) return;
logfile->write("================================================\n");
logfile->write(sprintf("%s:%d:%s\n",file,line,err)); logfile->write(sprintf("%s:%d:%s\n",file,line,err));
} }
}
void dumpit(string file) void dumpit(string file)
{ {
if(logfile)
logfile->write("##%s##\n",file);
if(!quiet) if(!quiet)
werror(file +": "); werror(file +": ");
...@@ -130,10 +183,10 @@ void dumpit(string file) ...@@ -130,10 +183,10 @@ void dumpit(string file)
werror("does not exist.\n"); werror("does not exist.\n");
break; break;
} }
if(programp(p=compile_file(file))) if(programp(p=compile_file(file, Handler())))
{ {
string s=encode_value(p, Codec()); string s=encode_value(p, Codec());
p=decode_value(s,Codec()); p=decode_value(s,master()->Codec());
if(programp(p)) if(programp(p))
{ {
Stdio.File(file + ".o","wct")->write(s); Stdio.File(file + ".o","wct")->write(s);
...@@ -169,8 +222,8 @@ void dumpit(string file) ...@@ -169,8 +222,8 @@ void dumpit(string file)
werror("X"); werror("X");
if(logfile) if(logfile)
{ {
err[0]="While dumping "+file+": "+err[0]; // err[0]="While dumping "+file+": "+err[0];
logfile->write("================================================\n"); // logfile->write("================================================\n");
logfile->write(master()->describe_backtrace(err)); logfile->write(master()->describe_backtrace(err));
} }
}else{ }else{
...@@ -182,16 +235,23 @@ void dumpit(string file) ...@@ -182,16 +235,23 @@ void dumpit(string file)
int main(int argc, string *argv) int main(int argc, string *argv)
{ {
foreach( (array)all_constants(), [string name, mixed func])
function_names[func]="efun:"+name;
function_names[Stdio.stdin]="resolv:Stdio.stdin";
function_names[Stdio.stdout]="resolv:Stdio.stdout";
function_names[Stdio.stderr]="resolv:Stdio.stderr";
function_names[_static_modules.Builtin]="resolv:_";
if(argv[1]=="--quiet") if(argv[1]=="--quiet")
{ {
quiet=1; quiet=1;
argv=argv[1..]; argv=argv[1..];
master()->set_inhibit_compile_errors(log);
// FIXME: Make this a command line option.. // FIXME: Make this a command line option..
// It should not be done when running a binary dist // It should not be done when running a binary dist
// installation... // installation...
logfile=Stdio.File("dumpmodule.log","cwt"); logfile=Stdio.File("dumpmodule.log","caw");
// werror("Dumping modules "); // werror("Dumping modules ");
} }
...@@ -199,7 +259,6 @@ int main(int argc, string *argv) ...@@ -199,7 +259,6 @@ int main(int argc, string *argv)
{ {
quiet=2; quiet=2;
argv=argv[1..]; argv=argv[1..];
master()->set_inhibit_compile_errors(log);
logfile=0; logfile=0;
} }
......
...@@ -49,9 +49,15 @@ class Regexp ...@@ -49,9 +49,15 @@ class Regexp
{ {
case 'O': case 'O':
return sprintf("Regexp(%O)", regexp_string); return sprintf("Regexp(%O)", regexp_string);
case 's':
return regexp_string;
} }
return 0; return 0;
} }
mixed _encode() { return regexp_string; }
mixed _decode(string s) { create(s); }
} }
program _module_value=Regexp; program _module_value=Regexp;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment