pike.git/
lib/
master.pike.in
Branch:
Tag:
Non-build tags
All tags
No tags
1999-11-04
1999-11-04 17:00:14 by Henrik Grubbström (Grubba) <grubba@grubba.org>
01d3c960aa888bb1d0c72520215d4474d1cb1e79 (
75
lines) (+
54
/-
21
)
[
Show
|
Annotate
]
Branch:
7.9
Improved warnings.
Rev: lib/master.pike.in:1.67
1:
-
/* $Id: master.pike.in,v 1.
66
1999/11/04
02
:
35
:
31
grubba Exp $
+
/* $Id: master.pike.in,v 1.
67
1999/11/04
17
:
00
:
14
grubba Exp $
* * Master-file for Pike. *
103:
#endif
-
program compile_string(string data, void|string name)
+
program compile_string(string data, void|string name
, object|void handler
)
{
-
return compile(cpp(data,name||"-"));
+
return compile(cpp(data,name||"-"
, 0, handler
)
, handler
);
}
-
program compile_file(string file)
+
program compile_file(string file
, object|void handler
)
{ AUTORELOAD_CHECK_FILE(file);
-
return compile(cpp(_static_modules.files()->Fd(file,"r")->read(),file, 1));
+
return compile(cpp(_static_modules.files()->Fd(file,"r")->read(),
+
file, 1
, handler
)
, handler
);
}
262:
AUTORELOAD_CHECK_FILE(fname+".o"); return programs[fname]=decode_value(_static_modules.files()->Fd(fname+".o","r")->read(),Codec()); };
-
if(want_warnings) {
+
if (handler) {
-
handler->compile_warning(fname, 0,
+
handler->compile_warning(fname
+ ".o"
, 0,
sprintf("Decode failed:\n" "\t%s", err[0])); } else {
-
compile_warning(fname, 0,
+
compile_warning(fname
+ ".o"
, 0,
sprintf("Decode failed:\n" "\t%s", err[0])); }
-
+
} else {
+
if (handler) {
+
handler->compile_warning(fname + ".o", 0,
+
"Compiled file is out of date\n");
+
} else {
+
compile_warning(fname + ".o", 0, "Compiled file is out of date\n");
} } }
1002:
if(i >=0) exit(i); }
+
#if constant(thread_local)
+
object inhibit_compile_errors = thread_local();
+
+
void set_inhibit_compile_errors(mixed f)
+
{
+
inhibit_compile_errors->set(f);
+
}
+
#else /* !constant(thread_local) */
mixed inhibit_compile_errors; void set_inhibit_compile_errors(mixed f) { inhibit_compile_errors=f; }
-
+
#endif /* constant(thread_local) */
string trim_file_name(string s) {
1026:
*/ void compile_error(string file,int line,string err) {
-
if(!inhibit_compile_errors)
+
mixed val;
+
if(!
(val =
inhibit_compile_errors
+
#if constant(thread_local
)
+
->get()
+
#endif /* constant(thread_local) */
+
))
{ werror(sprintf("%s:%d:%s\n",trim_file_name(file),line,err)); }
-
else if(objectp(
inhibit_compile_errors
) ||
-
programp(
inhibit_compile_errors
) ||
-
functionp(
inhibit_compile_errors
))
+
else if(objectp(
val
) ||
+
programp(
val
) ||
+
functionp(
val
))
{
-
+
if (objectp(val) && val->compile_error) {
+
val->compile_error(file, line, err);
+
} else {
inhibit_compile_errors(file,line,err); } }
-
+
}
/* * This function is called whenever a compiling error occurs,
1046:
*/ void compile_warning(string file,int line,string err) {
-
if(!inhibit_compile_errors)
+
mixed val;
+
+
if(!
(val =
inhibit_compile_errors
+
#if constant(thread_local
)
+
->get()
+
#endif /* constant(thread_local) */
+
))
{ if(want_warnings) werror(sprintf("%s:%d:Warning: %s\n",trim_file_name(file),line,err));
-
+
} else if (objectp(val) && val->compile_warning) {
+
val->compile_warning(file, line, err);
} }